Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,22 +8,20 @@ st.write(
|
|
| 8 |
"I am passionate about finding ways to leverage ML."
|
| 9 |
)
|
| 10 |
|
| 11 |
-
|
| 12 |
form = st.form(key='sentiment-form')
|
| 13 |
user_input = form.text_area('Enter your text')
|
| 14 |
submit = form.form_submit_button('Submit')
|
| 15 |
|
| 16 |
if submit:
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
if label == 'POSITIVE':
|
| 23 |
-
st.success(f'{label} sentiment (score: {score})')
|
| 24 |
-
else:
|
| 25 |
-
st.error(f'{label} sentiment (score: {score})')
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
x = st.slider('Select a value')
|
| 29 |
st.write(x, 'squared is', x * x)
|
|
|
|
| 8 |
"I am passionate about finding ways to leverage ML."
|
| 9 |
)
|
| 10 |
|
|
|
|
| 11 |
form = st.form(key='sentiment-form')
|
| 12 |
user_input = form.text_area('Enter your text')
|
| 13 |
submit = form.form_submit_button('Submit')
|
| 14 |
|
| 15 |
if submit:
|
| 16 |
+
classifier = pipeline("sentiment-analysis")
|
| 17 |
+
result = classifier(user_input)[0]
|
| 18 |
+
label = result['label']
|
| 19 |
+
score = result['score']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
if label == 'POSITIVE':
|
| 22 |
+
st.success(f'{label} sentiment (score: {score})')
|
| 23 |
+
else:
|
| 24 |
+
st.error(f'{label} sentiment (score: {score})')
|
| 25 |
|
| 26 |
x = st.slider('Select a value')
|
| 27 |
st.write(x, 'squared is', x * x)
|