Tải bản đầy đủ (.docx) (10 trang)

Chuyên đề lập trình ứng dụng demo

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (290.2 KB, 10 trang )

TRƯỜ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ố:

Chun đề:

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


Mục lục

1.
2.

3.

Danh mục chữ viết tắt

4.

TF: term frequency

5.



IDF: inverse document frequency

6.

TF.IDF: term frequency. inverse document frequency

7.

DTM: document term matrix

8.

Logistic: hồi quy logistic.

9.

P(A): Xác xuất sự kiện A

10.

NER: Named Entity Recognition

11.

SoA: Sentiment analysis - Phân tích cảm xúc


1. Đặt vấn đề
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.
12.

2. Phương pháp nghiên cứu, cách tiếp cận
- Sử dụng ngơn ngữ lập trình python với IDE jupyter notebook

13.

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
- Đọc dữ liệu nhà hàng từ tập tin excel

15.
16.
17.
18.

import pandas as Pd
import numpy as np
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:
20.

name 21.
sta

22.

24.

Kai

25.

26.

4

28.

Cain's Saloon

29.

took...

32.


Olive Garden Italian
Restaurant
36.
Olive Garden Italian
Restaurant

40.

NYPD Pizza

44.

Sunup Brewing

48.

Murphy's Pub

52.

Randy's Restaurant &
Ice Cream
56.
Filibertos Mexican
Food

60.
65.

Hiro Sushi


64.

30.

This is a belated review for a meal that

Great beer list always changing it up
Follows...
33. 34.
In the last few years Ive tried my best to
lik...
2
37. 38.
I dont know what is happening to Olive
Garden...
1
41. 42.
My favorite lunch spot in the area Im
from
NJ...
5
45. 46.
Nice cozy neighborhood brewery
Friendly staff...
4
49. 50.
Well its an institution here at the u of I
You...
4

53. 54.
I go here when i am working and want to
get aw...
4
57. 58.
After hearing a few individuals talk about
Fil...
1
61. 62.
This IS as good as it gets for sushi in
Arizon...
5
Bảng 1.Các bình luận tích cực nhất cho các doanh nghiệp

5

23.

textclean
27.

catego

Ameri
can (New)
31.
Ameri
can (New)

35.


Italian

39.

Italian

43.

Italian

47.

Ameri
can (New)
51.
Ameri
can (New)
55.
Ameri
can (New)
59.
Mexic
an
63.
Japan
ese

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


sentiment_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']
67.

name 68.
sta
72.

ca
textclean 70.
tegories

73.

We love this place Th is is gonna be a long rev...

74.

76.


77.

Yummmmmmm Best vegetarian restaurant in

78.

5

Phoen...

71.

Loving Hut

75.

Loving Hut

79.

Tram's Kitchen

80.

83.

Saigon Pho &

84.


Seafood

69.

5

82.

It might be a holeinthewall but its a pretty n...

5

85.

Fast service delicious food and excellent pric...

5

89.

Im giving Tea Light Cafe an extra star well de...

93.

Ive been driving by Tea Lite for awhile but ne...

94.

97.


This is a great little spot casual and quick a...

98.

88.

86.

90.

91.

Tea Light Cafe

92.

95.

Savor Flavor Asia

96.

99.

Pho Minh

100. 101.

Best place for pho in the city 1 have tried th...


102.

103.

Saigon Pho &

104. 105.

Saigon is by far my favorite pho stop 1 come h...

106.

108. 109.

We really like this place 1 love the owners...

110.

Seafood

107.

5
5

Cyclo Vietnamese

Cuisine


4

111.
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
112.

Vie

tnamese

Tea Light Cafe

5

Vie

tnamese

87.

4

Vie

tnamese

81.

5


Vie

tnamese

Vie

tnamese
Vie

tnamese
Vie

tnamese
Vie

tnamese
Vie

tnamese
Vie

tnamese

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.
118.
119.
120.

