OOlajide commited on
Commit
25a1096
1 Parent(s): ae23c23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -35
app.py CHANGED
@@ -78,41 +78,20 @@ elif option == 'Text summarization':
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"])
 
78
 
79
  elif option == 'Text generation':
80
  st.markdown("<h2 style='text-align: center; color:grey;'>Generate text</h2>", unsafe_allow_html=True)
81
+ text = st.text_input(label='Enter one line of text and let the NLP model generate the rest for you')
82
+ button = st.button('Generate text')
83
+ if button:
84
+ generator = generation_model()
85
+ with st.spinner(text="Generating text..."):
86
+ generated_text = generator(text, max_length=50)
87
+ st.write(generated_text[0]["generated_text"])
 
 
 
 
 
 
 
 
 
 
 
88
 
89
  elif option == 'Sentiment analysis':
90
  st.markdown("<h2 style='text-align: center; color:grey;'>Classify review</h2>", unsafe_allow_html=True)
91
+ text = st.text_input(label='Enter a sentence to get its sentiment analysis')
92
+ button = st.button('Get sentiment analysis')
93
+ if button:
94
+ sentiment_analysis = sentiment_model()
95
+ with st.spinner(text="Getting sentiment analysis..."):
96
+ sentiment = sentiment_analysis(text)
97
+ st.write(sentiment[0]["label"])