NameError: name 'ne_chunk' is not defined
NameError: name 'ne_chunk' is not defined
我目前正在使用 NLTK 学习命名实体识别。这是我的代码:
from nltk.chunk import conlltags2tree, tree2conlltags
from pprint import pprint
iob_tagged = tree2conlltags(cs)
pprint(iob_tagged)
ne_tree = ne_chunk(pos_tag(word_tokenize(ex)))
print(ne_tree)
它给我一个错误:
NameError Traceback (most recent call last)
in
----> 1 ne_tree = ne_chunk(pos_tag(word_tokenize(ex)))
2 print(ne_tree)
NameError: name 'ne_chunk' is not defined
我已经尝试过 NLTK 的其他示例,只要它有 ne_chunk 它也会给出错误。你能帮我么?我正在使用 Ubuntu 18.04 和 python 3.7.1
您需要下载以下软件包:
命名实体分块器将为您提供包含块和标签的树。
# nltk for NER-tagging
import nltk
from nltk.corpus import conll2000
from nltk.chunk import conlltags2tree, tree2conlltags
from nltk.chunk import ne_chunk
from nltk import pos_tag
sentence = "Clement and Mathieu are working at Apple."
ne_tree = ne_chunk(pos_tag(word_tokenize(sentence)))
它对我有用,谢谢@thrinadh
import nltk
from nltk.corpus import conll2000
from nltk.chunk import conlltags2tree, tree2conlltags
from nltk.chunk import ne_chunk
from nltk import pos_tag
sentence = "Clement and Mathieu are working at Apple."
ne_tree = ne_chunk(pos_tag(word_tokenize(sentence)))
我目前正在使用 NLTK 学习命名实体识别。这是我的代码:
from nltk.chunk import conlltags2tree, tree2conlltags
from pprint import pprint
iob_tagged = tree2conlltags(cs)
pprint(iob_tagged)
ne_tree = ne_chunk(pos_tag(word_tokenize(ex)))
print(ne_tree)
它给我一个错误:
NameError Traceback (most recent call last) in ----> 1 ne_tree = ne_chunk(pos_tag(word_tokenize(ex))) 2 print(ne_tree)
NameError: name 'ne_chunk' is not defined
我已经尝试过 NLTK 的其他示例,只要它有 ne_chunk 它也会给出错误。你能帮我么?我正在使用 Ubuntu 18.04 和 python 3.7.1
您需要下载以下软件包: 命名实体分块器将为您提供包含块和标签的树。
# nltk for NER-tagging
import nltk
from nltk.corpus import conll2000
from nltk.chunk import conlltags2tree, tree2conlltags
from nltk.chunk import ne_chunk
from nltk import pos_tag
sentence = "Clement and Mathieu are working at Apple."
ne_tree = ne_chunk(pos_tag(word_tokenize(sentence)))
它对我有用,谢谢@thrinadh
import nltk
from nltk.corpus import conll2000
from nltk.chunk import conlltags2tree, tree2conlltags
from nltk.chunk import ne_chunk
from nltk import pos_tag
sentence = "Clement and Mathieu are working at Apple."
ne_tree = ne_chunk(pos_tag(word_tokenize(sentence)))