Natural language 18.1_named Entity recognition with NLTK

Source: Internet
Author: User
Tags nltk

https://www.pythonprogramming.net/named-entity-recognition-nltk-tutorial/?completed=/chinking-nltk-tutorial/ Named Entity recognition with NLTK




One of the most major forms of chunking in natural language processing is called "Named Entity recognition." The idea was to has the machine immediately being able to pull out "entities" like people, places, things, locations, Monetar Y figures, and more.

This can being a bit of a challenge, but NLTK are this built in for us. There is 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.

Here's an example:

ImportNltkFromNltk.CorpusImportState_unionFromNltk.TokenizeImport PunktsentencetokenizerTrain_text=State_union.Raw("2005-gwbush.txt")Sample_text=State_union.Raw("2006-gwbush.txt")Custom_sent_tokenizer= Punktsentencetokenizer(Train_text)Tokenized=Custom_sent_tokenizer.Tokenize(Sample_text)DefProcess_content(): Try: ForIInchTokenized[5:]:Words=Nltk.Word_tokenize(I)Tagged=Nltk.Pos_tag(words)  namedent = nltk< Span class= "pun". ne_chunk (tagged, Binary=true)  Namedent . draw ()  except exception as E:  print (str ( eprocess_content ()           

Here, with the option of binary = True, this means either something are a named entity, or not. There'll be no further detail. The result is:

If you set binary = False and then the result is:

Immediately, you can see a few things. When Binary was False, it picked up the same things, but wound up splitting up terms as White House to "white" and "Hou Se "as if they were different, whereas we could see in the binary = True option, the named entity recognition is correct To say White House is part of the same named entity.

Depending on your goals, if you would use the binary option. Here is the types of Named entities that can get if you have binary as false:

NE Type and Examples
Organization-georgia-pacific Corp., who
Person-eddy Bonte, President Obama
Location-murray River, Mount Everest
Date-june, 2008-06-29
Time-two Fifty a M, for the p.m.
MONEY-175 million Canadian Dollars, GBP 10.40
Percent-twenty pct, 18.75
Facility-washington Monument, Stonehenge
Gpe-south East Asia, Midlothian

Either, you'll probably find that's need to do a bit more work to get it just right, but this is pretty powerful r Ight out of the box.

In the next tutorial, we ' re going-talk about something similar to stemming, called lemmatizing.

Natural language 18.1_named Entity recognition with NLTK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.