ner-english / README.md
alanakbik's picture
Update README.md
efd7314
|
raw
history blame
990 Bytes
metadata
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

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)]