Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,55 @@
|
|
|
|
1 |
import streamlit as st
|
|
|
|
|
2 |
import spacy
|
3 |
from spacy import displacy
|
4 |
import spacy_streamlit
|
5 |
from spacy_streamlit import visualize_ner
|
6 |
import en_core_web_sm
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
def prediction(raw_text):
|
13 |
-
text1= NER(raw_text)
|
14 |
-
st.write("List wise NERs:")
|
15 |
-
st.write("------------------")
|
16 |
-
st.write(f"{'Text' : <10}{'NER' : >10}")
|
17 |
|
18 |
-
for word in text1.ents:
|
19 |
-
|
20 |
-
print()
|
21 |
-
st.write("------------------")
|
22 |
-
st.write("NERs in the sentence:")
|
23 |
#spacy_streamlit.visualize(displacy.render(text1,style="ent"))
|
24 |
|
25 |
-
models = ["en_core_web_sm"]
|
26 |
-
spacy_streamlit.visualize(text1,models = models)
|
27 |
#visualize_ner(text1, labels=nlp.get_pipe("ner").labels)
|
28 |
|
29 |
-
raw_text = """Ai-Khanoum (/aɪ ˈhɑːnjuːm/, meaning Lady Moon; Uzbek: Oyxonim) is the archaeological site of a Hellenistic city in Takhar Province, Afghanistan.
|
30 |
-
The city, whose original name is unknown,[a] was probably founded by an early ruler of the Seleucid Empire and served as a military and economic centre for the rulers of the Greco-Bactrian Kingdom until its destruction c. 145 BC.
|
31 |
-
Rediscovered in 1961, the ruins of the city were excavated by a French team of archaeologists until the outbreak of conflict in Afghanistan in the late 1970s. """
|
32 |
-
prediction(raw_text)
|
33 |
|
34 |
|
|
|
1 |
+
#Core Packages
|
2 |
import streamlit as st
|
3 |
+
|
4 |
+
#nlp pkgs
|
5 |
import spacy
|
6 |
from spacy import displacy
|
7 |
import spacy_streamlit
|
8 |
from spacy_streamlit import visualize_ner
|
9 |
import en_core_web_sm
|
10 |
|
11 |
+
nlp = spacy.load("en_core_web_sm")
|
12 |
+
|
13 |
+
def main():
|
14 |
+
"""A simple NLP app with spacy-streamlit"""
|
15 |
+
|
16 |
+
spacy_model = "en_core_web_sm"
|
17 |
+
st.title('Entity Extraction')
|
18 |
+
|
19 |
+
menu = ["Home","NER"]
|
20 |
+
choice = st.sidebar.selectbox("Menu", menu)
|
21 |
+
|
22 |
+
if choice == "Home":
|
23 |
+
st.subheader("Tokenization")
|
24 |
+
elif choice == 'NER':
|
25 |
+
st.subheader("Name Entity Recognition")
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
if __name__ == '__main__':
|
30 |
+
main()
|
31 |
+
|
32 |
|
33 |
+
#def prediction(raw_text):
|
34 |
+
#text1= NER(raw_text)
|
35 |
+
#st.write("List wise NERs:")
|
36 |
+
#st.write("------------------")
|
37 |
+
#st.write(f"{'Text' : <10}{'NER' : >10}")
|
38 |
|
39 |
+
#for word in text1.ents:
|
40 |
+
# st.write(word.text,"\t\t",word.label_)
|
41 |
+
#print()
|
42 |
+
#st.write("------------------")
|
43 |
+
#st.write("NERs in the sentence:")
|
44 |
#spacy_streamlit.visualize(displacy.render(text1,style="ent"))
|
45 |
|
46 |
+
#models = ["en_core_web_sm"]
|
47 |
+
#spacy_streamlit.visualize(text1,models = models)
|
48 |
#visualize_ner(text1, labels=nlp.get_pipe("ner").labels)
|
49 |
|
50 |
+
#raw_text = """Ai-Khanoum (/aɪ ˈhɑːnjuːm/, meaning Lady Moon; Uzbek: Oyxonim) is the archaeological site of a Hellenistic city in Takhar Province, Afghanistan.
|
51 |
+
#The city, whose original name is unknown,[a] was probably founded by an early ruler of the Seleucid Empire and served as a military and economic centre for the rulers of the Greco-Bactrian Kingdom until its destruction c. 145 BC.
|
52 |
+
#Rediscovered in 1961, the ruins of the city were excavated by a French team of archaeologists until the outbreak of conflict in Afghanistan in the late 1970s. """
|
53 |
+
#prediction(raw_text)
|
54 |
|
55 |
|