Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

20ECP118: Foundations of AI Applications Lab

Prepared By: Divneet Singh Kapoor & Kiran Jot Singh

Worksheet
EXPERIMENT – 5
GROUP NO. 3
GROUP MEMBERS:
 Aman Singh
 Sudhanshu Singhal
 Shaurya Yadav
 SIDDHARTHA KUMAR
 Aman Kumar Nishad

Aim:
Derive insights from unstructured text using machine learning
custom models to classify, extract, and detect sentiments

Requirements:
 PC with internet connectivity
 Python 3.7 OR Anaconda (Spyder)

Text Used:
Mirzapur Season 2 Review: A still from the series. That out of the
way, Mirzapur S2 isn't a washout. Directed by Gurmmeet Singh and
Mihir Desai, the show is well-crafted and the script by Puneet
Krishna and Vineet Krishna, while relying largely on trite tropes,
isn't without its share of highs.
20ECP118: Foundations of AI Applications Lab

Prepared By: Divneet Singh Kapoor & Kiran Jot Singh

CODE:

import nltk
from textblob import TextBlob
from textblob import Word

text = input("Enter the text you want to analyze\n")


obj = TextBlob(text)
sentiment, subjectivity = obj.sentiment
print(obj.sentiment)

if sentiment == 0:
print('The text is neutral')
elif sentiment > 0:
print('The text is positive')
else:
print('The text is negative')
nouns = list()

for word, tag in obj.tags:


if tag == 'NN':
nouns.append(word.lemmatize())
print("\nThis text is about...\n")

for item in nouns:


word = Word(item)
print(word.pluralize())
20ECP118: Foundations of AI Applications Lab

Prepared By: Divneet Singh Kapoor & Kiran Jot Singh

OUTPUT:

You might also like