sloria / TextBlob

Simple, Pythonic, text processing--Sentiment analysis, part-of-speech tagging, noun phrase extraction, translation, and more.
https://textblob.readthedocs.io/
MIT License
9.15k stars 1.15k forks source link

information about sentiment analysis algorithm #415

Open DSLituiev opened 1 year ago

DSLituiev commented 1 year ago

Is any information available such as publication or corpus used for training?

DSLituiev commented 1 year ago

related to a question in issue #412

Deepankar-98 commented 1 year ago

Internal working of TextBlob Sentiment Analysis Library:

Pattern Sentiment Analysis library is used by Textblob internally for sentiment Analysis. Pattern is a rule based algorithm and it uses knowledge base defined in en-sentiment.xml file for English language.

You can refer this video for more details on how textblob sentiment score is calculated: https://www.youtube.com/watch?v=Y8iNez1tCx8

Sentiment score database -- https://github.com/sloria/TextBlob/blob/6396e24e85af7462cbed648fee21db5082a1f3fb/textblob/en/en-sentiment.xml

You can add new words into this XML file based on your use-case and the word will get included and corresponding sentiment will be visible on reloading the environment.

For example lets add the word expedite:

<word form="expedite" pos="VB" sense="" polarity="-0.3" subjectivity="0.8" intensity="1.0" confidence="0.9" />

Then on reloading and re-running textblob.TextBlob.sentiment.polarity you will get polarity of -0.3

Textblob Sentiment analysis source code: https://github.com/sloria/TextBlob/blob/6396e24e85af7462cbed648fee21db5082a1f3fb/textblob/_text.py#L661