Spaces:
Runtime error
Runtime error
Buckeyes2019
commited on
Commit
•
2e6f5d4
1
Parent(s):
672ef3c
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
import streamlit as st
|
2 |
-
import torch
|
3 |
from transformers import pipeline
|
4 |
import spacy
|
5 |
from spacy import displacy
|
6 |
import plotly.express as px
|
7 |
import numpy as np
|
8 |
|
9 |
-
st.set_page_config(page_title="
|
10 |
|
11 |
st.title("Natural Language Processing Prototype")
|
12 |
-
st.write("_This web application is intended for educational use, please do not upload any
|
13 |
st.subheader("__Which natural language processing task would you like to try?__")
|
14 |
st.write("- __Sentiment Analysis:__ Identifying whether a piece of text has a positive or negative sentiment.")
|
15 |
st.write("- __Named Entity Recognition:__ Identifying all geopolitical entities, organizations, people, locations, or dates in a body of text.")
|
@@ -67,7 +66,6 @@ with st.spinner(text="Please wait for the models to load. This should take appro
|
|
67 |
if option == 'Text Classification':
|
68 |
cat1 = st.text_input('Enter each possible category name (separated by a comma). Maximum 5 categories.')
|
69 |
text = st.text_area('Enter Text Below:', height=200)
|
70 |
-
#uploaded_file = st.file_uploader("Choose a file", type=['txt'])
|
71 |
submit = st.button('Generate')
|
72 |
if submit:
|
73 |
st.subheader("Classification Results:")
|
@@ -82,18 +80,16 @@ if option == 'Text Summarization':
|
|
82 |
max_lengthy = st.slider('Maximum summary length (words)', min_value=30, max_value=150, value=60, step=10)
|
83 |
num_beamer = st.slider('Speed vs quality of summary (1 is fastest)', min_value=1, max_value=8, value=4, step=1)
|
84 |
text = st.text_area('Enter Text Below (maximum 800 words):', height=300)
|
85 |
-
#uploaded_file = st.file_uploader("Choose a file", type=['txt'])
|
86 |
submit = st.button('Generate')
|
87 |
if submit:
|
88 |
st.subheader("Summary:")
|
89 |
with st.spinner(text="This may take a moment..."):
|
90 |
summWords = sum2(text, max_length=max_lengthy, min_length=15, num_beams=num_beamer, do_sample=True, early_stopping=True, repetition_penalty=1.5, length_penalty=1.5)
|
91 |
-
text2 =summWords[0]["summary_text"]
|
92 |
st.write(text2)
|
93 |
|
94 |
if option == 'Sentiment Analysis':
|
95 |
text = st.text_area('Enter Text Below:', height=200)
|
96 |
-
#uploaded_file = st.file_uploader("Choose a file", type=['txt'])
|
97 |
submit = st.button('Generate')
|
98 |
if submit:
|
99 |
st.subheader("Sentiment:")
|
@@ -104,7 +100,6 @@ if option == 'Sentiment Analysis':
|
|
104 |
|
105 |
if option == 'Named Entity Recognition':
|
106 |
text = st.text_area('Enter Text Below:', height=300)
|
107 |
-
#uploaded_file = st.file_uploader("Choose a file", type=['txt'])
|
108 |
submit = st.button('Generate')
|
109 |
if submit:
|
110 |
entities = []
|
|
|
1 |
import streamlit as st
|
|
|
2 |
from transformers import pipeline
|
3 |
import spacy
|
4 |
from spacy import displacy
|
5 |
import plotly.express as px
|
6 |
import numpy as np
|
7 |
|
8 |
+
st.set_page_config(page_title="NLP Prototype")
|
9 |
|
10 |
st.title("Natural Language Processing Prototype")
|
11 |
+
st.write("_This web application is intended for educational use, please do not upload any sensitive information._")
|
12 |
st.subheader("__Which natural language processing task would you like to try?__")
|
13 |
st.write("- __Sentiment Analysis:__ Identifying whether a piece of text has a positive or negative sentiment.")
|
14 |
st.write("- __Named Entity Recognition:__ Identifying all geopolitical entities, organizations, people, locations, or dates in a body of text.")
|
|
|
66 |
if option == 'Text Classification':
|
67 |
cat1 = st.text_input('Enter each possible category name (separated by a comma). Maximum 5 categories.')
|
68 |
text = st.text_area('Enter Text Below:', height=200)
|
|
|
69 |
submit = st.button('Generate')
|
70 |
if submit:
|
71 |
st.subheader("Classification Results:")
|
|
|
80 |
max_lengthy = st.slider('Maximum summary length (words)', min_value=30, max_value=150, value=60, step=10)
|
81 |
num_beamer = st.slider('Speed vs quality of summary (1 is fastest)', min_value=1, max_value=8, value=4, step=1)
|
82 |
text = st.text_area('Enter Text Below (maximum 800 words):', height=300)
|
|
|
83 |
submit = st.button('Generate')
|
84 |
if submit:
|
85 |
st.subheader("Summary:")
|
86 |
with st.spinner(text="This may take a moment..."):
|
87 |
summWords = sum2(text, max_length=max_lengthy, min_length=15, num_beams=num_beamer, do_sample=True, early_stopping=True, repetition_penalty=1.5, length_penalty=1.5)
|
88 |
+
text2 =summWords[0]["summary_text"]
|
89 |
st.write(text2)
|
90 |
|
91 |
if option == 'Sentiment Analysis':
|
92 |
text = st.text_area('Enter Text Below:', height=200)
|
|
|
93 |
submit = st.button('Generate')
|
94 |
if submit:
|
95 |
st.subheader("Sentiment:")
|
|
|
100 |
|
101 |
if option == 'Named Entity Recognition':
|
102 |
text = st.text_area('Enter Text Below:', height=300)
|
|
|
103 |
submit = st.button('Generate')
|
104 |
if submit:
|
105 |
entities = []
|