如何使用 NLTK 包在文本中获取有关 population/Country 的信息

How to get information regarding population/Country in the text using NLTK package

我有文本,其中包含有关人口的信息,country.I 想获得人口和国家/地区的 NER。

我的正文如下:

text_sent = japan.using 一项美国国立卫生研究院标准淋巴细胞毒性试验中的动脉闭塞性疾病抗原,一种可能的日本特异性抗原,在 48 名血栓闭塞性脉管炎患者中的 17 名患者中鉴定出 bjw 22.2(35.4 / %),在 15 名高安氏动脉炎患者中有 5 名 (33.3%),在 113 名正常对照者中有 11 名 (9.7%)。

我试过用这个

从 nltk 导入 word_tokenize, pos_tag, ne_chunk ne_chunk(pos_tag(word_tokenize(text_sent )))

我得到了标签,但没有得到任何 GPE 标签词

(小号 antigens/NNS in/IN arterial/JJ occlusive/JJ diseases/NNS in/IN 日本.using/VBG a/DT nih/JJ standard/JJ lymphocytotoxicity/NN test/NN ,/, a/DT possible/JJ japanese/JJ specific/JJ antigen/NN ,/, bjw/JJ 22.2/光盘 was/VBD identified/VBN in/IN 17张/光盘 out/IN of/IN 48张/光盘 patients/NNS with/IN thromboangiitis/NN obliterans/NNS (/( 35.4/光盘 per/IN cent/NN )/) ,/, in/IN 5张/光盘 out/IN of/IN 15张/光盘 patients/NNS with/IN takayasu/NN 's/POS arteritis/NN (/( 33.3/光盘 per/IN cent/NN )/) and/CC in/IN 11张/光盘 out/IN of/IN 113张/光盘 normal/JJ controls/NNS (/( 9.7/光盘 per/IN cent/NN )/) ./.)

你没有得到 GPE 标记,因为 "japan.using" 不是地理位置名称,应该是日本使用

我已经使用经过训练的 spacy 模型进行了尝试

import spacy 
nlp = spacy.load("en_core_web_sm")

doc = nlp(u"antigens in arterial occlusive diseases in japan.using a nih standard lymphocytotoxicity test, a possible japanese specific antigen, bjw 22.2 was identified in 17 out of 48 patients with thromboangiitis obliterans (35.4 per cent), in 5 out of 15 patients with takayasu's arteritis (33.3 per cent) and in 11 out of 113 normal controls (9.7 per cent).")

for ent in doc.ents:
print(ent.text, ent.start_char, ent.end_char, ent.label_)

#o/p
japanese 106 114 NORP
22.2 137 141 CARDINAL
17 160 162 CARDINAL
48 170 172 CARDINAL
35.4 per cent 215 228 MONEY
5 234 235 CARDINAL
15 243 245 CARDINAL
33.3 per cent 282 295 MONEY
11 304 306 CARDINAL
113 314 317 CARDINAL
9.7 per cent 335 347 MONEY

但是当您将 'japan.using' 修改为 'Japan. using' 时,您将获得 GPE 标签

Japan 43 48 GPE
japanese 107 115 NORP
22.2 138 142 CARDINAL
17 161 163 CARDINAL
48 171 173 CARDINAL
35.4 per cent 216 229 MONEY
5 235 236 CARDINAL
15 244 246 CARDINAL
33.3 per cent 283 296 MONEY
11 305 307 CARDINAL
113 315 318 CARDINAL
9.7 per cent 336 348 MONEY