Are you committed to using NLTK/Python? I ran into the same problems as you, and had much better results using Stanford's named-entity recognizer: http://nlp.stanford.edu/software/CRF-NER.shtml. The process for training the classifier using your own data is very well-documented in the FAQ.

If you really need to use NLTK, I'd hit up the mailing list for some advice from other users: http://groups.google.com/group/nltk-users.

Hope this helps!

Answer from jjdubs on Stack Overflow
🌐
Python Programming
pythonprogramming.net β€Ί named-entity-recognition-nltk-tutorial
Named Entity Recognition with NLTK
There are two major options with NLTK's named entity recognition: either recognize all named entities, or recognize named entities as their respective type, like people, places, locations, etc.
🌐
Artiba
artiba.org β€Ί blog β€Ί named-entity-recognition-in-nltk-a-practical-guide
Named Entity Recognition in NLTK: A Practical Guide | Artificial Intelligence
Named entity recognition (NER) is an essential part of natural language processing (NLP) that helps to identify particular entities, including names, organizations, and locations within the text.
Discussions

python - NLTK Named Entity Recognition with Custom Data - Stack Overflow
I'm trying to extract named entities from my text using NLTK. I find that NLTK NER is not very accurate for my purpose and I want to add some more tags of my own as well. I've been trying to find a... More on stackoverflow.com
🌐 stackoverflow.com
nlp - NLTK Named Entity recognition to a Python list - Stack Overflow
I used NLTK's ne_chunk to extract named entities from a text: 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 More on stackoverflow.com
🌐 stackoverflow.com
Named entity recognition using NLTK in python
Take a look at https://github.com/japerk/nltk-trainer . You need to create your own tagged corpus required for training, which conforms to nltk.corpus.reader.ChunkedCorpusReader. After you have done that you can use the trainer described here : http://nltk-trainer.readthedocs.io/en/latest/train_chunker.html If you are specifically looking for Classic Named Entity Recognizers, i would also recommend to look at CRFSuite as well. More on reddit.com
🌐 r/MachineLearning
3
1
July 12, 2016
[D] Named Entity Recognition (NER) Libraries
Hi everyone, I have to cluster a large chunk of textual conversational business data to find relevant topics in it. Since… More on reddit.com
🌐 r/MachineLearning
10
11
January 7, 2023
🌐
MLK
machinelearningknowledge.ai β€Ί home β€Ί beginner’s guide to named entity recognition (ner) in nltk library
Beginner's Guide to Named Entity Recognition (NER) in NLTK Library - MLK - Machine Learning Knowledge
June 3, 2021 - In the output, we can see that the classifier has added category labels such as PERSON, ORGANIZATION, and GPE (geographical physical location) where ever it founded named entity. ... import nltk from nltk import word_tokenize,pos_tag text = "NASA awarded Elon Musk’s SpaceX a $2.9 billion contract to build the lunar lander." tokens = word_tokenize(text) tag=pos_tag(tokens) print(tag) ne_tree = nltk.ne_chunk(tag) print(ne_tree)
🌐
DataCamp
campus.datacamp.com β€Ί courses β€Ί introduction-to-natural-language-processing-in-python β€Ί named-entity-recognition
Named Entity Recognition | Python
For our simple use case, we will use the built-in named entity recognition with NLTK. To do so, we take a normal sentence, and preprocess it via tokenization. Then, we can tag the sentence for parts of speech. This will add tags for proper nouns, pronouns, adjective, verbs and other part of ...
🌐
Medium
fouadroumieh.medium.com β€Ί nlp-entity-extraction-ner-using-python-nltk-68649e65e54b
NLP Entity Extraction/NER using python NLTK | by Fouad Roumieh | Medium
October 13, 2023 - Now, we have the tagged_tokens ... step for named entity recognition, let’s see the final step which is the actual Entity Extraction. To extract the entities all we need is to call β€œne_chunk” to chunk the given list of tagged tokens: entities = nltk.ne_chunk(tagg...
🌐
Nanonets
nanonets.com β€Ί blog β€Ί named-entity-recognition-with-nltk-and-spacy
A complete guide to Named Entity Recognition (NER) in 2025
January 20, 2025 - In this section, we’ll be using ... ... nltk is a leading python-based library for performing NLP tasks such as preprocessing text data, modelling data, parts of speech tagging, evaluating models and more....
Find elsewhere
Top answer
1 of 7
37

nltk.ne_chunk returns a nested nltk.tree.Tree object so you would have to traverse the Tree object to get to the NEs.

Take a look at Named Entity Recognition with Regular Expression: NLTK

>>> from nltk import ne_chunk, pos_tag, word_tokenize
>>> from nltk.tree import Tree
>>> 
>>> def get_continuous_chunks(text):
...     chunked = ne_chunk(pos_tag(word_tokenize(text)))
...     continuous_chunk = []
...     current_chunk = []
...     for i in chunked:
...             if type(i) == Tree:
...                     current_chunk.append(" ".join([token for token, pos in i.leaves()]))
...             if current_chunk:
...                     named_entity = " ".join(current_chunk)
...                     if named_entity not in continuous_chunk:
...                             continuous_chunk.append(named_entity)
...                             current_chunk = []
...             else:
...                     continue
...     return continuous_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."
>>> get_continuous_chunks(my_sent)
['WASHINGTON', 'New York', 'Loretta E. Lynch', 'Brooklyn']


>>> my_sent = "How's the weather in New York and Brooklyn"
>>> get_continuous_chunks(my_sent)
['New York', 'Brooklyn']
2 of 7
22

You can also extract the label of each Name Entity in the text using this code:

import nltk
for sent in nltk.sent_tokenize(sentence):
   for chunk in nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(sent))):
      if hasattr(chunk, 'label'):
         print(chunk.label(), ' '.join(c[0] for c in chunk))

