Natural language 19.1_lemmatizing with NLTK

Source: Internet
Author: User
Tags nltk

https://www.pythonprogramming.net/lemmatizing-nltk-tutorial/?completed=/named-entity-recognition-nltk-tutorial/

Lemmatizing with NLTK




A very similar operation to stemming are called lemmatizing. The major difference between these are, as you saw earlier, stemming can often create non-existent words, whereas lemmas ar e actual words.

So, your root stem, meaning the word "end up with," is not something you can just look up in a dictionary, but can L Ook up a lemma.

Some times you'll wind up with a very similar word, but sometimes, you'll wind up with a completely different word. Let's see some examples.

FromNltk.StemImport WordnetlemmatizerLemmatizer= Wordnetlemmatizer()Print(Lemmatizer.Lemmatize("Cats"))Print(Lemmatizer.Lemmatize("Cacti"))Print(Lemmatizer.Lemmatize("Geese"))Print(Lemmatizer.Lemmatize("Rocks"))Print(Lemmatizer.Lemmatize("Python"))Print(Lemmatizer.Lemmatize("Better",Pos= "a" )) print (lemmatizer.< Span class= "PLN" >lemmatize ( "best" , pos< Span class= "pun" >= "a" print  (lemmatizer. Lemmatize ( "Run"  (lemmatizer. Lemmatize ( "Run" , ' V ' ) )  

Here, we have got a bunch of examples of the lemma for the words so we use. The only major thing to note was that Lemmatize takes a part of speech parameter, "pos." If not supplied, the default is "noun." This means a attempt would be made to find the closest noun, which can create trouble for you. Keep this on mind if your use lemmatizing!

In the next tutorial, we ' re going to dive into the ntlk corpus the came and the module, looking at all of the awesome do Cuments They has waiting for us there.

Natural language 19.1_lemmatizing 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.