sentiment analysis part1 - GitHub Pages · •...

37
Sentiment Analysis การ$เคราะ(อารม+ความ-ก

Transcript of sentiment analysis part1 - GitHub Pages · •...

Page 1: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Sentiment Analysisการ$เคราะ(อารม+ความ-ก

Page 2: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Sentiment AnalysisExpression of subjective opinion as positive or negative การแสดงออก)งความเ.น0วน1ว2าเ3นแ4บวกห7อลบ

Page 3: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates
Te R.
Te R.
Te R.
Page 4: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Brand Monitoring

brandwatch.com

Te R.
Te R.
Te R.
Te R.
Page 5: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Customer Service

Te R.
Te R.
Te R.
Page 6: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

.นายราคา1น

Johan Bollen, Huina Mao, Xiaojun Zeng (2011) Twitter mood predicts the stock market.

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 7: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Sentiment Analyzer

ข้อความ แง่บวก/ลบ/กลางสุนัขไม่รับประทาน ???กินได้เรื่อยๆ ???

ข้อความ แง่บวก/ลบ/กลางสุนัขไม่รับประทาน ลบกินได้เรื่อยๆ กลาง

Te R.
Page 8: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

การส3าง Sentiment Analyzer

ข้อความ แง่บวก/ลบ/กลางอร่อยจังเลย บวก

ไม่รู้อร่อยตรงไหน ลบพอทานได้ กลางกินจนพุงกาง บวก

… …

Machine Learning AlgorithmExamples

Te R.
Te R.
Te R.
Te R.
Te R.
Page 9: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

ตอน67น8ขนาดไหนแ>ว

• !งไ$%อยเ)น 90%

• out-of-domain problem / overfitting

• ไ$สามารถใ1 package 2ย3ก5ด7อ8ลไ:

Page 10: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

