Spaces:
Sleeping
Sleeping
Delete flair_test.py
Browse files- flair_test.py +0 -27
flair_test.py
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
# Import generic wrappers
|
2 |
-
from transformers import AutoModel, AutoTokenizer
|
3 |
-
|
4 |
-
|
5 |
-
if __name__ == "__main__":
|
6 |
-
|
7 |
-
from flair.data import Sentence
|
8 |
-
from flair.models import SequenceTagger
|
9 |
-
|
10 |
-
# load tagger
|
11 |
-
tagger = SequenceTagger.load("flair/ner-english-large")
|
12 |
-
|
13 |
-
# make example sentence
|
14 |
-
sentence = Sentence("George Washington went to Washington")
|
15 |
-
|
16 |
-
# predict NER tags
|
17 |
-
tagger.predict(sentence)
|
18 |
-
|
19 |
-
# print sentence
|
20 |
-
print(sentence)
|
21 |
-
|
22 |
-
# print predicted NER spans
|
23 |
-
print('The following NER tags are found:')
|
24 |
-
# iterate over entities and print
|
25 |
-
for entity in sentence.get_spans('ner'):
|
26 |
-
print(entity)
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|