Version 22 (modified by 8 years ago) (diff) | ,
---|
Opinion mining, sentiment analysis
IA161 Advanced NLP Course?, Course Guarantee: Aleš Horák
Prepared by: Zuzana Nevěřilová
State of the Art
Sentiment analysis can be seen as a text categorization task (i.e. is the writer's opinion on a discussed topic X or Y?). It consists of detection of the topic (which can be easy in focused reviews) and detection of the sentiment (which is generally difficult). Opinions are sometimes expressed in a very subtle manner (e.g. the sentence How could anyone sit through this movie? contains no negative word) [3]. The sentiments are usually simply classified by their polarity (positive, negative) but they can be recognized more in depth (e.g. strongly negative). Recognized opinions are also subject to summarization (e.g. how many people like this new iPhone design?).
References
- Bing Liu. Sentiment Analysis and Opinion Mining. Synthesis Lectures on Human Language Technologies. 2012, 5(1): 1-167. DOI: 10.2200/s00416ed1v01y201204hlt016. Draft version available at http://www.cs.uic.edu/~liub/FBS/SentimentAnalysis-and-OpinionMining.pdf
- Bing Liu. Sentiment Analysis Tutorial. AAAI-2011, August 8, 2011. Slides available at http://www.cs.uic.edu/~liub/FBS/Sentiment-Analysis-tutorial-AAAI-2011.pdf
- Bo Pang, Lillian Lee, and Shivakumar Vaithyanathan, Thumbs up? Sentiment Classification using Machine Learning Techniques, Proceedings of EMNLP 2002. http://www.cs.cornell.edu/home/llee/papers/sentiment.pdf
- Liviu P. Dinu and Iulia Iuga. The Naive Bayes classifier in opinion mining: In search of the best feature set. In Alexander Gelbukh, editor, Computational Linguistics and Intelligent Text Processing, volume 7181 of Lecture Notes in Computer Science, pages 556–567. Springer Berlin Heidelberg, 2012.
Bing Liu's References: http://www.cs.uic.edu/~liub/FBS/AAAI-2011-tutorial-references.pdf
Practical Session
Czech Sentiment Analysis
In this workshop, we try several methods for opinion mining. First, we will train a classifier on real Czech data from Seznam.cz (thank you for the data, Seznam.cz guys!).
Requirements: python, NLTK module
Files: reviews.csv, reviews_desamb.csv, reviews_czaccent.csv, reviews_czaccent_desamb.csv, classify.py
- Create
<YOUR_FILE>
, a text file named ia161-UCO-01.txt where UCO is your university ID. - Open
reviews.csv
, observe column meanings (Ack. to Karel Votruba, Karel.Votruba@firma.seznam.cz):- shop ID
- positive comment
- negative comment
- price/delivery rating
- communication rating
- goods/content rating
- package/return rating
- complaints procedure rating
- Run classify.py.
PYTHONIOENCODING=UTF-8 python classify.py
- What the most informative features? Do they make sense? Write most informative features to
<YOUR_FILE>
and mark them with + or - depending on whether they make sense. Example (In the example, we can see that the first feature makes sense while the second does not.):- peníze +
- s -
- Open classify.py, read the code, uncomment print statements, observe the results.
- Why the classification is not very good even though the accuracy is over 95 %? Particularly, why the last sentence is not correctly classified? Write your answer at the end of
<YOUR_FILE>
. Feel free to discuss it with the group. - Think of improvements in feature extraction. Currently, the program takes only words as features. Add another feature, i.e. modify the function
document_features()
.
Sentiment analysis in English
Second, we try the Stanford Core NLP Sentiment Pipeline.
Requirements: Java 8, python, gigabytes of memory
module add jdk
this adds Java 8, you can check it when typing java -version
- Download Stanford Core NLP from http://nlp.stanford.edu/software/corenlp.shtml, unzip it.
- Try it: e.g.
java -cp "stanford-corenlp-full-2015-04-20/*" -mx5g \ edu.stanford.nlp.sentiment.SentimentPipeline -stdin
orjava -cp "stanford-corenlp-full-2015-04-20/*" -mx5g \ edu.stanford.nlp.sentiment.SentimentPipeline -file book-reviews.txt
The file book-reviews.txt is available.
- In how many classes does Stanford Core NLP classify the sentences? Write it in
<YOUR_FILE>
. Write example of a wrong classification.
Upload <YOUR_FILE>
Do not forget to upload your resulting file to the homework vault (odevzdávárna).
Attachments (4)
- book-reviews.txt (4.0 KB) - added by 7 years ago.
- book-reviews.2.txt (4.0 KB) - added by 7 years ago.
-
classify.py (2.9 KB) - added by 7 years ago.
reseni NLTK UNICODE problemu v NLTK 3.1 (tokenizace necelych slov)
- Aspect_Based_Sentiment_Analysis.ipynb (240.3 KB) - added by 12 months ago.
Download all attachments as: .zip