File size: 3,103 Bytes
057c911
324bed5
057c911
 
a988da7
 
cfcad6a
0d3e54e
a988da7
 
e67326c
057c911
 
 
 
 
 
 
 
a6f9f12
36b9547
 
0326f56
84ff5f7
 
 
1a4c320
45ebe9f
d9b477f
057c911
 
d9b477f
 
 
 
 
057c911
 
8f16ea0
 
7de1fae
2532b89
057c911
 
 
 
 
 
a988da7
057c911
 
 
 
 
b935e2b
057c911
 
 
 
 
f4e047c
b7772c5
057c911
 
4d53264
4e870ab
057c911
 
 
 
7b97c56
a988da7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#Core Packages
import streamlit as st 

#nlp pkgs
import spacy
from spacy import displacy
import spacy_streamlit
from spacy_streamlit import visualize_ner
import en_core_web_sm

nlp = spacy.load("en_core_web_sm")

def main():
    """A simple NLP app with spacy-streamlit"""
    
    spacy_model = "en_core_web_sm"
    st.title('Entity Extraction')

    menu = ["Home","NER"]
    choice = st.sidebar.selectbox("Menu", menu)
    with st.sidebar:
        st.write("Sample Text")
        st.write("""Ai-Khanoum (/aɪ ˈhɑːnjuːm/, meaning Lady Moon; Uzbek: Oyxonim) is the archaeological site of a Hellenistic city in Takhar Province, Afghanistan. 
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. 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. """)
        st.write("""The Indian Space Research Organisation or is the national space agency of India, headquartered in Bengaluru.
        It operates under Department of Space which is directly overseen by the Prime Minister of India while Chairman of ISRO acts as executive of DOS as well.""")
    
    if choice == "Home":
        st.subheader("Tokenization")
        raw_text = st.text_area("Your Text","Enter the Text Here")
        docx = nlp(raw_text)
        if st.button("Tokenize"):
            spacy_streamlit.visualize_tokens(docx,attrs = ['text','pos_','dep_','ent_type_'])

    elif choice == 'NER':
        st.subheader("Name Entity Recognition")
        raw_text = st.text_area("Your Text","Enter the Text Here")
        docx = nlp(raw_text)
        spacy_streamlit.visualize_ner(docx,labels = nlp.get_pipe('ner').labels,show_table = False)
        #displacy.render(docx,style="ent")



if __name__ == '__main__':
    main()


#def prediction(raw_text):
  #text1= NER(raw_text)
  #st.write("List wise NERs:")
  #st.write("------------------")
  #st.write(f"{'Text' : <10}{'NER' : >10}")
  
  #for word in text1.ents:
   # st.write(word.text,"\t\t",word.label_)
  #print()
  #st.write("------------------")
  #st.write("NERs in the sentence:")
  #spacy_streamlit.visualize(displacy.render(text1,style="ent"))
   
  #models = ["en_core_web_sm"]
  #spacy_streamlit.visualize(text1,models = models)
  #visualize_ner(text1, labels=nlp.get_pipe("ner").labels)

#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. 
#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. 
#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. """
#prediction(raw_text)