peterciank commited on
Commit
44f1a7e
Β·
verified Β·
1 Parent(s): 92000af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -25
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 = ['Option 1', 'Option 2']
13
 
14
  # Create a dropdown menu to select options
15
- selected_option = st.selectbox("Select an option", options)
16
 
17
  # Define URLs for different options
18
- url_option1 = "https://raw.githubusercontent.com/peteciank/public_files/main/jd_sm.txt"
19
- url_option2 = "https://raw.githubusercontent.com/peteciank/public_files/main/jd_controller.txt"
 
 
 
 
20
 
21
  # Function to fetch text content based on selected option
22
  def fetch_text_content(selected_option):
23
- if selected_option == 'Option 1':
24
  return requests.get(url_option1).text
25
- elif selected_option == 'Option 2':
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
- # Summarization
91
- st.write("Summarization")
92
- out_summ = pipe_summ(text)
93
- summarized_text = out_summ[0]['summary_text']
94
- st.write(summarized_text)
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
- # Keyword extraction
97
- st.write("Keywords")
98
- keywords = extract_keywords(text)
99
- keyword_list = [keyword[1] for keyword in keywords]
100
- st.write(keyword_list)
 
 
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")