# lower maxfont size
wordcloud = WordCloud(max,max_font_size=40).generate(chuoi2) plt.figure()
plt.imshow(wordcloud, interpolation-'bilmear") plt.axis("off")
plt.show()

4


121.

name 122.
sta

123.

126. 127.

125.

Phu Thanh

129.


Saigon Pho &

1

Seafood

textclean 124. ca
tegories

Being a huge fan of Vietnamese food and how

he...

128.

130. 131.

Dont go to this restaurant The employees are...

132.

1
Tea Light Cafe

134. 135.

First and foremost this fastfood Vietnam rest...

136.


137.

Pho Minh

138. 139.

Maybe I went on a bad day but the food was pre...

140.

142. 143.

Theres a reason why this place has no reviews ...

144.

146. 147.

Very VERY disappointed in the service This was...

148.

150. 151.

I really dont understand what the fuss is abou...

152.

141.


My Ngoc
Restaurant
145. Saigon Pho &
Seafood
149. Cyclo Vietnamese
Cuisine

1
1
1
1

157.

Saigon Pho &

158. 159.

We always eat here when we crave Saigon Pho

160.

Saigon Pho &

Seafood

165.

166.
167.


162. 163.

We had dinner and had the worst experience
we ...
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

1

Vie

tnamese

156.

161.

Vie

tnamese

Absolutely terrible and slow service They are...

To...

Vie

tnamese

154. 155.

1

Vie

tnamese

Loving Hut

Seafood

Vie

tnamese

153.

1

Vie

tnamese

133.

3

Vie

tnamese


Vie

tnamese
Vie

tnamese

164.

Vie

tnamese

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.
169.

3.1

Kết quả thực nghiệm

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


172.
173.

Bảng 4.Ma

trân đánh giá phân loại cảm xúc

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.
176. Tích cực - hệ số
179. excellent: 1.14614924052
180. delicious: 1.1119727885
r rrir/K



amazing: 1.03514286548
181. awesome:
0.872256805683
perfect:
0.838463244404
great:
0.806499315192
best:
0.744851346902
fantastic:
0.734042587596
love:
0.731300119008
reasonable:
0.72016372024
183.
184.
185.

Bảng 5. Nhóm

177.
178. Tiêu cực-hệ số
182. worst: -1.13781905968
r rri*/K
■*

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

10 từ cảm xúc rút ra từ kết quả phân tích

- 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")
6


192.
193.
194.

195.

# lower max_font_size
wordcloud = WordCloud(max_font_size=40).generate(chuoi) plt.figure()
plt.imshow(wordcloud, interpolation="bilinear") plt.axis("off")
plt.show()

196.
197.198.
Hình 3.Các từ ảnh hưởng mạnh ẩm thực Việt

- 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

199.

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.
[:20]

# sort your values in descending order indSort = np.argsort(values)[::-1]

211.
212.

# rearrange your data
labels = np.array(labels)[indSort] values = np.array(values)[indSort]

213.

indexes = np.arange(len(labels))


214.
215.

bar_width = 0.1 plt.bar(indexes, values) # add labels
plt.xticks(indexes + bar_width, labels, rotation-vertical') plt.show()
7


216.
217.
Hình 4..Phân phối các từ có tần suất cao của ẩm thực Nhật
218.

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 tố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 tốn.

8


226.

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)
[3] RuiXia, FengXu, JianfeiYu,” Polarity shift detection, elimination and ensemble: A
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 TwentyEighth 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


[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).
[12] Wanxiang Che, Yanyan Zhao, Honglei Guo, Zhong Su, and Ting Liu,”
Sentence Compression for spect-Based Sentiment Analysis” IEEE/ACM

229.

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. 254255.
[15]

Huong Nguyen Thi Xuan, Anh Cuong Le ; Le Minh Nguyen, (2012)

”Linguistic Features for Subjectivity classification“ Asian Language Processing
(IALP), 2012 International Conference.

230.

Xác nhận thực hiện chuyên đề
Chủ nhiệm đề tài

1
0



×