polyglot
polyglot copied to clipboard
Inconsistency when repeatedly doing NER for the same sentence
Operating system: CentOS 7.8 (64-bit Linux) Python version: Python 3.8.5 (default, Sep 4 2020, 07:30:14) Polyglot version: polyglot-16.7.4
This is the code that I am running, basically, I am doing NER for the sentence "パウロ・フレイレはマルクス主義者?" ten times
from polyglot.text import Text
def ner_poly(sent, code):
poly_text = Text(sent, hint_language_code=code)
return poly_text.entities, poly_text.words
for i in range(10):
print(ner_poly("パウロ・フレイレはマルクス主義者?", 'ja'))
The result is the following:
([I-PER(['パウロ', '・', 'フレイレ'])], WordList(['パウロ', '・', 'フレイレ', 'は', 'マルクス主義', '者', '?']))
([I-PER(['パウロ', '・', 'フレイ'])], WordList(['パウロ', '・', 'フレイ', 'レ', 'は', 'マルクス主義', '者', '?']))
([I-PER(['パウロ', '・', 'フレイ'])], WordList(['パウロ', '・', 'フレイ', 'レ', 'は', 'マルクス主義', '者', '?']))
([I-PER(['パウロ', '・', 'フレイ'])], WordList(['パウロ', '・', 'フレイ', 'レ', 'は', 'マルクス主義', '者', '?']))
([I-PER(['パウロ', '・', 'フレイ'])], WordList(['パウロ', '・', 'フレイ', 'レ', 'は', 'マルクス主義', '者', '?']))
([I-PER(['パウロ', '・', 'フレイ'])], WordList(['パウロ', '・', 'フレイ', 'レ', 'は', 'マルクス主義', '者', '?']))
([I-PER(['パウロ', '・', 'フレイ'])], WordList(['パウロ', '・', 'フレイ', 'レ', 'は', 'マルクス主義', '者', '?']))
([I-PER(['パウロ', '・', 'フレイ'])], WordList(['パウロ', '・', 'フレイ', 'レ', 'は', 'マルクス主義', '者', '?']))
([I-PER(['パウロ', '・', 'フレイ'])], WordList(['パウロ', '・', 'フレイ', 'レ', 'は', 'マルクス主義', '者', '?']))
([I-PER(['パウロ', '・', 'フレイ'])], WordList(['パウロ', '・', 'フレイ', 'レ', 'は', 'マルクス主義', '者', '?']))
Only the first time result is correct, i.e., it should be [I-PER(['パウロ', '・', 'フレイレ'])] rather than [I-PER(['パウロ', '・', 'フレイ'])], i.e., the entity should be パウロ・フレイレ, rather than パウロ・フレイ.