Whats is Part-of-speech (POS) tagging ?
It is a process of converting a sentence to forms – list of words, list of tuples (where each tuple is having a form (word, tag)). The tag in case of is a part-of-speech tag, and signifies whether the word is a noun, adjective, verb, and so on.
Default tagging is a basic step for the part-of-speech tagging. It is performed using the DefaultTagger class. The
DefaultTagger class takes ‘tag’ as a single argument. NN is the tag for a singular noun.
DefaultTagger is most useful when it gets to work with most common part-of-speech tag. that’s why a noun tag is recommended.
Code #1 : How it works ?
[('Hello', 'NN'), ('Geeks', 'NN')]
Each tagger has a
tag() method that takes a list of tokens (usually list of words produced by a word tokenizer), where each token is a single word.
tag() returns a list of tagged tokens – a tuple of (word, tag).
How DefaultTagger works ?
It is a subclass of
SequentialBackoffTagger and implements the
choose_tag() method, having three arguments.
- list of tokens
- index of the current token, to choose the tag.
- list of the previous tags
Code #2 : Tagging Sentences
[[('welcome', 'NN'), ('to', 'NN'), ('.', 'NN')], [('Geeks', 'NN'), ('for', 'NN'), ('Geeks', 'NN')]]
Note: Every tag in the list of tagged sentences (in the above code) is NN as we have used
Code #3 : Illustrating how to untag.
['Geeks', 'for', 'Geeks']
- Python | Part of Speech Tagging using TextBlob
- Part of Speech Tagging with Stop words using NLTK in python
- NLP | Distributed Tagging with Execnet - Part 1
- NLP | Distributed Tagging with Execnet - Part 2
- NLP | Part of speech tagged - word corpus
- Speech Recognition in Python using Google Speech API
- NLP | WordNet for tagging
- NLP | Regex and Affix tagging
- NLP | Trigrams'n'Tags (TnT) Tagging
- NLP | Classifier-based tagging
- NLP | Backoff Tagging to combine taggers
- Python | PoS Tagging and Lemmatization using spaCy
- Python | Text to Speech by using pyttsx3
- Convert Text to Speech in Python
- Python | Convert image to text and then to speech
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet