Update app.py
Browse files26 unmodified lines272829303130313233343535363739383940414243444544464748491 unmodified line51525354555657585935 unmodified lines959697989910010110210324 unmodified lines1281291301251311321271331341351362 unmodified lines13914014113614214314414526 unmodified lines processed_data = [i for i in input_data[columnname]] random_selection = random.sample(processed_data, num_data) filtered_data = filter_similar_items(random_selection, similarity_threshold = 0.5) st.write('The Number of Data You Input: ',len(random_selection)) st.write('After Removing Duplicates: ',len(filtered_data)) st.write('Number of data input: ',len(random_selection)) st.write('After removing duplicates: ',len(filtered_data)) return filtered_data
def chi2eng(filtered_data): trans_pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-zh-en") translated_data = [] language_Classification = langid.classify(filtered_data[0])[0] if language_Classification == "zh": st.write("Your input is Chinese, Translating to English") st.write("Your input is Chinese, translating to English") st.write('▶️ Translation model start downing, loading model may takes time, please wait...') trans_pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-zh-en") st.write('⏺️ Translation model successfully loaded') for i in filtered_data: st.write(trans_pipe(i)[0]['translation_text']) translated_data.append(trans_pipe(i)[0]['translation_text']) elif language_Classification == 'en': st.write("Your input is English, Moving to Next Stage") st.write("Your input is English, moving to next stage...") translated_data = [i for i in filtered_data] else: st.write('The anguage you input is: ',langid.classify(filtered_data[0])[0],'the program cannot process')1 unmodified line
# Text Classification:Negative/Neutral/Positivedef emotion_classification(translated_data): st.write('▶️ Classification model start downing, loading model may takes time, please wait...') emo_pipe = pipeline("text-classification", model="deeplearningwithpython5240/twitter_roberta_base_sentiment_fintune_with_app_reviews") st.write('⏺️ Classification model successfully loaded') negative_count, neutral_count, positive_count = 0,0,0 negative_dict = {} for i in translated_data:35 unmodified lines
# Summarizationdef summarization(top10_negative_str): st.write('▶️ Summarizatio model start downing, loading model may takes time, please wait...') summarize_pipe = pipeline("text2text-generation", model="deeplearningwithpython5240/summarisation-t5-finetuned-model", max_new_tokens =512) st.write('⏺️ Summarization model successfully loaded') summarized_text = summarize_pipe(top10_negative_str) return summarized_text
24 unmodified lines st.text('️️ ')
#stage 3:emotion Classification st.text('️️🔶 Processing Emotion Calssification 🔶') st.text('️️🔶 Processing Emotion Classification 🔶') top10_negative_str = emotion_classification(translated_data) st.text('️️🟢 Emotion Calssification Finished 🟢') st.text('️️🟢 Emotion Classification Finished 🟢') st.text('️️ ')
#stage 4:Summarization2 unmodified lines st.write(summarized_text) st.text('️️🟢 Summarization Finished 🟢') except: st.write("Please load a file to continue...") st.write("") if __name__ == "__main__": main()app.py+14-8