Update README.md
Browse files
README.md
CHANGED
@@ -9,9 +9,15 @@ datasets:
|
|
9 |
inference: false
|
10 |
---
|
11 |
|
12 |
-
##
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
### Demo: How to use in Flair
|
17 |
|
@@ -19,22 +25,27 @@ Imported from https://nlp.informatik.hu-berlin.de/resources/models/ner/
|
|
19 |
from flair.data import Sentence
|
20 |
from flair.models import SequenceTagger
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
)
|
25 |
-
|
26 |
-
tagger = SequenceTagger.load("julien-c/flair-ner")
|
27 |
|
|
|
|
|
28 |
|
29 |
# predict NER tags
|
30 |
tagger.predict(sentence)
|
31 |
|
32 |
-
# print sentence
|
33 |
-
print(sentence
|
34 |
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
```
|
37 |
|
38 |
yields the following output:
|
39 |
|
40 |
-
> `
|
|
|
|
9 |
inference: false
|
10 |
---
|
11 |
|
12 |
+
## English NER in Flair (default model)
|
13 |
|
14 |
+
This is the standard 4-class NER model for English that ships with Flair.
|
15 |
+
|
16 |
+
Classes:
|
17 |
+
PER (person name)
|
18 |
+
LOC (location name)
|
19 |
+
ORG (organization name)
|
20 |
+
MISC (other names)
|
21 |
|
22 |
### Demo: How to use in Flair
|
23 |
|
|
|
25 |
from flair.data import Sentence
|
26 |
from flair.models import SequenceTagger
|
27 |
|
28 |
+
# load tagger
|
29 |
+
tagger = SequenceTagger.load("flair/ner-english")
|
|
|
|
|
|
|
30 |
|
31 |
+
# make example sentence
|
32 |
+
sentence = Sentence("George Washington went to Washington")
|
33 |
|
34 |
# predict NER tags
|
35 |
tagger.predict(sentence)
|
36 |
|
37 |
+
# print sentence
|
38 |
+
print(sentence)
|
39 |
|
40 |
+
# print predicted NER spans
|
41 |
+
print('The following NER tags are found:')
|
42 |
+
# iterate over entities and print
|
43 |
+
for entity in sentence.get_spans('ner'):
|
44 |
+
print(entity)
|
45 |
|
46 |
```
|
47 |
|
48 |
yields the following output:
|
49 |
|
50 |
+
> `Span [1,2]: "George Washington" [− Labels: PER (0.9968)]
|
51 |
+
Span [5]: "Washington" [− Labels: LOC (0.9994)]`
|