alanakbik commited on
Commit
efd7314
1 Parent(s): 8c51e31

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -10
README.md CHANGED
@@ -9,9 +9,15 @@ datasets:
9
  inference: false
10
  ---
11
 
12
- ## Flair NER model `en-ner-conll03-v0.4.pt`
13
 
14
- Imported from https://nlp.informatik.hu-berlin.de/resources/models/ner/
 
 
 
 
 
 
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
- sentence = Sentence(
23
- "My name is Julien, I currently live in Paris, I work at Hugging Face, Inc."
24
- )
25
-
26
- tagger = SequenceTagger.load("julien-c/flair-ner")
27
 
 
 
28
 
29
  # predict NER tags
30
  tagger.predict(sentence)
31
 
32
- # print sentence with predicted tags
33
- print(sentence.to_tagged_string())
34
 
 
 
 
 
 
35
 
36
  ```
37
 
38
  yields the following output:
39
 
40
- > `My name is Julien <S-PER> , I currently live in Paris <S-LOC> , I work at Hugging <B-LOC> Face <E-LOC> .`
 
 
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)]`