📜  使用 nltk 提取名称组织 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:22.150000             🧑  作者: Mango

代码示例1
>>> import nltk
>>> def extract_entities(text):
...     for sent in nltk.sent_tokenize(text):
...         for chunk in nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(sent))):
...             if hasattr(chunk, 'node'):
...                 print chunk.node, ' '.join(c[0] for c in chunk.leaves())
...