A blog for computer science passionates.

Sunday 3 March 2019

Hello Friends,

In previous post, we have seen how to install NLTK? In this post we start with How to work with NLTK?

As we know, NLTK is a library in python to work with NLP. So, First of all what is NLP?

NLP - Natural Language Processing is to develop an application to understand Human Languages.
some examples,

  • Amazon Alexa
  • Google HomeMini, etc.
Some of it's application, Speech recognition, speech translation, understanding sentences, synonyms etc.

Where NLP is used?
  • Search Engine - in search engine we have seen, we speak a word and it answers. like google, yahoo etc, uses NLP.
  • Social Website Feeds - in social website like facebook uses news feeds.
  • Spam Filters - Google filters spam mails.
These all are the examples of NLP.


So, now let's start to work with NLTK.
Let's tokenize sentences,
Tokenize Sentence means we have a paragraph, and we split this paragraph into sentences. this process is known as tokenize sentences

Example,

from nltk.tokenize import sent_tokenize
sentence="This is an example of NLTK. Let's start with sentences tokenizer"
print(sent_tokenize(sentence))

O/P of above code

['This is an example of NLTK.', "Let's start with sentences tokenizer"]

Run the above code it will return list of sentences. 

Now, Let's see an example of word_tokenize. Like tokenize sentences return different sentence in list from group of sentences.
word_tokenize returns list of words from sentences it splits words.

Example,
from nltk.tokenize import word_tokenize
sentence="This is an example of NLTK. Let's start with sentences tokenizer"

print(word_tokenize(sentence))

O/P of below code

['This', 'is', 'an', 'example', 'of', 'NLTK', '.', 'Let', "'s", 'start', 'with', 'sentences', 'tokenizer']

So, Start with NLTK and try to tokenize sentences and words. in next post we will learn more in NLTK.

Happy Coding... :)
Hello Friends,

Today we are going to learn natural language processing by using python and nltk.

nltk - is one of the most popular library (Module) available in python for Natural Language Processing.
some other libraries are there for NLP:

  • NLTK
  • Apache OpenNLP
  • Stanford NLP suite.
  • Gate NLP Library etc.
NLTK (Natural Language Toolkit), is most popular NLP library first of all we need to install it.
So, let's install NLTK, for that open,

cmd select path of your python then run below command,

  • pip install nltk
After that just open idle and write below lines,


>>> import nltk
>>> nltk.download()
showing info https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml


it will open below nltk downloader dialogue,

just click on download button it will install nltk. it takes some time to install all modules,

after installation we can start, development on nltk.