Output:

GPE WASHINGTON
GPE New York
PERSON Loretta E. Lynch
GPE Brooklyn

You can see Washington, New York and Brooklyn are GPE means geo-political entities

and Loretta E. Lynch is a PERSON

🌐
Medium
medium.com β€Ί data-science β€Ί named-entity-recognition-with-nltk-and-spacy-8c4a7d88e7da
Named Entity Recognition with NLTK and SpaCy | by Susan Li | TDS Archive | Medium
December 6, 2018 - With the function nltk.ne_chunk(), we can recognize named entities using a classifier, the classifier adds category labels such as PERSON, ORGANIZATION, and GPE. ne_tree = ne_chunk(pos_tag(word_tokenize(ex))) print(ne_tree) ...
🌐
Wellsr
wellsr.com β€Ί python β€Ί python-named-entity-recognition-with-nltk-and-spacy
Python Named Entity Recognition with NLTK & spaCy - wellsr.com
August 14, 2020 - To download and install all the ... for named entity recognition, you need to pass the parts of speech (POS) tags of a text to the ne_chunk() function of the NLTK library....
🌐
Medium
divyanshjain6134.medium.com β€Ί named-entity-recognition-ner-in-python-using-nltk-1421d1f72b8c
Named Entity Recognition (NER) in Python Using NLTK | by Divyansh Jain | Medium
February 18, 2025 - """ from nltk import word_tokenize words=word_tokenize(sentence) print(words) #Giving Part of Speech Tags to the words tagged=nltk.pos_tag(words) # By using the ne_chunk we can generate a tree like structure to give the pos tags to every word nltk.ne_chunk(tagged)
🌐
NLTK
nltk.org β€Ί book β€Ί ch07.html
7. Extracting Information from Text
Named entity recognition is a task that is well-suited to the type of classifier-based approach that we saw for noun phrase chunking. In particular, we can build a tagger that labels each word in a sentence using the IOB format, where chunks are labeled by their appropriate type.
🌐
NLTK
nltk.org β€Ί howto β€Ί relextract.html
NLTK :: Sample usage for relextract
For example, assuming that we can recognize ORGANIZATIONs and LOCATIONs in text, we might want to also recognize pairs (o, l) of these kinds of entities such that o is located in l. The sem.relextract module provides some tools to help carry out a simple version of this task. The tree2semi_rel() function splits a chunk document into a list of two-member lists, each of which consists of a (possibly empty) string followed by a Tree (i.e., a Named Entity):
🌐
Coder Connect
ukana.hashnode.dev β€Ί named-entity-recognition-ner-in-nlp-using-nltk
Named Entity Recognition (NER) in NLP using NLTK
October 28, 2024 - Named Entity Recognition (NER) ... where entities such as names of people, organizations, locations, dates, and more are identified and classified in text. For instance, in the sentence "Albert Einstein was born in Germany in 1879," NER helps ...
🌐
Spot Intelligence
spotintelligence.com β€Ί home β€Ί how to implement named entity recognition in python with spacy, bert, nltk & flair
How To Implement Named Entity Recognition In Python With SpaCy, BERT, NLTK & Flair
December 26, 2023 - There are many different ways of implementing named entity recognition. The simplest is a rule-based system. Slightly more complicated is the dictionary approach, and the more complicated systems use machine learning. Supervised and unsupervised learning can both be used to do entity extraction. The most complicated NER technique is based on neural networks. Common options are BiLSTM, ELMO, and BERT architectures. Python has several really good NER implementations to choose from. SpaCy, NLTK, BERT and Flair all have solid implementations you can use out of the box or train your model with.
🌐
Medium
matam-kirankumar.medium.com β€Ί named-entity-recognition-with-nltk-nlp-in-python-edaee48103ce
Named-Entity- Recognition with NLTK (NLP in Python) | by Kiran Kumar | Medium
August 20, 2023 - The nltk.download() functions are ... entity recognition is performed. The nltk.ne_chunk_sents() function is used to chunk the POS-tagged sentences and identify named entities....
🌐
Aswnss Blog
aswnss.hashnode.dev β€Ί named-entity-recognition-ner-using-nltk-in-python-using-grammar
Named Entity Recognition (NER) using NLTK in Python Using Grammar
June 30, 2023 - We import the required modules from NLTK: nltk, word_tokenize, pos_tag, and RegexpParser. The bio_tag() function takes a sentence as input and performs the NER process. We tokenize the input sentence using word_tokenize() and assign POS tags to the words using pos_tag(). Next, we define the grammar pattern for named entity recognition using regular expressions. The grammar pattern specifies the structure of named entities, such as noun phrases (NP) and proper nouns (NNP).
🌐
Dev3lop
dev3lop.com β€Ί home β€Ί using python for named entity recognition (ner), a nlp subtask
Using Python for Named Entity Recognition (NER), A NLP Subtask - Dev3lop
October 26, 2023 - To incorporate named entity recognition (NER) into the existing code, you can employ the ne_chunk() function from the nltk.chunk module, which accepts a list of POS-tagged tokens as input and yields a tree of named entities.
🌐
GitHub
gist.github.com β€Ί gavinmh β€Ί 4735528
Named Entity Extraction with NLTK in Python Β· GitHub
File "C:\ProgramData\Anaconda3\lib\site-packages\nltk\tree.py", line 202, in _get_node raise NotImplementedError("Use label() to access a node label.") NotImplementedError: Use label() to access a node label. ... @reach2ashish Replace 'node' with 'label' on Line 12 and it will work :) If you're using Python3, you will also have to add additional ( ) around the print statement.