Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st # web app
|
| 2 |
+
import spacy # named entity recognition
|
| 3 |
+
|
| 4 |
+
st.title("News Bias Words Recognizer")
|
| 5 |
+
|
| 6 |
+
# wait until the modl loads with a simple spinner - progress bar
|
| 7 |
+
with st.spinner("Please wait while the model is eing loaded...."):
|
| 8 |
+
nlp = spacy.load("en_pipeline")
|
| 9 |
+
|
| 10 |
+
## text box to get user input
|
| 11 |
+
|
| 12 |
+
input = st.text_area(label = "Enter your text to get biased words recognized .......")
|
| 13 |
+
|
| 14 |
+
# create a doc object
|
| 15 |
+
doc = nlp(input)
|
| 16 |
+
|
| 17 |
+
# visualize the output
|
| 18 |
+
|
| 19 |
+
output_html = spacy.displacy.render(doc, style="ent", jupyter=False, options={"colors":{'bias':"#ff5136"}})
|
| 20 |
+
|
| 21 |
+
st.markdown(output_html, unsafe_allow_html=True)
|