donât really see the need to do this. I mean we are using another library and the code is just like 9 lines long.
But I suppose I can delve deep into the library to truly discover, I guess.
https://www.youtube.com/watch?v=tXuvh5_Xyrw&list=PL7yh-TELLS1G9mmnBN3ZSY8hYgJ5kBOg-&index=4
Setup
You will want to install nltk (natural language tool kit) from pip
and also install textblob
and lastly, install newspaper3k
this is what we import for our script:
we want to import nltk and nltk.download(âpunktâ) and just run that once, you should be good to continue the code now.
and then we want to grab our article from the internet.
The result we get from the article will be a value from -1 â 1. -1 meaning a negative emotion like hateful, angry, despair, 0 being completely neutral and 1 being upbeat, positive and gleeful.
We pick a wikipedia article which is very tone-neutral
then we prepare it for natural language processing. Download the html page, take the raw html, and prepare nlp.
Summarizing
now, look how long that text is.
Lets summarize it.
the summary we get is quite dull. I believe the AI is searching for general terms like âin generalâ, âoftentimesâ, âmanyâ. Its not really a summary.
The text is all from the article. The webcrawler denotes where it is found(what # div it is I believe)
Getting sentiment
We make a textblob, then we grab the sentiment from blob.sentiment.polarity
0.14. more positive than negative, still pretty neutral
I want to try to get a sentiment from a forumn post
I can also give it my own text
File reading
same sorta deal, just get the text from a file.
now I want you to notice how god-awful the AI performs. I need to add a >:( to signify anger. BRUH!
I believe the algorithm is not so good because it is not actually neural network, it is just a simple AI which scans for words like good(+0.25), bad(-0.25), >:((-0.75), :D(+1)
Other textblob features
This is not included in the video, it is on readthedocs.io https://textblob.readthedocs.io/en/latest/quickstart.html#quickstart
Subjectivity
sentence correction
textblob is a piece of shit