TRƯỜNG ĐẠI HỌC THỦ DẦU MỘTKHOA KỸ THUẬT CÔNG NGHỆ Tên đề tài: NGHIÊN CỨU RÚT TRÍCH THÔNG TIN DỰA TRÊN CƠ SỞ PHÂN TÍCH CẢM XÚC Mã số: Chuyên đề: Lập trình ứng dụng demo Chủ nhiệm đề tài :
Trang 1TRƯỜNG ĐẠI HỌC THỦ DẦU MỘT
KHOA KỸ THUẬT CÔNG NGHỆ
Tên đề tài: NGHIÊN CỨU RÚT TRÍCH THÔNG TIN
DỰA TRÊN CƠ SỞ PHÂN TÍCH CẢM XÚC
Mã số:
Chuyên đề:
Lập trình ứng dụng demo
Chủ nhiệm đề tài : ThS.Nguyễn Tấn Lộc
Người chủ trì thực hiện chuyên đề : ThS.Nguyễn Tấn Lộc
Bình Dương, 08/01/2018
Trang 2Mục lục
1
2
3 Danh mục chữ viết tắt
6 TF.IDF: term frequency inverse document frequency
8 Logistic: hồi quy logistic
11 SoA: Sentiment analysis - Phân tích cảm xúc
Trang 31 Đặt vấn đề
12 Dựa vào lý thuyết mô hình logistic, ngôn ngữ lập trình python với IDE
jupyter notebook chúng tôi xây dựng mô hình xếp hạng các bình luận và trích xuất các bình luận Sau đó thực hiện phân tích và đánh giá mức độ ảnh hưởng các từ cho các loại ẩm thực của các quốc gia kết quả phân tích ẩm thực các quốc gia phản ánh đúng thực tiễn : Món ăn phổ biến nhất Việt Nam là phở, Nhật Bản với các ẩm thực sushi tươi sống, một số món ăn Thái có hương vị cay, các nhà hàng Ý nổi tiếng với bánh pizza
2 Phương pháp nghiên cứu, cách tiếp cận
13 - Sử dụng ngôn ngữ lập trình python với IDE jupyter notebook
14.- Dựa vào lý thuyết mô hình logistic v2 tối ưu hóa hàm mất mát, chuẩn hóa mô hình L2-norm
3 Kết quả đạt được
15 - Đọc dữ liệu nhà hàng từ tập tin excel
16 import pandas as P d
17 import numpy as np
18 reviews = pd.read_csv('Resfull.csv',encoding = "ISO-8859-1")
19.- Trong phần thực nghiệm này, chúng tôi rút trích thông tin hữu ích và các bình luận nằm nhóm đầu 10 được bình luận tốt nhất, nhóm 10 bình luận hàng đầu theo quốc gia:
23
catego
4 26 This is a belated review for a meal that
can (New)
28 Cain's Saloon 29
5
30 Great beer list always changing it up
can (New)
32 Olive Garden Italian
Restaurant
33
2
34 In the last few years Ive tried my best to
36 Olive Garden Italian
Restaurant 37
1 38 I dont know what is happening to Olive
40 NYPD Pizza 41
5 42 My favorite lunch spot in the area Im from NJ 43 Italian
44 Sunup Brewing 45
4 46 Nice cozy neighborhood brewery Friendly staff 47 Ameri
can (New)
48 Murphy's Pub 49
4
50 Well its an institution here at the u of I
can (New)
52 Randy's Restaurant &
Ice Cream
53
4
54 I go here when i am working and want to get aw
55 Ameri can (New)
56 Filibertos Mexican
1 58 After hearing a few individuals talk about
an
60 Hiro Sushi 61
5 62 This IS as good as it gets for sushi in
ese
64 Bảng 1.Các bình luận tích cực nhất cho các doanh nghiệp
65
66 #top 10 positive reviews for Vietnamese restaurant
Vietnamese=reviews_subset_test[reviews_subset_test.categories=-Vietnamese']
Vietnamese[['review_id', 'name','stars', 'text_clean', 'categories','sentiment']] test_matrix_vn = vectorizer.transform(Vietnamese['text_clean'].values.astype('U')) predict_prob_vn =
3
Trang 4sentiment_model.predict_proba(test_matrix_vn)[:,1] predict_score_vn =
sentiment_model.decision_function(test_matrix_vn) df_viet = {'Probabilties':
predict_prob_vn, 'Scores': predict_score_vn, 'Predictions': se
ntiment_model.predict(test_matrix_vn)} sentiment_model_predictions =
pd.DataFrame(df_viet).sort_values(by-Scores', ascen ding=False)
sentiment_model_predictions head( 10) top20posreviews=Vietnamese[['review_id',
'name','stars', 'text_clean', 'categories','senti
ment']].iloc[sentiment_model_predictions.index[0:100]] top10posreviews['text_clean']
tegories
71 Loving Hut 72
5 73 We love this place Th is is gonna be a long rev 74 Vie
tnamese
75 Loving Hut 76
5 77 Yummmmmmm Best vegetarian restaurant in
tnamese
79 Tram's Kitchen 80
5 81 It might be a holeinthewall but its a pretty n 82 Vie
tnamese
83 Saigon Pho &
Seafood
84
5 85 Fast service delicious food and excellent pric 86 Vie
tnamese
87 Tea Light Cafe 88
5 89 Im giving Tea Light Cafe an extra star well de 90 Vie
tnamese
91 Tea Light Cafe 92
4 93 Ive been driving by Tea Lite for awhile but ne 94 Vie
tnamese
95 Savor Flavor Asia 96
5 97 This is a great little spot casual and quick a 98 Vie
tnamese
99 Pho Minh 100
5 101 Best place for pho in the city 1 have tried th 102 Vie
tnamese
103 Saigon Pho &
Seafood 104
5 105 Saigon is by far my favorite pho stop 1 come h 106 Vie
tnamese
107 Cyclo Vietnamese
Cuisine
108
4 109 We really like this place 1 love the owners 110 Vie
tnamese
111.112.Bảng 2 Các bình luận cảm xúc tích cực nhất cho các doanh nghiệp Việt Nam
113.- Nhóm 10 bình luận cảm xúc tiêu cực nhất cho các nhà hàng Việt Nam, dữ liệu phản ánh khá hợp lý với xếp hạng 1 đến 3 sao
114 chuoi2=''
115 for titlel in top20negatives['text_clean'].values.tolist(): chuoi2= chuoi2+ titlel +''
116 wordcloud = WordCloud().generate(chuoi2) plt.imshow(wordcloud,
interpolation-bilinear') plt.axis("off")
117 # lower maxfont size
118 wordcloud = WordCloud(max,max_font_size=40).generate(chuoi2) plt.figure()
119 plt.imshow(wordcloud, interpolation-'bilmear") plt.axis("off")
120 plt.show()
Trang 5121 name 122.
tegories
125 Phu Thanh 126
1
127 Being a huge fan of Vietnamese food and how he
128 Vie tnamese
129 Saigon Pho &
Seafood
130
1 131 Dont go to this restaurant The employees are 132 Vie
tnamese
133 Tea Light Cafe 134
3 135 First and foremost this fastfood Vietnam rest 136 Vie
tnamese
1 139 Maybe I went on a bad day but the food was pre 140 Vie
tnamese
141 My Ngoc
Restaurant 142
1 143 Theres a reason why this place has no reviews . 144 Vie
tnamese
145 Saigon Pho &
Seafood 146
1 147 Very VERY disappointed in the service This was 148 Vie
tnamese
149 Cyclo Vietnamese
Cuisine
150
1 151 I really dont understand what the fuss is abou 152 Vie
tnamese
153 Loving Hut 154
1 155 Absolutely terrible and slow service They are 156 Vie
tnamese
157 Saigon Pho &
Seafood 158
1 159 We always eat here when we crave Saigon Pho
tnamese
161 Saigon Pho &
Seafood
162
1
163 We had dinner and had the worst experience
we
164 Vie tnamese
165 Bảng 3.Nhóm bình luận cảm xúc tiêu cực nhất cho doanh nghiệp Việt Nam
166
167 Kết quả phân loại cảm xúc tích cực và tiêu cực ảnh hưởng rất mạnh đến kết quả rút trích thông tin Nếu kết quả phân loại chính xác, truy vấn sẽ rút trích thông tin
có độ chính xác cao
168 3.1 Kết quả thực nghiệm
169 Dữ liệu với mô hình logistic cho kết quả với độ chính xác cao
accuracy=90%, recall=89.8%, precision=96.9% và hệ số chuẩn hóa cho mô hình tối
ưu với hệ số chuẩn hóa C=0.2154
170
171 Hình 1 Đánh giá mô hỉnh huấn luyện và kiểm thử dữ liệu
5
Trang 6172 Bảng 4 Ma trân đánh giá phân loại cảm xúc
173 Trích xuất chính xác cảm xúc giúp doanh nghiệp định hình xu hướng phát triển, đồng thời nắm bắt được quan điểm và cảm xúc khách hàng về món ăn, chất lượng dịch vụ khách hàng
174 Nhóm 10 từ cảm xúc mạnh tích cực và tiêu cực nhất
175 r rrir ■/K ■
r rri* */K ■
178 Tiêu cực-hệ số
179 excellent: 1.14614924052
180 delicious: 1.1119727885 amazing: 1.03514286548
perfect: 0.838463244404 great:
0.72016372024
182 worst: -1.13781905968 horrible: -1.0873361229 terrible: -1.04677190115 mediocre: -1.04432799702 bland: -0.874645601756 awful: -0.836073920222 tasteless: -0.821659220617 rude:
-0.820886331069 disgusting: -0.805035172104 overpriced: -0.803561081306
183 Bảng 5 Nhóm 10 từ cảm xúc rút ra từ kết quả phân tích
184
185 - Nhóm 20 từ phổ biến trích từ các bình luận hàng đầu thể hiện cảm xúc tích Các từ có tần số xuất hiện cao phù hợp với thực tế Món ăn phổ biến Việt Nam là phở
186
187 Hình 2. Phân phối các từ có tần suất cao ẩm thực Việt
188 - Đoạn chương trình thể hiện wordcloud
189 from wordcloud import WordCloud import matplotlib.pyplot as plt
chuoi=''
190.for title in top20posreviews['text_clean'].values.tolist(): chuoi= chuoi+ title +''
191 wordcloud = WordCloud().generate(chuoi) plt.imshow(wordcloud, interpolation='bilinear') plt.axis("off")
Trang 7192 # lower max_font_size
193 wordcloud = WordCloud(max_font_size=40).generate(chuoi) plt.figure()
194 plt.imshow(wordcloud, interpolation="bilinear") plt.axis("off")
195 plt.show()
196
197.198.Hình 3 Các từ ảnh hưởng mạnh ẩm thực Việt
199 - Kết quả phân loại và rút trích cảm xúc chính xác cho các nhà hàng Nhật bản, món ăn phổ biến nhất là Sushi và tươi sống
200 blacklist =
["the","The","and",,also,,"a","is",,out,,,just,,"in",,all',,or,,"to","be","it" ,"I","was","wer e","of^,,"ofĩ^,,,up,,,on', "are", "for", "this'Vabouf
201 ,above\
202 according,,
203 ,accordingly,,
204 Across,, 'actually','any','only',"Time","My",'ouf,'Ouf,'which','whaf,'who',
'after','me','about',
205 'afterwards','too','got','can','from','back','than','other',rWe','They','get','if1,'go ', ,again,,
206 'againsf,'thaf,'my','would','will','we','you','have','has','buf,'with','as','af,'they'
,'so' ,'its','some','here','there','their','very','had'] # Blacklist of words to be filtered out
chuoi=chuoi lower() for word in blacklist:
207 chuoi = chuoi.replace(" " + word + " ", " ")
208 word_list = chuoi.split() counts = Counter(word_list)
209 labels, values = zip(*counts.items())
210 # sort your values in descending order indSort = np.argsort(values)[::-1] [:20]
211 # rearrange your data
212 labels = np.array(labels)[indSort] values = np.array(values)[indSort]
213 indexes = np.arange(len(labels))
214 bar_width = 0.1 plt.bar(indexes, values) # add labels
215 plt.xticks(indexes + bar_width, labels, rotation-vertical') plt.show()
7
Trang 8217.218.Hình 4 Phân phối các từ có tần suất cao của ẩm thực Nhật
219
220 Hình 5 Các từ ảnh hưởng mạnh ẩm thực Nhật bản
4.Kết luận và kiến nghị
221 Trong nghiên cứu này, Tôi thực hiện khảo sát và so sánh hướng tiếp cận phân loại cảm xúc dựa vào các thuật toán học máy, từ điển và ontology và đánh giá các kỹ thuật rút trích thông tin dựa trên cơ sở phân loại cảm xúc Trên nền tảng các lý thuyết đó, Tôi tiền hành xây dựng mô hình thực nghiệm với phương pháp hồi quy logistic để phân loại cảm xúc và sau đó tiến hành rút trích thông tin Và thử nghiệm thuật toán rút trích thông tin có cảm xúc cho các câu truy vấn Cụ thể đề tài đạt được một số cột mốc quan như sau
222 - Nghiên cứu tổng quan về phân tích cảm xúc, ứng dụng thực tế cuộc sống
223 - Nghiên cứu các phương pháp rút trích thông tin và các phương pháp phân tích cảm xúc
224 - Xây dựng mô hình thử nghiệm trích thông tin theo câu truy vấn từ dữ liệu
225 - Đánh giá thử nghiệm dữ liệu thuật toán hồi quy logistic và lựa chọn tham
số tối ưu để nâng cao độ chính xác thuật toán
Trang 9226 Thời gian tới đề tài tiếp tục phát triển :
227 - Xây dựng nhiều mô hình phân loại cảm xúc với nhiều thuật toán và mở rộng hướng tiếp cận ngữ nghĩa ontology, phương pháp từ điển, học máy từ đó so sánh các kết quả thực nghiệm để so sánh đánh giá ưu khuyết của các phương pháp cho từng trường hợp cụ thể
228 - Xây dựng mô hình rút trích thông tin trên cơ sở phân tích cảm xúc các trang tiếng việt về dịch vụ du lịch tripadvisor, Lazada
5.Tài liệu tham khảo
[1] B Agarwal and N Mittal, “Optimal feature selection for sentiment analysis,” in Proceedings of the 14th International Conference on Intelligent Text Processing and Computational Linguistics (CICLing 13), vol 7817, pp 13-24, 2013
[2] A Basant, M Namita, B Pooja, Sonal Garg “Sentiment Analysis Using
Common-Sense and Context Information” Hindawi Publishing Corporation Computational Intelligence and Neuroscience (2015)
three stage model for document-level sentiment analysis” Information Processing and Management 52 (2016) 36- 45
[4] Y Ainur, Y Yisong, C Claire “Multi-level structured models for document-level sentiment classification”.Proceedings of the 2010 Conference on Empirical Methods in Natural Language Processing, MIT, Massachusetts, Association for Computational Linguistics, USA (2010), pp 1046-1056
[5] F Noura, C Elie, A.A Rawad, H Hazem “Sentence-level and documentlevel sentiment mining for arabic texts”.Proceeding IEEE International Conference on Data Mining Workshops (2010)
[6] Hao chen Zhou and Fei Song.(2015) “Aspect-level sentiment analysis based on a generalized probabilistic topic and syntax model” Proceedings of the Twenty-Eighth International Florida Artificial Intelligence Research Society Conference, Association for the Advancement of Artificial Intelligence (2015)
[7] Ariyasriwatana, W., Buente, W., Oshiro, M., & Streveler, D (2014) Categorizing health-related cues to action: using Yelp reviews of restaurants in Hawaii New Review of Hypermedia and Multimedia, 20(4), 317-340
9
Trang 10[8] Hicks, A., Comp, S., Horovitz, J., Hovarter, M., Miki, M., & Bevan, J L (2012) Why people use Yelp com: An exploration of uses and gratifications Computers
in Human Behavior, 28(6), 2274-2279
[9] Huang, J., Rogers, S., & Joo, E (2014) “Improving restaurants by extracting
subtopics from yelp reviews” iConference 2014 (Social Media Expo).
[10] Ruhui Shen, Jialiang Shen, Yuhong Li & Haohan Wang (2016), ” Predicting usefulness of Yelp reviews with localized linear regression models ”, 2016 7th IEEE International Conference on Software Engineering and Service Science (ICSESS)
[11] Solov'ev A N., Antonova A Ju., Pazel'skaia A G., (2012), Using sentiment-analysis for text information extraction I-Teco (Moscow).
TRANSACTIONS ON AUDIO, SPEECH, AND LANGUAGE PROCESSING, VOL 23, NO 12, DECEMBER 2015
[13] P.D Turney,(2000), “Learning algorithms for keyphrase extraction”
Information Retrieval vol 2, no 4, pp 303 - 336
[14] I.H Witten, G.W Paynter, E Frank, C Gutwin and C.G Nevill- Manning (1999) “KEA: Practical automatic Keyphrase Extraction.” The proceedings of Digital Libraries '99: The Fourth ACM Conference on Digital Libraries, pp 254-255
[15] Huong Nguyen Thi Xuan, Anh Cuong Le ; Le Minh Nguyen, (2012)
”Linguistic Features for Subjectivity classification“ Asian Language Processing (IALP), 2012 International Conference.
Chủ nhiệm đề tài
1