2017-01-09 92 views
0

我正在尝试使用斯坦福NER提取百分比。但它不能正确提取百分比。斯坦福NER未正确提取百分比

inp_str = 'total revenue received was one hundred and twenty five percent 125% for last financial year' 
split_inp_str = inp_str.split() 
st = StanfordNERTagger('english.muc.7class.distsim.crf.ser.gz') 
print(st.tag(split_inp_str)) 

这让下面的输出

[('total', 'O'), ('revenue', 'O'), ('received', 'O'), ('was', 'O'), ('one', 'O'), ('hundred', 'O'), ('and', 'O'), ('twenty', 'O'), ('five', 'PERCENT'), ('percent', 'PERCENT'), ('125%', 'O'), ('for', 'O'), ('last', 'O'), ('financial', 'O'), ('year', 'O')] 

为什么不提取125%125%的

+0

当我使用Stanford CoreNLP 3.7.0时,“PERCENT”为“125%125%”。我正在运行Java代码。如果您使用NLTK,我不完全确定正在运行的是什么。 – StanfordNLPHelp

回答

-1

您需要标记句子而不是split()。尝试下面的代码。

from nltk import word_tokenize 

inp_str = 'total revenue received was one hundred and twenty five percent 125% for last financial year' 
split_inp_str = word_tokenize(inp_str) 
st = StanfordNERTagger('english.muc.7class.distsim.crf.ser.gz') 
print(st.tag(split_inp_str))