'Why FLAIR does't recognize the entire location name of simple sentence?

I'm tying to to detect simple location with NER algorithm, and I'm getting semi-correct results:

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

tagger   = SequenceTagger.load('ner')
text     = 'Jackson leaves at north Carolina'
sentence = Sentence(text)

tagger.predict(sentence)
for entity in sentence.get_spans('ner'):
    print(entity)

Output:

Span [1]: "Jackson"   [− Labels: PER (0.9996)]
Span [5]: "Carolina"   [− Labels: LOC (0.7363)]

I was expecting to receive "north Carolina".

  1. Can FLAIR detect full location description? What do we need for it?
  2. Is there any NER algorithm that cat detect full location description?


Solution 1:[1]

FLAIR CAN detect full location description. The reason for your issue is that the 'north' is not capitalized.

If you run

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

tagger   = SequenceTagger.load('ner')
text     = 'Jackson leaves at North Carolina'
sentence = Sentence(text)

tagger.predict(sentence)
for entity in sentence.get_spans('ner'):
    print(entity)

You'll get

Span[0:1]: "Jackson" ? PER (0.9997)
Span[3:5]: "North Carolina" ? LOC (0.9246)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Chao