Getting started with NLP using NLTK

Easy Natural Language Processing tutorial using NLTK package in Python

--

Natural Language Processing (NLP) is an area of computer science and artificial intelligence concerned with interactions between computer and human(natural) language.

Well, wondering what is NLTK? the Natural Language Toolkit, or more commonly NLTK, is a suite of libraries and programs for symbolic and statistical natural language processing (NLP) for English written in the Python programming language. It was developed by Steven Bird and Edward Loper in the Department of Computer and Information Science at the University of Pennsylvania.

The basic task in NLP are:

1.convert text to lower case
2. word tokenize
3. sent tokenize
4. stop words removal
5. lemma
6. stem
7. get word frequency
8. pos tags
9. NER

Pre-requirements:

install Python

install nltk and its corpus

Examples:

1. import nltk

import nltk in-order to use its functions

2. convert text to lower case:

It is necessary to convert the text to lower case as it is case sensitive.

Data Scientist Jobs

3. word tokenize

Tokenize sentences to get the tokens of the text i.e breaking the sentences into words.

4. sent tokenize

Tokenize sentences if the there are more than 1 sentence i.e breaking the sentences to list of sentence.

5. stop words removal

Remove irrelevant words using nltk stop words like is,the,a etc from the sentences as they don’t carry any information.

6. lemma

lemmatize the text so as to get its root form eg: functions,funtionality as function

Trending AI Articles:

1. Natural Language Generation:
The Commercial State of the Art in 2020

2. This Entire Article Was Written by Open AI’s GPT2

3. Learning To Classify Images Without Labels

4. Becoming a Data Scientist, Data Analyst, Financial Analyst and Research Analyst

7. stemming

stemming is the process of reducing inflected (or sometimes derived) words to their word stem, base or root form

8. Get word frequency

counting the word occurrence using FreqDist library

9. pos(Part of Speech)tags

POS tag helps us to know the tags of each word like whether a word is noun, adjective etc.

10. NER

NER(Named Entity Recognition) is the process of getting the entity names

PS: Execute all those code and tada!!! you know the basics of NLP 😃

You can also try some mini projects like:

  1. Extracting keywords of documents, articles.
  2. Generating part of speech for phrases.
  3. Getting the top used words among all documents.

You can also check : NLP for Beginners using SPACY

Don’t forget to give us your 👏 !

--

--

curretly an NLP Engineer @EKbana(Nepal)| previously worked@Awesummly(Bangalore)| internship@Meltwater, Bangalore| Linkedin: https://www.linkedin.com/in/pemagrg/