SalmanML commited on
Commit
854ac8d
1 Parent(s): 0917dd0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flair.data import Sentence
2
+ from flair.models import SequenceTagger
3
+ import streamlit as st
4
+
5
+ # load tagger
6
+ tagger = SequenceTagger.load("flair/ner-english-large")
7
+
8
+ # make example sentence
9
+ text=st.text_area("Enter the text to detect it's named entities")
10
+ sentence = Sentence(text)
11
+
12
+ # predict NER tags
13
+ tagger.predict(sentence)
14
+
15
+ # print sentence
16
+ print(sentence)
17
+
18
+ # print predicted NER spans
19
+ print('The following NER tags are found:')
20
+ # iterate over entities and printx
21
+ for entity in sentence.get_spans('ner'):
22
+ print(entity)