📅  最后修改于: 2022-03-11 14:47:22.150000             🧑  作者: Mango
>>> 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())
...