File size: 990 Bytes
33d405d
 
 
 
 
 
 
 
 
 
 
efd7314
33d405d
efd7314
 
 
 
 
 
 
33d405d
 
 
 
 
 
 
efd7314
 
33d405d
efd7314
 
33d405d
 
 
 
efd7314
 
33d405d
efd7314
 
 
 
 
33d405d
 
 
 
 
efd7314
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
tags:
- flair
- token-classification
- sequence-tagger-model
language: en
datasets:
- conll2003
inference: false
---

## English NER in Flair (default model)

This is the standard 4-class NER model for English that ships with Flair.

Classes: 
PER (person name)
LOC (location name)
ORG (organization name)
MISC (other names)

### Demo: How to use in Flair

```python
from flair.data import Sentence
from flair.models import SequenceTagger

# load tagger
tagger = SequenceTagger.load("flair/ner-english")

# make example sentence
sentence = Sentence("George Washington went to Washington")

# predict NER tags
tagger.predict(sentence)

# print sentence
print(sentence)

# print predicted NER spans
print('The following NER tags are found:')
# iterate over entities and print
for entity in sentence.get_spans('ner'):
    print(entity)

```

yields the following output:

> `Span [1,2]: "George Washington"   [− Labels: PER (0.9968)]
Span [5]: "Washington"   [− Labels: LOC (0.9994)]`