varun500 commited on
Commit
d4ce213
·
1 Parent(s): f9e88d8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import spacy
2
+ import streamlit as st
3
+
4
+ # Load your trained SpaCy NER model
5
+ nlp = spacy.load('your_model_name')
6
+
7
+ # Define a function to perform NER on user input
8
+ def predict_ner(text):
9
+ doc = nlp(text)
10
+ ents = [(ent.text, ent.label_) for ent in doc.ents]
11
+ return ents
12
+
13
+ # Create the Streamlit app
14
+ def main():
15
+ st.title("SpaCy NER Demo")
16
+
17
+ # Add a text input for users to input their text
18
+ text = st.text_input("Enter some text:")
19
+
20
+ # If the user has entered some text, show the NER predictions
21
+ if text:
22
+ st.write("Predictions:")
23
+ ents = predict_ner(text)
24
+ for ent in ents:
25
+ st.write(ent)
26
+
27
+ if __name__ == '__main__':
28
+ main()
29
+