Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,21 +9,33 @@ from fuzzywuzzy import fuzz
|
|
9 |
st.title("Exploring Torch, Transformers, Rake, and Others analyzing Text")
|
10 |
|
11 |
# Define the options for the dropdown menu, Selecting a remote txt file already created to analyze the text
|
12 |
-
options = ['
|
13 |
|
14 |
# Create a dropdown menu to select options
|
15 |
-
selected_option = st.selectbox("Select
|
16 |
|
17 |
# Define URLs for different options
|
18 |
-
url_option1 = "https://raw.githubusercontent.com/peteciank/public_files/main/
|
19 |
-
url_option2 = "https://raw.githubusercontent.com/peteciank/public_files/main/
|
|
|
|
|
|
|
|
|
20 |
|
21 |
# Function to fetch text content based on selected option
|
22 |
def fetch_text_content(selected_option):
|
23 |
-
if selected_option == '
|
24 |
return requests.get(url_option1).text
|
25 |
-
elif selected_option == '
|
26 |
return requests.get(url_option2).text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
else:
|
28 |
return ""
|
29 |
|
@@ -77,24 +89,28 @@ def extract_keywords(text):
|
|
77 |
text = st.text_area('Enter the text to analyze', jd)
|
78 |
|
79 |
if text:
|
80 |
-
# Sentiment analysis
|
81 |
-
st.write("Sentiment Analysis")
|
82 |
-
out_sentiment = pipe_sent(text)
|
83 |
-
# Display sentiment analysis result
|
84 |
-
sentiment_score = out_sentiment[0]['score']
|
85 |
-
sentiment_label = out_sentiment[0]['label']
|
86 |
-
sentiment_emoji = 'π' if sentiment_label == 'POSITIVE' else 'π'
|
87 |
-
sentiment_text = f"Sentiment Score: {sentiment_score}, Sentiment Label: {sentiment_label.capitalize()} {sentiment_emoji}"
|
88 |
-
st.write(sentiment_text)
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
|
9 |
st.title("Exploring Torch, Transformers, Rake, and Others analyzing Text")
|
10 |
|
11 |
# Define the options for the dropdown menu, Selecting a remote txt file already created to analyze the text
|
12 |
+
options = ['Apprecitation Letter', 'Regret Letter', 'Kindness Tale', 'Lost Melody Tale', 'Twitter Example 1', 'Twitter Example 2']
|
13 |
|
14 |
# Create a dropdown menu to select options
|
15 |
+
selected_option = st.selectbox("Select a preset option", options)
|
16 |
|
17 |
# Define URLs for different options
|
18 |
+
url_option1 = "https://raw.githubusercontent.com/peteciank/public_files/main/Transformers/Appreciation_Letter.txt"
|
19 |
+
url_option2 = "https://raw.githubusercontent.com/peteciank/public_files/main/Transformers/Regret_Letter.txt"
|
20 |
+
url_option3 = "https://raw.githubusercontent.com/peteciank/public_files/main/Transformers/Kindness_Tale.txt"
|
21 |
+
url_option4 = "https://raw.githubusercontent.com/peteciank/public_files/main/Transformers/Lost_Melody_Tale.txt"
|
22 |
+
url_option5 = "https://raw.githubusercontent.com/peteciank/public_files/main/Transformers/Twitter_Example_1.txt"
|
23 |
+
url_option6 = "https://raw.githubusercontent.com/peteciank/public_files/main/Transformers/Twitter_Example_2.txt"
|
24 |
|
25 |
# Function to fetch text content based on selected option
|
26 |
def fetch_text_content(selected_option):
|
27 |
+
if selected_option == 'Apprecitation Letter':
|
28 |
return requests.get(url_option1).text
|
29 |
+
elif selected_option == 'Regret Letter':
|
30 |
return requests.get(url_option2).text
|
31 |
+
elif selected_option == 'Kindness Tale':
|
32 |
+
return requests.get(url_option3).text
|
33 |
+
elif selected_option == 'Lost Melody Tale':
|
34 |
+
return requests.get(url_option4).text
|
35 |
+
elif selected_option == 'Twitter Example 1':
|
36 |
+
return requests.get(url_option5).text
|
37 |
+
elif selected_option == 'Twitter Example 2':
|
38 |
+
return requests.get(url_option6).text
|
39 |
else:
|
40 |
return ""
|
41 |
|
|
|
89 |
text = st.text_area('Enter the text to analyze', jd)
|
90 |
|
91 |
if text:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
+
with st.expander("Sentiment Analysis", expanded=True):
|
94 |
+
# Sentiment analysis
|
95 |
+
out_sentiment = pipe_sent(text)
|
96 |
+
# Display sentiment analysis result
|
97 |
+
sentiment_score = out_sentiment[0]['score']
|
98 |
+
sentiment_label = out_sentiment[0]['label']
|
99 |
+
sentiment_emoji = 'π' if sentiment_label == 'POSITIVE' else 'π'
|
100 |
+
sentiment_text = f"Sentiment Score: {sentiment_score}, Sentiment Label: {sentiment_label.capitalize()} {sentiment_emoji}"
|
101 |
+
st.write(sentiment_text)
|
102 |
+
st.write("β
Completed")
|
103 |
+
|
104 |
+
with st.expander("Summarization", expanded=True):
|
105 |
+
# Summarization
|
106 |
+
out_summ = pipe_summ(text)
|
107 |
+
summarized_text = out_summ[0]['summary_text']
|
108 |
+
st.write(summarized_text)
|
109 |
+
st.write("β
Completed")
|
110 |
|
111 |
+
with st.expander("Keywords Extraction", expanded=True):
|
112 |
+
# Keyword extraction
|
113 |
+
keywords = extract_keywords(text)
|
114 |
+
keyword_list = [keyword[1] for keyword in keywords]
|
115 |
+
st.write(keyword_list)
|
116 |
+
st.write("β
Completed")
|