File size: 680 Bytes
d4ce213
 
 
 
377658d
d4ce213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import spacy
import streamlit as st

# Load your trained SpaCy NER model
nlp = spacy.load('my_ner')

# Define a function to perform NER on user input
def predict_ner(text):
    doc = nlp(text)
    ents = [(ent.text, ent.label_) for ent in doc.ents]
    return ents

# Create the Streamlit app
def main():
    st.title("SpaCy NER Demo")
    
    # Add a text input for users to input their text
    text = st.text_input("Enter some text:")
    
    # If the user has entered some text, show the NER predictions
    if text:
        st.write("Predictions:")
        ents = predict_ner(text)
        for ent in ents:
            st.write(ent)

if __name__ == '__main__':
    main()