Statistical modeling involving the n-gram approach

Unigram means a single word. In a unigram tagger, a single token is used to find the particular parts-of-speech tag.

Training of UnigramTagger can be performed by providing it with a list of sentences at the time of initialization.

Let's see the following code in NLTK, which performs UnigramTagger training:

>>> import nltk >>> from nltk.tag import UnigramTagger >>> from nltk.corpus import treebank >>> training= treebank.tagged_sents()[:7000] >>> unitagger=UnigramTagger(training) >>> treebank.sents()[0] ['Pierre', 'Vinken', ',', '61', 'years', 'old', ',', 'will', 'join', 'the', 'board', 'as', 'a', 'nonexecutive', 'director', 'Nov.', '29', '.'] >>> unitagger.tag(treebank.sents()[0]) [('Pierre', 'NNP'), ...

Get Natural Language Processing: Python and NLTK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.