我使用NLTK的ne_chunk
从文本中提取命名实体:
my_sent = "WASHINGTON -- In the wake of a string of abuses by New York police officers in the 1990s, Loretta E. Lynch, the top federal prosecutor in Brooklyn, spoke forcefully about the pain of a broken trust that African-Americans felt and said the responsibility for repairing generations of miscommunication and mistrust fell to law enforcement."
nltk.ne_chunk(my_sent, binary=True)
但是我不知道如何将这些实体保存到列表中?例如:
print Entity_list
('WASHINGTON', 'New York', 'Loretta', 'Brooklyn', 'African')
谢谢。
ne_chunk()
返回什么?你到底卡在哪里了? - lenznltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize("欢迎来到巴巴多斯,Tobdy!")))
这样的事情。 - Alex Riina