NLP in Python by TextBlob Practical Machine Learning2
Date: 11 May. 2021 3rd Stage
……………………………………………………..………………………………………………………………
Natural Language Processing (NLP) is an area of growing attention
due to increasing number of applications like chatbots, machine
translation etc. In some ways, the entire revolution of intelligent
machines in based on the ability to understand and interact with
humans.
Outline
Why TextBlob?
Installing package
Tokenization
POS-Tagging
Words inflection
N-grams
Spelling correction
Language detection and Translation
1
NLP in Python by TextBlob Practical Machine Learning2
Date: 11 May. 2021 3rd Stage
……………………………………………………..………………………………………………………………
Why TextBlob?
There are many libraries to explore NLP:
1- NLTK is a perfect library for education and research, it
becomes very heavy and tedious for completing even the
simple tasks.
2- TextBlob it is easy to learn and offers a lot of features like
sentiment analysis, pos-tagging, noun phrase extraction, etc.
3- spacy it is recognized as one of the powerful and advanced
library used to implement NLP tasks.
If it is your first step in NLP, TextBlob is the perfect library for you to
get hands-on with.
Installing Packages
Installation of TextBlob in your system in a simple task, all you need
to do is open cmd prompt and enter the following commands:
pip install textblob
Tokenization
Tokenization refers to dividing text or a sentence into a
sequence of tokens, which roughly correspond to “words”.
This is one of the basic tasks of NLP. To do this using
TextBlob, follow the two steps:
1. Create a textblob object and pass a string with it.
2. Call functions of textblob in order to do a specific task.
2
NLP in Python by TextBlob Practical Machine Learning2
Date: 11 May. 2021 3rd Stage
……………………………………………………..………………………………………………………………
This textblob can be tokenized into a sentence and further into
words. In the following read from text file
3
NLP in Python by TextBlob Practical Machine Learning2
Date: 11 May. 2021 3rd Stage
……………………………………………………..………………………………………………………………
POS-Tagging
Part-of-speech tagging or grammatical tagging is a method
to mark words present in a text on the basis of its definition
and context. In simple words, it tells whether a word is a
noun, or an adjective, or a verb, etc.
Here’s a list of the tags, what they mean, and some
examples:
4
NLP in Python by TextBlob Practical Machine Learning2
Date: 11 May. 2021 3rd Stage
……………………………………………………..………………………………………………………………
Word inflection
N-grams
A combination of multiple words together
5
NLP in Python by TextBlob Practical Machine Learning2
Date: 11 May. 2021 3rd Stage
……………………………………………………..………………………………………………………………
Spelling correction
Language detection and Translation