OOlajide commited on
Commit
ae23c23
1 Parent(s): c03cd0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -14
app.py CHANGED
@@ -67,22 +67,52 @@ elif option == 'Text summarization':
67
  summary = summarizer(text, max_length=130, min_length=30)
68
  st.write(summary)
69
 
 
 
 
 
 
 
 
 
 
70
  elif option == 'Text generation':
71
  st.markdown("<h2 style='text-align: center; color:grey;'>Generate text</h2>", unsafe_allow_html=True)
72
- text = st.text_input(label='Enter one line of text and let the NLP model generate the rest for you')
73
- button = st.button('Generate text')
74
- if button:
75
- generator = generation_model()
76
- with st.spinner(text="Generating text..."):
77
- generated_text = generator(text, max_length=50)
78
- st.write(generated_text[0]["generated_text"])
 
 
79
 
 
 
 
 
 
 
 
 
 
80
  elif option == 'Sentiment analysis':
81
  st.markdown("<h2 style='text-align: center; color:grey;'>Classify review</h2>", unsafe_allow_html=True)
82
- text = st.text_input(label='Enter a sentence to get its sentiment analysis')
83
- button = st.button('Get sentiment analysis')
84
- if button:
85
- sentiment_analysis = sentiment_model()
86
- with st.spinner(text="Getting sentiment analysis..."):
87
- sentiment = sentiment_analysis(text)
88
- st.write(sentiment[0]["label"])
 
 
 
 
 
 
 
 
 
 
 
67
  summary = summarizer(text, max_length=130, min_length=30)
68
  st.write(summary)
69
 
70
+ elif source == "I want to upload a file":
71
+ uploaded_file = st.file_uploader("Choose a .txt file to upload", type=["txt"])
72
+ button = st.button('Get summary')
73
+ if button:
74
+ summarizer = summarization_model()
75
+ with st.spinner(text="Summarizing text..."):
76
+ summary = summarizer(text, max_length=130, min_length=30)
77
+ st.write(summary)
78
+
79
  elif option == 'Text generation':
80
  st.markdown("<h2 style='text-align: center; color:grey;'>Generate text</h2>", unsafe_allow_html=True)
81
+ source = st.radio("How would you like to start? Choose an option below", ["I want to input some text", "I want to upload a file"])
82
+ if source == "I want to input some text":
83
+ text = st.text_input(label='Enter one line of text and let the NLP model generate the rest for you')
84
+ button = st.button('Generate text')
85
+ if button:
86
+ generator = generation_model()
87
+ with st.spinner(text="Generating text..."):
88
+ generated_text = generator(text, max_length=50)
89
+ st.write(generated_text[0]["generated_text"])
90
 
91
+ elif source == "I want to upload a file":
92
+ uploaded_file = st.file_uploader("Choose a .txt file to upload", type=["txt"])
93
+ button = st.button('Generate text')
94
+ if button:
95
+ generator = generation_model()
96
+ with st.spinner(text="Generating text..."):
97
+ generated_text = generator(text, max_length=50)
98
+ st.write(generated_text[0]["generated_text"])
99
+
100
  elif option == 'Sentiment analysis':
101
  st.markdown("<h2 style='text-align: center; color:grey;'>Classify review</h2>", unsafe_allow_html=True)
102
+ source = st.radio("How would you like to start? Choose an option below", ["I want to input some text", "I want to upload a file"])
103
+ if source == "I want to input some text":
104
+ text = st.text_input(label='Enter a sentence to get its sentiment analysis')
105
+ button = st.button('Get sentiment analysis')
106
+ if button:
107
+ sentiment_analysis = sentiment_model()
108
+ with st.spinner(text="Getting sentiment analysis..."):
109
+ sentiment = sentiment_analysis(text)
110
+ st.write(sentiment[0]["label"])
111
+ elif source == "I want to upload a file":
112
+ uploaded_file = st.file_uploader("Choose a .txt file to upload", type=["txt"])
113
+ button = st.button('Get sentiment analysis')
114
+ if button:
115
+ sentiment_analysis = sentiment_model()
116
+ with st.spinner(text="Getting sentiment analysis..."):
117
+ sentiment = sentiment_analysis(text)
118
+ st.write(sentiment[0]["label"])