Natural Language Processing

NLP – Python

NLP – Python

A group of Python libraries known as the Natural language toolkit (NLTK) was created specifically to locate and tag the various parts of speech that can be found in texts written in natural languages like English. To build NLTK-based applications for natural language processing and perform text analysis, additional Python packages like "genism" and "pattern" are also important. 

  • Tokenization: The process of dividing the given text into smaller units known as tokens is known as tokenization. Tokens can be letters, numbers, or punctuation marks. It's also known as word segmentation.
  • Stemming: Language is very diverse because of grammatical reasons. Variations in the sense that different forms of a word exist in the language, both English and other languages. For projects involving machine learning, the machines must comprehend that these various words share the same basic form. As a result, when analyzing the text, it is very helpful to extract the word's basic forms.
  • Lemmatization: Another method of removing inflectional endings from words is lemmatization, which typically employs vocabulary and morphological analysis. The base form of any word after lemmatization is known as a lemma.

Running the NLP Script
import nltk
Here,

  • DT is the determinant
  • VBP is the verb
  • JJ is the adjective
  • IN is the preposition
  • NN is the noun
sentence=[("a","DT"),("clever","JJ"),("fox","NN"),("was","VBP"),("jumping","VBP"),("over","IN"),("the","DT"),("wall","NN")]
grammar = "NP:{<DT>?<JJ>*<NN>}"
parser_chunking = nltk.RegexpParser(grammar)
parser_chunking.parse(sentence)
Output = parser_chunking.parse(sentence)
output.draw()

 

Top course recommendations for you

    How to Build your own Chatbot using Python?
    2 hrs
    Beginner
    32.8K+ Learners
    4.5  (2163)
    Face Detection with OpenCV in Python
    2 hrs
    Intermediate
    16.2K+ Learners
    4.45  (705)
    Introduction to Artificial Intelligence
    1 hrs
    Beginner
    146K+ Learners
    4.47  (18127)
    AI for Leaders
    2 hrs
    Advanced
    4.4K+ Learners
    4.51  (245)
    AI Foundation
    4 hrs
    Beginner
    7.7K+ Learners
    4.49  (177)
    Multilayer Perceptron
    2 hrs
    Intermediate
    2.8K+ Learners
    4.62  (170)
    Deepfakes Basics
    2 hrs
    Intermediate
    4.8K+ Learners
    4.48  (200)
    Convolutional Neural Networks
    3 hrs
    Intermediate
    12.9K+ Learners
    4.6  (535)
    Neural Network in R
    2 hrs
    Intermediate
    6K+ Learners
    4.53  (206)