哈工大情感词典怎么下载
时间: 2023-09-14 21:10:39 浏览: 172
可以通过以下步骤从哈工大社会计算与信息检索研究中心下载哈工大情感词典:
1. 访问哈工大社会计算与信息检索研究中心的官网:http://ir.hit.edu.cn/~nlpir/。
2. 点击页面中的“资源下载”链接,进入资源下载页面。
3. 在资源下载页面中,找到“情感分析词典”一栏,选择需要下载的版本和格式(如GBK版或UTF-8版),并点击下载链接。
4. 下载完成后,解压缩文件,即可获得情感词典文件,文件名为“情感词汇表.txt”。
需要注意的是,哈工大情感词典的版权属于哈尔滨工业大学社会计算与信息检索研究中心,并仅供学术研究和非商业用途使用。在使用哈工大情感词典时,需要注明出处和版权信息。
相关问题
如何通过构建哈工大情感词典进行中文情感分析
哈工大情感词典是一个常用的中文情感词典,可以用于中文情感分析。下面是基于哈工大情感词典的中文情感分析的步骤:
1. 下载哈工大情感词典,可以在官网上下载或者用Python库进行下载:
```python
import urllib.request
url = 'https://github.com/ysc/graduation-project/blob/master/ChnSentiCorp_htl_ba_6000.txt?raw=true'
urllib.request.urlretrieve(url, 'Hownet.txt')
```
2. 加载情感词典,将词典中的词语和情感值存储到字典中:
```python
def load_dict():
sentiment_dict = {}
with open('Hownet.txt', 'r', encoding='utf-8') as f:
for line in f.readlines():
line = line.strip()
if line:
word, sentiment = line.split('\t')
sentiment_dict[word] = sentiment
return sentiment_dict
sentiment_dict = load_dict()
```
3. 对中文文本进行分词和情感分类,可以使用Python中的分词库jieba和Python中的字典:
```python
import jieba
def chinese_sentiment_analysis(text):
seg_list = jieba.cut(text)
words_list = list(seg_list)
positive_score = 0
negative_score = 0
for word in words_list:
if word in sentiment_dict:
sentiment = sentiment_dict[word]
if sentiment == 'positive':
positive_score += 1
elif sentiment == 'negative':
negative_score += 1
if positive_score > negative_score:
return 'positive'
elif positive_score < negative_score:
return 'negative'
else:
return 'neutral'
```
4. 测试代码:
```python
text = '这家餐厅的菜很好吃,服务也很周到。'
sentiment = chinese_sentiment_analysis(text)
print(sentiment) # positive
```
上述代码仅仅是一个简单的示例,实际应用中可能需要根据具体情况进行修改和优化。
综合情感词典在哪里下载
综合情感词典可以在以下网站下载:
1. 哈工大社会计算与信息检索研究中心:http://ir.hit.edu.cn/~nlpir/download/%E6%83%85%E6%84%9F%E8%AF%8D%E5%85%B8%E5%8C%85%E4%B8%8B%E8%BD%BD.html
2. 中文情感词汇本体:https://www.pubyun.com/resources.html
3. 情感词典大全:https://www.jianshu.com/p/8c7f3e5c6d7f
需要注意的是,不同的情感词典可能有不同的使用方法和适用场景,请根据具体需求选择使用。