Amrrs commited on
Commit
74bb5a2
1 Parent(s): 7bcd6c3

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st # web app
2
+ import spacy # named entity recognition
3
+
4
+ # title
5
+
6
+ st.title("News Bias Words Recognizer")
7
+
8
+ # wait until the model loads with a simple spinner - progress bar
9
+
10
+ with st.spinner("Please wait while the model is being loaded...."):
11
+ nlp = spacy.load("en_pipeline")
12
+
13
+ # text box to get user input
14
+
15
+ input = st.text_area(label = "Enter your text to get biased words recognized.....")
16
+
17
+ # create a doc object with named entities
18
+
19
+ doc = nlp(input)
20
+
21
+ # get the html / markdown code for displaying the output
22
+
23
+ output_html = spacy.displacy.render(doc, style='ent', jupyter=False, options = {"colors": {'bias':'#ff5a36'} })
24
+
25
+ # render the html code as a markdown with html rendering enabled
26
+
27
+ st.markdown(output_html, unsafe_allow_html=True)