├── .gitignore ├── KMeans_Topic_Select.py ├── LDA_Topic_Select.py ├── LICENSE ├── Project_Main.py ├── README.md ├── commit_processing.py ├── data ├── geo_data.csv ├── label_comment.csv ├── sentence_cut.txt ├── text_resource.txt └── xiecheng_ugc.csv ├── model_saved └── init.py ├── pic ├── gaopin1.png ├── ip.png ├── lda_topic_select.png ├── lda_topic_select1.png ├── poi可视化.png ├── poi打分.png ├── 不一致.png ├── 主题.png ├── 各主题分数.png ├── 地址.png ├── 情感分析图.png ├── 数据库.png ├── 文本分类.png ├── 模型对比.png ├── 模型对比2.png ├── 流程.png ├── 结构1.png └── 高频2.png ├── requirement.txt ├── sa_analysis.py ├── sa_model_predict.py ├── sa_model_train.py └── setting.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Example user template template 3 | 4 | # IntelliJ project files 5 | .idea 6 | *.iml 7 | out 8 | gen 9 | __pycache__/ 10 | model/__pycache__ 11 | ### Python template 12 | # Byte-compiled / optimized / DLL files 13 | __pycache__/ 14 | *.py[cod] 15 | *$py.class 16 | # C extensions 17 | *.so 18 | 19 | # Distribution / packaging 20 | .Python 21 | build/ 22 | develop-eggs/ 23 | dist/ 24 | downloads/ 25 | eggs/ 26 | .eggs/ 27 | lib/ 28 | lib64/ 29 | parts/ 30 | sdist/ 31 | var/ 32 | wheels/ 33 | pip-wheel-metadata/ 34 | share/python-wheels/ 35 | *.egg-info/ 36 | .installed.cfg 37 | *.egg 38 | MANIFEST 39 | 40 | # PyInstaller 41 | # Usually these files are written by a python script from a template 42 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 43 | *.manifest 44 | *.spec 45 | 46 | # Installer logs 47 | pip-log.txt 48 | pip-delete-this-directory.txt 49 | 50 | # Unit test / coverage reports 51 | htmlcov/ 52 | .tox/ 53 | .nox/ 54 | .coverage 55 | .coverage.* 56 | .cache 57 | nosetests.xml 58 | coverage.xml 59 | *.cover 60 | .hypothesis/ 61 | .pytest_cache/ 62 | 63 | # Translations 64 | *.mo 65 | *.pot 66 | 67 | # Django stuff: 68 | *.log 69 | local_settings.py 70 | db.sqlite3 71 | 72 | # Flask stuff: 73 | instance/ 74 | .webassets-cache 75 | 76 | # Scrapy stuff: 77 | .scrapy 78 | 79 | # Sphinx documentation 80 | docs/_build/ 81 | 82 | # PyBuilder 83 | target/ 84 | 85 | # Jupyter Notebook 86 | .ipynb_checkpoints 87 | 88 | # IPython 89 | profile_default/ 90 | ipython_config.py 91 | 92 | # pyenv 93 | .python-version 94 | 95 | # pipenv 96 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 97 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 98 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 99 | # install all needed dependencies. 100 | #Pipfile.lock 101 | 102 | # celery beat schedule file 103 | celerybeat-schedule 104 | 105 | # SageMath parsed files 106 | *.sage.py 107 | 108 | # Environments 109 | .env 110 | .venv 111 | env/ 112 | venv/ 113 | ENV/ 114 | env.bak/ 115 | venv.bak/ 116 | 117 | # Spyder project settings 118 | .spyderproject 119 | .spyproject 120 | 121 | # Rope project settings 122 | .ropeproject 123 | 124 | # mkdocs documentation 125 | /site 126 | 127 | # mypy 128 | .mypy_cache/ 129 | .dmypy.json 130 | dmypy.json 131 | 132 | # Pyre type checker 133 | .pyre/ 134 | 135 | ### Example user template template 136 | ### Example user template 137 | 138 | # IntelliJ project files 139 | .idea 140 | *.iml 141 | out 142 | gen 143 | -------------------------------------------------------------------------------- /KMeans_Topic_Select.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @USER: CarryChang -------------------------------------------------------------------------------- /LDA_Topic_Select.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @USER: CarryChang 3 | from sklearn.feature_extraction.text import CountVectorizer 4 | from gensim.corpora.dictionary import Dictionary 5 | # 加载 LDA 模型库 6 | from gensim.models.ldamodel import LdaModel 7 | # 加载计算 LDA 模型的评估库 8 | from gensim.models.coherencemodel import CoherenceModel 9 | # 加载 LDA 主题模型 10 | from sklearn.decomposition import LatentDirichletAllocation 11 | import matplotlib.pyplot as plt 12 | import jieba.posseg as pseg 13 | from tqdm import tqdm 14 | import numpy as np 15 | from setting import * 16 | # 分词器预热 17 | list(pseg.cut('垃圾饭店')) 18 | 19 | # 定义处理函数 20 | def get_n_filter(sentence_list): 21 | # 提取语料提取后的名词 22 | n_filter_list = list() 23 | for sentence_ in tqdm(sentence_list): 24 | n_filter = list() 25 | words = pseg.cut(sentence_) 26 | for word, flag in words: 27 | # 过滤长度大于 1 的名词 28 | if 'n' in flag and len(word) > 1: 29 | n_filter.append(word) 30 | n_filter_list.append(n_filter) 31 | return n_filter_list 32 | def topic_number_search(): 33 | # 设初始的主题数 start_topic_number 34 | start_topic_number = 1 35 | # 设置最大的主题数 topic_numbers_max 36 | topic_numbers_max = 10 37 | # 收集模型分数 38 | error_list = list() 39 | # 定义主题数搜索列表,每次计算差距 2 个 topic 40 | topics_list = list(range(start_topic_number, topic_numbers_max + 1, 2)) 41 | for topic_numbers in tqdm(topics_list): 42 | lda_model = LdaModel(corpus=corpus, 43 | id2word=dictionary, 44 | num_topics=topic_numbers) 45 | # 计算主题模型的分数 46 | CM = CoherenceModel( 47 | model=lda_model, 48 | texts=data_comment_n, 49 | dictionary=dictionary, ) 50 | # 收集不同主题数下的一致性分数 51 | error_list.append(CM.get_coherence()) 52 | return error_list, topics_list 53 | def best_lda_trian(): 54 | # 使用 best_topic_numbers 作为主题数,其余参数均使用默认即可 55 | best_lda_model = LatentDirichletAllocation(n_components=best_topic_numbers) 56 | # 开始训练 LDA 模型 57 | best_lda_model.fit(n_comment_count_vec) 58 | # 设置每个主题下关联的主题词数量 59 | topic_words_numbers = 30 60 | # 获取所有的词典中的词语 61 | feature_names = n_count_vectorizer.get_feature_names() 62 | # 打印每个主题和附属的主题词 63 | for topic_idx, topic in enumerate(best_lda_model.components_): 64 | print("Topic # {}: ".format(int(topic_idx))) 65 | print(" ".join([feature_names[i] for i in topic.argsort()[:-topic_words_numbers - 1:-1]])) 66 | 67 | def topic_vis(): 68 | # 横坐标表示聚类点 69 | plt.xlabel('topic_number') 70 | # 纵坐标表示一致性分数 71 | plt.ylabel('coherence_score') 72 | # 对主题数进行标注 73 | plt.plot(topics_list, error_list, '*-') 74 | plt.show() 75 | 76 | if __name__ == '__main__': 77 | import pandas as pd 78 | data = pd.read_csv('data/xiecheng_ugc.csv') 79 | # 对用户评论进行名词标注 80 | data['comment_n'] = get_n_filter(data['content'].tolist()) 81 | data_comment_n = data['comment_n'].tolist() 82 | n_count_vectorizer = CountVectorizer(max_features=n_features) 83 | # 对用户评价中的名词进行字典转换 84 | n_comment_count_vec = n_count_vectorizer.fit_transform([str(i) for i in data_comment_n]) 85 | # 生成统计词典 86 | dictionary = Dictionary(data_comment_n) 87 | # 利用词典对生成每个词进行字典向量化 88 | corpus = [dictionary.doc2bow(text) for text in data_comment_n] 89 | # 开始搜素最佳主题数 90 | error_list, topics_list = topic_number_search() 91 | # 开始对主题数量进行可视化 92 | topic_vis() 93 | # 求得最大一致性分数所在的索引 94 | max_score_index = np.argmax(error_list) 95 | # 根据最大的值的索引找到最佳的主题数 96 | best_topic_numbers = topics_list[max_score_index] 97 | print('找到最佳的主题数为:{}'.format(best_topic_numbers)) 98 | # 使用找到的最佳主题数进行主题模型训练 99 | best_lda_trian() -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Project_Main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from sa_analysis import topic_sa_analysis 4 | import jieba.posseg as pseg 5 | from sa_model_train import model_train 6 | import multiprocessing 7 | from setting import * 8 | from tqdm import tqdm 9 | import os 10 | 11 | # 识别标点符号进行句子切分 12 | def doc2sentence(resource_text): 13 | # jieba 预热 14 | print(pseg.cut('预热')) 15 | with open(sentence_cut_path, 'w', encoding='utf-8') as sentence_cut: 16 | for sentence in tqdm(resource_text): 17 | if len(sentence.strip()) > 1: 18 | for word, flag in pseg.cut(sentence): 19 | if flag != 'x': 20 | sentence_cut.write(word) 21 | else: 22 | sentence_cut.write('\n') 23 | 24 | # 多线程主题句查询 25 | def find_topic_sentence(): 26 | if not os.path.exists(topic_path): 27 | os.mkdir(topic_path) 28 | task_split = [] 29 | for topic_n, key_words_list in topic_words_list.items(): 30 | task_split.append([topic_path, topic_n, key_words_list]) 31 | # task multiprocessing 32 | thread_number = len(topic_words_list.keys()) 33 | pool = multiprocessing.Pool(processes=thread_number) 34 | pool.map(find_key_txt, task_split) 35 | def find_key_txt(data_list): 36 | sentence_cut = open(sentence_cut_path, 'r', encoding='utf-8') 37 | with open('{}/{}.txt'.format(data_list[0], data_list[1]), 'w', encoding='utf-8') as key_txt: 38 | for sentence in sentence_cut.readlines(): 39 | for i in data_list[2]: 40 | if i in sentence: 41 | key_txt.write(sentence) 42 | # 关闭文件 43 | sentence_cut.close() 44 | print('{} 已经查找完成'.format(data_list[1])) 45 | 46 | if __name__ == '__main__': 47 | # 情感分析模型训练 48 | model_train() 49 | with open('data/text_resource.txt', 'r', encoding='utf-8') as resource_text: 50 | resource_text = resource_text.readlines() 51 | # 整句切分 52 | doc2sentence(resource_text) 53 | # 主题句查询 54 | find_topic_sentence() 55 | # 主题情感极性可视化 56 | topic_sa_analysis() 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu) 2 | #### Customer_satisfaction_Analysis 3 | 4 | [![Stargazers over time](https://starchart.cc/CarryChang/Customer_Satisfaction_Analysis.svg)](https://starchart.cc/CarryChang/Customer_Satisfaction_Analysis) 5 | 6 | ##### 结果整合 7 |
8 | 9 | ##### Demo 演示 10 | - [视频演示demo](https://github.com/CarryChang/C-CNN-for-Chinese-Sentiment-Analysis/blob/master/video/demo.mp4) 11 | - [详细步骤](https://www.lanqiao.cn/courses/2628) 12 | 13 | ##### 基于用户 UGC 的在线民宿满意度挖掘,负责数据采集、主题抽取、情感分析等任务。开发的目的是克服用户打分和评论不一致,实现了在线评论采集和用户满意度分析。 14 | 15 |
16 | 17 | ##### 主要功能包括在线原始评论采集、主题聚类、评论情感分析与结果可视化展示等四个模块,如下所示。 18 | 19 |
20 | 21 | 22 | >1. 提取后的民宿地址和在线评论等信息如下。 23 | 24 |
25 | 26 | >2. 搭建了百度地图 POI 查询入口,可以进行自动化的批量查询地理信息。 27 | 28 |
29 | 30 | > 3. 通过高频词可视化展示,归纳出评论主题。 31 | 32 |
33 |
34 | 35 | > 4. 构建了基于在线民宿语料的 LDA 自动化主题聚类模型,利用主题中心词能找出对应的主题属性字典,并使用用户打分作为标注,然后通过多种分类模型,选用最优模型对提出的评价主体 进行情感分析,针对主题属性表进行主题提取后的文本进行情感分析,分别得出当前主题对应的情感趋势,横坐标为所有关于主题为“环境”的情感得分,纵坐标为对应的情感的条数,可以起到纵观当前“环境”主题下的情感趋势,趋势往右代表当前主题评价较好,总共有{“交通”,“价格”,“体验”,“服务”,“特色”,“环境”,“设施”,“餐饮”}的主题,选取“环境”主题进行可视化之后的结果如下图所示。 36 | 37 |
38 |
39 |
40 | 41 | > 5. 通过POI热力图的方式对在线民宿满意度进行展示。 42 | 43 |
44 |
45 | 46 | > 6. 代码结构如下。 47 | 48 |
49 | 50 | ##### 专利信息 51 |
52 | 53 | 54 | ##### 新版本特性 55 | > 1. 使用 litNLP 深度情感推理 56 | > 2. 增加多进程提高多个 topic 下的文本匹配速度 57 | > 3. Project_Main.py 直接完成细粒度情感极性可视化操作 58 | -------------------------------------------------------------------------------- /commit_processing.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import jieba.posseg as pseg 3 | import multiprocessing 4 | from setting import * 5 | import os 6 | 7 | # 识别标点符号进行句子切分 8 | def doc2sentence(resource_text): 9 | with open(sentence_cut_path, 'w', encoding='utf-8') as sentence_cut: 10 | for sentence in resource_text: 11 | if len(sentence.strip()) > 1: 12 | for word, flag in pseg.cut(sentence): 13 | if flag != 'x': 14 | sentence_cut.write(word) 15 | else: 16 | sentence_cut.write('\n') 17 | 18 | # 多线程主题句查询 19 | def find_topic_sentence(): 20 | if not os.path.exists(topic_path): 21 | os.mkdir(topic_path) 22 | task_split = [] 23 | for topic_n, key_words_list in topic_words_list.items(): 24 | task_split.append([topic_path, topic_n, key_words_list]) 25 | # task multiprocessing 26 | thread_number = len(topic_words_list.keys()) 27 | pool = multiprocessing.Pool(processes=thread_number) 28 | pool.map(find_key_txt, task_split) 29 | 30 | def find_key_txt(data_list): 31 | sentence_cut = open(sentence_cut_path, 'r', encoding='utf-8') 32 | with open('{}/{}.txt'.format(data_list[0], data_list[1]), 'w', encoding='utf-8') as key_txt: 33 | for sentence in sentence_cut.readlines(): 34 | for i in data_list[2]: 35 | if i in sentence: 36 | key_txt.write(sentence) 37 | # 关闭文件 38 | sentence_cut.close() 39 | print('{} 已经查找完成'.format(data_list[1])) -------------------------------------------------------------------------------- /data/geo_data.csv: -------------------------------------------------------------------------------- 1 | name,address,score,comment_number,price,location 2 | 林木森驿站(重庆北碚步行街中心店),北碚区胜利街1号附13号,近北碚地铁终点站2号出口。 ,4.4,188,224,北碚区 3 | 重庆如家客栈,璧山区镇政府保利电影院楼上4楼,近广场大厦。 ,3.9,40,78,北碚区 4 | 重庆颂棠别院,大足区佛都大道216号昌州古城14号楼C05,近676县道。 ,4.6,419,129,大足区 5 | 奉节依斗门客栈,奉节诗城东路131号,近诗城博物馆。 ,4.6,91,142,奉节县 6 | 重庆武陵山枳人客栈,涪陵区武陵山大裂谷景区,近武陵山森林公园。 ,4.8,153,376,涪陵区 7 | 重庆般若静舍客栈,江北区江北农场宏帆路星辰苑,近北滨路。 ,4.6,562,190,江北区 8 | 重庆镜域旅游俱乐部酒店,江北区观音桥朗晴广场A塔29楼,近观音桥步行街。 ,4.7,402,166,江北区 9 | 重庆明然玥客栈,江北区观音桥北城天街35号同创国际商业街4楼,九街高屋对面,近洋河路。 ,4.6,875,242,江北区 10 | 重庆瓦舍美宿客栈,江北区观音桥红鼎国际B座2单元17楼1711,近建新北路。 ,4.8,115,248,江北区 11 | 重庆四面山龙腾客栈,江津区重庆市 江津区 四面山镇龙潭路(家园超市斜对面)。 ,3.8,65,145,江津区 12 | 重庆四面山天然居山庄,江津区四面山洪洞村一社(江津区,近四面山派出所) ,4.3,46,125,江津区 13 | 重庆香山农庄,江津区四面山风景区大洪湖景点停车场旁,大洪湖码头旁。 ,4.8,93,190,江津区 14 | 重庆倦鸟驿站,开州区滨湖中段7号商务楼,无。 ,4.6,80,292,开州区 15 | 梁平平野园林大酒店,梁平区梁山街道八角村,近梁平机场、机场环线。 ,4.7,141,188,梁平区 16 | 重庆和悦庄客栈,南岸区南坪西路68号,近花园路。 ,4.8,389,439,南岸区 17 | 重庆江涛客栈,南岸区南坪东路31号二楼,女子医院斜对面。 ,3.2,135,30,南岸区 18 | 重庆尚玉客栈,南岸区学府大道323号,近工商大学。 ,3.9,61,57,南岸区 19 | 重庆隐约南山客栈,南岸区重庆南岸区南山抗战遗址博物馆旁南山公园路1号。 ,4.0,43,372,南岸区 20 | 重庆阿川雅阁风情客栈,南川区金佛山西坡三汇场,近卫生院二分院。 ,4.1,71,134,南川区 21 | 重庆金佛山9号客栈,南川区金佛山西坡天星小镇9号楼,近天星小镇游客服务中心。 ,3.9,59,138,南川区 22 | 重庆金佛山小桥流水人家客栈,南川区金佛山西坡三汇场,近石林村。 ,4.4,158,209,南川区 23 | 重庆金佛山印象天星风情客栈,南川区天星小镇,近金佛山西大门。 ,4.1,51,181,南川区 24 | 重庆美都驿栈,南川区金佛山西坡三汇场,近金佛山西大门。 ,4.2,107,188,南川区 25 | 重庆乡土风情客栈,南川区金佛山西坡三汇场,近金佛山西大门。 ,4.1,55,89,南川区 26 | 重庆鑫源居客栈,南川区金佛山西坡三汇场三汇路89号,近金佛山西大门。 ,4.6,113,143,南川区 27 | 彭水阿依河山庄,彭水阿依河景区大门旁,近阿依河社区。 ,3.4,94,143,彭水苗族土家族自治县 28 | 重庆黑山千缘客栈,綦江区万盛经开区黑山旅游景区北门接待中心紫薇5路5栋,近414省道。 ,4.7,67,113,綦江区 29 | 重庆黑山小筑客栈,綦江区万盛经开区黑山谷南大门售票厅旁,黑山谷南门。 ,4.0,63,238,綦江区 30 | 重庆山谷人家农家乐,綦江区黑山谷商业购物街B栋,近黑山谷售票处。 ,4.0,46,168,綦江区 31 | 重庆万盛黑山谷南门秀容宾馆,綦江区万盛江流西路31号,近414省道。 ,3.1,34,76,綦江区 32 | 重庆诚悦庄客栈,黔江区濯水镇濯水居委五组4幢龚家大院内,近镇政府。 ,4.6,108,196,黔江区 33 | 重庆蹲趴背包客栈,沙坪坝区天陈路二号世源大厦,近三峡广场步行街。 ,4.5,338,36,沙坪坝区 34 | 嘉古院客栈(重庆磁器口古镇店),沙坪坝区磁器口古镇横街16号,近动感影院。 ,3.3,458,171,沙坪坝区 35 | 重庆U城客栈,沙坪坝区大学城北路94号U城天街。 ,4.6,106,80,沙坪坝区 36 | 重庆七号花园客栈,九龙坡区香榭丽街半山七号(九龙坡区,近烟灯山公园) ,4.8,49,133,沙坪坝区 37 | 重庆融汇泉·别院,沙坪坝区梨树湾融汇温泉城汇泉路6号,近融汇温泉。 ,4.8,406,1614,沙坪坝区 38 | 重庆世茂客栈,沙坪坝区磁器口正街88号,近磁童路。 ,4.3,164,133,沙坪坝区 39 | 石柱黄水水云间客栈,石柱黄水莼乡路285号27幢1-1(石柱,近黄水景区) ,4.7,37,780,石柱土家族自治县 40 | 石柱小鸟金山客栈,石柱南宾镇人民街(石柱,近玉带北街) ,2.0,51,107,石柱土家族自治县 41 | 重庆安居古城南大门客栈,铜梁区安居古城南大门(铜梁区,近古城游客接待中心) ,4.3,46,116,铜梁区 42 | 重庆锦鸿客栈,铜梁区安居镇兴隆街164号1-1(铜梁区,安居古城接待中心对面) ,3.7,32,97,铜梁区 43 | 重庆青居别苑,铜梁区安居古城西街1号(铜梁区,近城隍庙) ,4.6,230,257,铜梁区 44 | 重庆青风客栈,九龙坡区石新路178号沛鑫汽配城综合楼4楼,近四季香山小区大门、东风起亚。 ,4.3,96,74,万州区 45 | 重庆三峡行客栈,万州区沙龙路二段230号,近科兴苑、宏远批发市场。 ,4.8,34,39,万州区 46 | 途涂客栈(武隆仙女山店),武隆仙女山镇翠云路62号,近武隆县游客接待中心。 ,4.7,285,266,武隆区 47 | 武隆丛林精品客栈,武隆仙女山镇黄鹏河大峡谷,近038乡道。 ,4.3,57,587,武隆区 48 | 武隆多来福客栈,武隆巷口镇芙蓉中路86号2幢3楼,近白杨路。 ,4.7,327,68,武隆区 49 | 武隆观景客栈,武隆仙女山镇游客中心背后,近天秀仙居。 ,4.4,378,119,武隆区 50 | 武隆郡临仙山农家乐,武隆仙女山新区翠云路8号,距离游客接待中心旁500米。 ,4.1,98,53,武隆区 51 | 武隆强兴客栈,武隆巷口镇芙蓉中路71号2幢12楼汽车站对面,武隆汽车站对面。 ,4.5,107,80,武隆区 52 | 武隆仙乐客栈,武隆仙女山镇逸云路39号,近市民公园。 ,3.1,62,62,武隆区 53 | 武隆仙女山陌陌客栈,武隆仙女山镇银杏大道35号附1号,近203省道。 ,4.7,284,188,武隆区 54 | 武隆闲暇农家乐,武隆仙女镇银杏大道,近游客接待中心。 ,3.9,97,100,武隆区 55 | 武隆再回首农家乐,武隆天生三桥景区。 ,4.6,63,107,武隆区 56 | 仙女山菩镜丘客栈,武隆仙女镇夜宴仙女山7-3-1,近翠云路。 ,4.9,33,559,武隆区 57 | 闲暇空间连锁客栈(武隆分店),武隆仙女山镇翠云路68号,近七星环路。 ,4.8,1314,256,武隆区 58 | 重庆武隆仙女山之间堂客栈,武隆仙女山镇步云路6号,近大槽。 ,4.7,88,930,武隆区 59 | 重庆市秀山茶峒摄影民宿,秀山洪安镇老街3号,近万年台对面。 ,4.8,137,138,秀山土家族苗族自治县 60 | 酉阳东篱苑客栈,酉阳桃花源镇酉州古城第29栋(酉阳,近桃花源景区) ,4.3,86,152,酉阳土家族苗族自治县 61 | 酉阳龚滩古镇巴适客栈,酉阳龚滩镇新华社区(酉阳) ,4.1,36,96,酉阳土家族苗族自治县 62 | 酉阳龚滩古镇老院子客栈,酉阳龚滩古镇内知珍里街(酉阳) ,4.5,109,98,酉阳土家族苗族自治县 63 | 酉阳龚滩古镇唐街客栈,酉阳龚滩古镇内(酉阳) ,4.3,245,100,酉阳土家族苗族自治县 64 | 酉阳龚滩秀景精品客栈,酉阳龚滩古镇景区内(酉阳,近古镇中心小广场) ,4.8,69,90,酉阳土家族苗族自治县 65 | 酉阳上林风情客栈,酉阳酉州古城32号(酉阳,近桃花源景区) ,4.3,147,146,酉阳土家族苗族自治县 66 | 酉阳水泊人家客栈,酉阳龚滩古镇南门停车场入口第一家店作坊路5号(酉阳,近龚滩镇小学) ,4.4,158,128,酉阳土家族苗族自治县 67 | 酉阳酉州古城爱晚庭客栈,酉阳酉州古城31号(酉阳,近桃花源景区) ,4.3,294,134,酉阳土家族苗族自治县 68 | 重庆酉阳龚滩古镇小滩子客栈,酉阳龚滩古镇B区入口南门停车场旁(酉阳) ,3.5,79,90,酉阳土家族苗族自治县 69 | 重庆酉阳归园田居客栈,酉阳酉州古城北门1—B号(酉阳,近210省道) ,3.8,82,116,酉阳土家族苗族自治县 70 | 加州客栈(重庆红琦店),渝北区红石路241号,近江北大浪淘沙。 ,4.3,296,199,渝北区 71 | 重庆2008金桥龙兴古镇客栈,渝北区龙兴镇天龙路59号,近华夏宗祠。 ,3.9,77,107,渝北区 72 | 重庆巴渝客栈,渝北区两江新区金兴大道龙景路1号(园博园正门),近园博园游船售票厅,悦来会展中心。 ,4.6,151,419,渝北区 73 | 重庆倦鸟驿栈,渝北区北部新区黄山大道金科中华坊三号商务楼,近高科体育中心。 ,4.6,325,368,渝北区 74 | 重庆六号花园客栈,渝北区颐泰园D栋2单元1-2,近凯歌路与双湖路交叉口。 ,4.5,81,51,渝北区 75 | 重庆隆门驿客栈,渝北区双凤桥街道长空路144号,近桃园公园。 ,4.7,468,89,渝北区 76 | 重庆慢时光客栈,渝北区玫瑰城绣色锦衣星辰37栋,近南方翻译学院。 ,4.7,136,72,渝北区 77 | 重庆青风客栈悦来会展中心店,渝北区滨江路84号附1-4号,近悦来会展中心。 ,4.2,213,201,渝北区 78 | 重庆渝州情客栈,渝北区红锦大道21号加来金大厦9-11层,近近轨道3号线红旗河沟站、金龙路。 ,4.3,92,114,渝北区 79 | 重庆·重玖玖客栈,渝中区八一路好吃街218号19楼,近轨道交通1号线、2号线。 ,4.3,353,238,渝中区 80 | 重庆临江客栈,渝中区西来寺36号(一号桥与魁星楼之间),近临江门1号桥华仁医院。 ,4.2,602,118,渝中区 81 | 重庆龙猫客栈,渝中区解放碑五一路9号帝都广场B栋35-14(王府井百货对面),近八一路右侧。 ,4.6,308,30,渝中区 82 | 重庆南旅艺术客栈,渝中区重庆渝中区长滨路19号海客瀛洲B栋4-8(朝天门码头)。 ,4.8,61,175,渝中区 83 | 重庆能仁客栈,渝中区重庆渝中区解放碑好吃街对面布丁酒店旁1楼。 ,4.0,39,143,渝中区 84 | 重庆弱水咖啡客栈,渝中区大溪沟河街66号,近嘉陵江滨江路。 ,4.7,82,50,渝中区 85 | 重庆缘宿江景客栈,渝中区海客瀛州C栋1007接待处,近长江滨江路。 ,4.7,49,288,渝中区 86 | 重庆源财客栈,渝中区较场口四贤巷30号青鸟大厦3楼,近民生路。 ,3.3,50,136,渝中区 87 | 云阳龙缸湘圆农家乐,云阳龙缸景区(云阳,近民俗天街) ,4.2,43,90,云阳县 88 | 重庆建宏客栈,长寿区长寿古镇万寿南路A区37栋,近米寿东街。 ,4.0,113,85,长寿区 89 | 重庆御临客栈,长寿区长寿古镇C区2-1-2,近竹园。 ,4.0,45,161,长寿区 90 | 重庆长寿古镇秦彩格客栈,长寿区长寿古镇桃园西四路1号105幢1-1,近万寿广场。 ,4.4,110,179,长寿区 91 | -------------------------------------------------------------------------------- /model_saved/init.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @USER: CarryChang -------------------------------------------------------------------------------- /pic/gaopin1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/gaopin1.png -------------------------------------------------------------------------------- /pic/ip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/ip.png -------------------------------------------------------------------------------- /pic/lda_topic_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/lda_topic_select.png -------------------------------------------------------------------------------- /pic/lda_topic_select1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/lda_topic_select1.png -------------------------------------------------------------------------------- /pic/poi可视化.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/poi可视化.png -------------------------------------------------------------------------------- /pic/poi打分.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/poi打分.png -------------------------------------------------------------------------------- /pic/不一致.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/不一致.png -------------------------------------------------------------------------------- /pic/主题.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/主题.png -------------------------------------------------------------------------------- /pic/各主题分数.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/各主题分数.png -------------------------------------------------------------------------------- /pic/地址.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/地址.png -------------------------------------------------------------------------------- /pic/情感分析图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/情感分析图.png -------------------------------------------------------------------------------- /pic/数据库.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/数据库.png -------------------------------------------------------------------------------- /pic/文本分类.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/文本分类.png -------------------------------------------------------------------------------- /pic/模型对比.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/模型对比.png -------------------------------------------------------------------------------- /pic/模型对比2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/模型对比2.png -------------------------------------------------------------------------------- /pic/流程.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/流程.png -------------------------------------------------------------------------------- /pic/结构1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/结构1.png -------------------------------------------------------------------------------- /pic/高频2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarryChang/Customer_Satisfaction_Analysis/c1ebfc056dbad05ced1ea9e1754b38aa2e627c59/pic/高频2.png -------------------------------------------------------------------------------- /requirement.txt: -------------------------------------------------------------------------------- 1 | tensorflow==2.0.1 2 | litNlp==0.8.4 3 | pyLDAvis==2.1.2 4 | scikit-learn==0.22.1 5 | numpy 6 | pandas 7 | jieba 8 | tqdm -------------------------------------------------------------------------------- /sa_analysis.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from litNlp.predict import SA_Model_Predict 3 | import matplotlib.pyplot as plt 4 | from setting import * 5 | import numpy as np 6 | import os 7 | plt.rcParams['font.sans-serif'] = ['SimHei'] 8 | plt.rcParams['axes.unicode_minus'] = False 9 | 10 | def topic_sa_analysis(): 11 | sa_model = SA_Model_Predict(tokenize_path, sa_model_path_m, max_len=100) 12 | if not os.path.exists(topic_emotion_pic): 13 | os.mkdir(topic_emotion_pic) 14 | print(topic_emotion_pic+'文件夹已经建立,请查看当前文件路径') 15 | for key_word in topic_words_list.keys(): 16 | sa_analysis_(key_word, sa_model) 17 | 18 | def sa_analysis_(key_word, sa_model): 19 | print('{} 正在执行...'.format(key_word)) 20 | key_txt = open('{}/{}.txt'.format(topic_path, key_word), 'r', encoding='utf-8').readlines() 21 | sentiments_score_predict = sa_model.predict(key_txt) 22 | # 情感极性输出 23 | sentiments_score_list = [i[1] for i in sentiments_score_predict] 24 | plt.hist(sentiments_score_list, bins=np.arange(0, 1, 0.01)) 25 | plt.xlabel("情感值") 26 | plt.ylabel("评论数目") 27 | plt.title(key_word+'-情感极性分布图') 28 | plt.savefig('{}/{}.png'.format(topic_emotion_pic, key_word)) 29 | plt.show() 30 | plt.close() 31 | print('{} 情感极性图完成'.format(key_word)) 32 | 33 | # if __name__ == '__main__': 34 | # # 添加多线程提升预测速度 35 | # topic_sa_analysis() 36 | -------------------------------------------------------------------------------- /sa_model_predict.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from litNlp.predict import SA_Model_Predict 3 | 4 | def model_predict(): 5 | model = SA_Model_Predict(tokenize_path, sa_model_path_m, max_len=100) 6 | sa_score = model.predict(predict_text) 7 | # 情感极性输出 8 | print([i[1] for i in sa_score]) 9 | 10 | if __name__ == '__main__': 11 | # load conf 12 | from setting import * 13 | # example 14 | predict_text = ['这个我不喜欢', '这个我喜欢不'] 15 | model_predict() 16 | -------------------------------------------------------------------------------- /sa_model_train.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pandas as pd 3 | from litNlp.train import SA_Model_Train 4 | # load conf 5 | from setting import * 6 | 7 | def model_train(): 8 | # data load 9 | train_data = pd.read_csv('data/label_comment.csv') 10 | # data process 11 | train_data['text_cut'] = train_data['text'].apply(lambda x: " ".join(list(x))) 12 | # train: evaluate 默认在训练完毕之后开启计算 13 | label = train_data['label'] 14 | train_data = train_data['text_cut'] 15 | # model load 16 | model = SA_Model_Train(max_words, embedding_dim, maxlen, tokenize_path, sa_model_path_m, train_method) 17 | # 模型训练 18 | model.train(train_data, label, num_classes=2, batch_size=256, epochs=2, verbose=1, evaluate=True) 19 | print('深度情感分析模型训练完毕') 20 | 21 | # if __name__ == '__main__': 22 | # # run model trian 23 | # model_train() -------------------------------------------------------------------------------- /setting.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @USER: CarryChang 3 | 4 | # 设置词典大小为 n_features 5 | n_features = 3000 6 | 7 | # 存储断句的文件夹 8 | sentence_cut_path = 'data/sentence_cut.txt' 9 | 10 | # 主题句文件夹 11 | topic_path = 'topic_text' 12 | 13 | # 基于字典的查找 14 | topic_words_list = { 15 | '环境': {'环境', '周边', '风景', '空气', '江景', '小区', '景点', '夜景', '街', '周围', '景区', '声音', '景色'}, 16 | '价格': {'价格', '房价', '性价比', '价位', '单价', '价钱'}, 17 | '特色': {'特色', '装潢', '布置', '建筑', '结构', '格调', '装修', '设计', '风格', '隔音'}, 18 | '设施': {'设施', '设备', '条件', '硬件', '房间', '热水', '马桶', '电梯', '阳台', '卫生间', '洗手间', '空调', '被子', '床', '大厅', '电话', '电', '摆设'}, 19 | '餐饮': {'餐饮', '早餐', '咖啡', '味道', '饭', '菜', '水果', '特产', '餐', '美食', '烧烤', '宵夜', '食材', '饭馆', '小吃'}, 20 | '交通': {'交通', '车程', '地段', '路程', '停车', '机场', '离', '车站', '地理', '位置', '地理', '中心', '海拔', '码头'}, 21 | '服务': {'服务', '态度', '前台', '服务员', '老板', '掌柜', '店家', '工作人员'}, 22 | '体验': {'体验', '整体', '感觉'}, 23 | } 24 | 25 | # 存储情感极性的图 26 | topic_emotion_pic = 'topic_emotion_pic' 27 | 28 | # 最大句子长度 29 | maxlen = 100 30 | 31 | # 最大的tokenizer字典长度 32 | max_words = 1000 33 | 34 | # 设置embedding大小 35 | embedding_dim = 300 36 | 37 | # train_method : 模型训练方式,默认 textcnn,可选:bilstm , gru 38 | train_method = 'textcnn' 39 | 40 | # 模型的保存位置,后续用于推理 41 | sa_model_path_m = 'model_saved/model.h5' 42 | 43 | # 离线保存tokenizer 44 | tokenize_path = 'model_saved/tokenizer.pickle' --------------------------------------------------------------------------------