I am currently learning named-entity recognition using NLTK. Here is my code:
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)
and it's giving me an error:
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
I have tried other example of NLTK, whenever it has a ne_chunk it gives an error too. Can you please help me? I am using Ubuntu 18.04, and python 3.7.1
You need to download the below packages: The named entity chunker will give you a tree containing both chunks and tags.
# 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)))