ทฤษ$การ(เคราะ,อารม/และความ34ก

Page 11: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Sentiment ?ออะไร

• ;ฐแจก?ตรคนจนเBมCกสามDานใบ

• ยอดขายเGอนHถIมทลาย

• KนHฝนตกพาNถIมทลายCกแDว

• แซมไปRอไSTกรยานUนVนมา

• หXงเYองVนZแDวเ[ยเวลามาก

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 12: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

@AพC

• emotion

• sentiment

• subjectivity

• opinion

• mood

Page 13: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Scherer Typology of Affect (1984)

• อารม\ Emotion

• สภาพอารม\ Mood

• ^าทางการแสดงออก_อ`aน Interpersonal stances

• bศนคd Attitudes

• eกษณะiคjกภาพ Personality traits

Page 14: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Scherer Typology of Affect (1984)

• Emotion (อารม9): การตอบสนองทางkางกายและระบบภายในของkางกายlm_อเหnการ\_างๆ รอบpวlอาจmความqUญ

• โกรธ mความuข แปลกใจ เศvา อาย กeว

Page 15: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Scherer Typology of Affect (1984)

• Mood (สภาพอารม9) สภาพทางอารม\wอนๆ mผลในเวลา%อน7างนาน โดยyวนใหzแDวจะไ${สาเหn

• kาเ|ง }มเศvา อารม\เ[ย Iองลอย เ~กบาน �วง

Page 16: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Scherer Typology of Affect (1984)

• Interpersonal Stances (การแสดงออก<อ=>น) ^าทางการแสดงออกทางอารม\เÄอmการปÅÇมÉนÑÖบ`aน

• Üางเáน เàนชา อบäน ãคาญ åบ

Page 17: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Scherer Typology of Affect (1984)

• Attitudes (?ศนคA) ความเçอl;บéทèพลมาจากอารม\ ความชอบyวนpว

• ชอบ เกêยด ปรารถนา โหยหา

Page 18: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Scherer Typology of Affect (1984)

• Personality traits (BกษณะทางGคHกภาพ) eกษณะทางอารม\l%อน7างเสëยร ไ$เปíยนแปลง�าย และแนวโìมเîงพฤdกรรมlเñนeกษณะประóของคนๆหòง

• เñนôตร öéจฉา öúง ùมûาม üาพeง

Page 19: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Scherer Typology of Affect (1984)

• อารม\ Emotion

• สภาพอารม\ Mood

• ^าทางการแสดงออก_อ`aน Interpersonal stances

• bศนคd Attitudes

• eกษณะiคjกภาพ Personality traits

Te R.
Te R.
Te R.
Page 20: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Sentiment Analysis

• Binary Classification (positive vs negative)

• Three-way classification (positive vs neutral vs negative)

• Fine-grained classification

Page 21: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

ระDบในการ$เคราะ(

• †และวê

• ระ°บประโยค

• :าน และ¢มมอง

• ระ°บ document

Page 22: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

ทฤษJภาษาศาสตMในการ$เคราะ(อารม+ความN-ก

Page 23: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

การแสดงOศนคPQานภาษา

• ระ°บ†: †l£อ§งbศนคd

• ระ°บวê: Negation การ•ใ¶เñนปÅเสธ

• ระ°บประโยค: syntactic pattern, modality

• ระ°บ discourse: ßดประชดประ®น

Page 24: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

@RSอTงOศนคP

• Adjective (และ adjectival verb) : delicious great อkอย สวย เละ

• Noun : this film is a masterpiece/disaster/failure

• Verb: ชอบ ป©ม เ™อ love hate dislike

• Adverb: อ´าง¨ชอง skillfully

Te R.
Te R.
Page 25: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 26: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Nonveridicality

• modal verbs - the ending of could be better.

• intensional verbs - I thought the food would be as good as last time.

• subjunctive - I wish the exhibitions were accessible to the public.

• intensifier - The quality of this work is barely satisfactory.

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 27: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Negation

• ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก

• Nobody appreciates the decor of the lobby.

• I will never come back to this branch again.

• The soup lacks fresh flavors that it deserves.

• I had bought a few iPhones and was never disappointed until now.

Te R.
Te R.
Te R.
Te R.
Te R.
Page 28: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Negating Adjectives/Adverbs

• good vs not good

• excellent vs not excellent

• ∞เ±ยม vs ไ$∞เ±ยม

• horrendous(ly) vs not horrendous(ly)

• ≤บาท≥ vs ไ$≤บาท≥

Te R.
Te R.
Te R.
Te R.
Te R.
Te R.
Page 29: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Irony and sarcasm

• Trees died for this book?

• Great for very bored and boring people

• อkอยจนอยากจะเท¥ง

• หXงµอเIมHเหมาะแ∂การใ1bบกระดาษ

Te R.
Te R.
Page 30: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

ภาษาศาสต9:บ Sentiment Analysis

• •ใ¶เ∑น§งความละเCยดwอนของโจท∏7อH

• สามารถใ1ทดสอบระบบไ:

• ภาษาไทยอาจจะmÆØaนๆ

Page 31: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

การส3าง Sentiment Analyzer

Page 32: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

https://github.com/sebastianruder/NLP-progress/blob/master/english/sentiment_analysis.md

Page 33: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

https://github.com/sebastianruder/NLP-progress/blob/master/english/sentiment_analysis.md

Page 34: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Out-of-domain problemTrain Test Accuracy

Page 35: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Pipeline

• Preprocessing

• Feature Engineering

• Model training and evaluation

Page 36: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Tokenization• !"#$%

• 555555555

• โดนโกงงงงง!!!!

• # URL

Page 37: sentiment analysis part1 - GitHub Pages · • ภาษา≠งกฤษmÆØการ•ประโยคปÅเสธไ:หลากหลายมาก • Nobody appreciates

Negation

• None of the characters is entertaining -> None of_NOT the_NOT characters_NOT is_NOT entertaining_NOT

• πกชายไ$%อยชอบตอนจบ -> πกชาย ไ$ %อย_NOT ชอบ_NOT ตอนจบ_NOT