当前位置:首页 » 行情解析 » python股票情感分析
扩展阅读
金世旗国际控股股票代码 2025-07-10 03:16:51
派生科技的股票成交量 2025-07-10 02:43:34
五粮YGC1的股票代码 2025-07-10 02:39:57

python股票情感分析

发布时间: 2021-06-29 23:05:49

① 用python做情感分析是text processing是自己搜集的数据吗

提供了一组操作协议接口,主要用于规定采用哪种协议进行数据的读写,它内部包含一个传输类(TTransport)成员对象,通过TTransport对象从输入输出流中读写数据;
它规定了很多读写方式,例如:
readByte()
readDouble()
readString()

② 怎样用python处理文本情感分析

Python 有良好的程序包可以进行情感分类,那就是Python 自然语言处理包,Natural Language Toolkit ,简称NLTK 。NLTK 当然不只是处理情感分析,NLTK 有着整套自然语言处理的工具,从分词到实体识别,从情感分类到句法分析,完整而丰富,功能强大。

③ 如何使用python做中文情感分析

pip install snownlppip install -U
textblobpython -m textblob.download_corpora

④ 如何用python 做 情感分析

这句话应该不是说你feature太多了,而是说for循环中,使用了两个变量去unpack featuresets太多了。所以应该是你的数据结构有问题,featuresets可能不是适合两个变量来解包的数据结构,或者中文编码有问题。

⑤ 如何用Python做情感分析

可以使用snownlp包,也可以用nltk 和 scikit-learn 结合,或者自己写算法实现。
简单话就是情感词典的匹配,想提高效果的需要考虑特征之间的搭配,语法顺序等,可以查询搜索相关的入门例子和算法详细了解。

⑥ 用python对中文做情感分析,有没有好的接口推荐

import jieba
import numpy as np

# 打开词典文件,返回列表
def open_dict(Dict='hahah',path = r'/Users/zhangzhenghai/Downloads/Textming/'):
path = path + '%s.txt' %Dict
dictionary = open(path, 'r', encoding='utf-8')
dict = []
for word in dictionary:
word = word.strip('\n')
dict.append(word)
return dict

def judgeodd(num):
if num % 2 == 0:
return 'even'
else:
return 'odd'

deny_word = open_dict(Dict='否定词')
posdict = open_dict(Dict='positive')
negdict = open_dict(Dict = 'negative')

degree_word = open_dict(Dict = '程度级别词语',path=r'/Users/zhangzhenghai/Downloads/Textming/')
mostdict = degree_word[degree_word.index('extreme')+1: degree_word.index('very')] #权重4,即在情感前乘以3
verydict = degree_word[degree_word.index('very')+1: degree_word.index('more')] #权重3
moredict = degree_word[degree_word.index('more')+1: degree_word.index('ish')]#权重2
ishdict = degree_word[degree_word.index('ish')+1: degree_word.index('last')]#权重0.5

def sentiment_score_list(dataset):
seg_sentence = dataset.split('。')

count1 = []
count2 = []
for sen in seg_sentence: # 循环遍历每一个评论
segtmp = jieba.lcut(sen, cut_all=False) # 把句子进行分词,以列表的形式返回
i = 0 #记录扫描到的词的位置
a = 0 #记录情感词的位置
poscount = 0 # 积极词的第一次分值
poscount2 = 0 # 积极反转后的分值
poscount3 = 0 # 积极词的最后分值(包括叹号的分值)
negcount = 0
negcount2 = 0
negcount3 = 0
for word in segtmp:
if word in posdict: # 判断词语是否是情感词
poscount +=1
c = 0
for w in segtmp[a:i]: # 扫描情感词前的程度词
if w in mostdict:
poscount *= 4.0
elif w in verydict:
poscount *= 3.0
elif w in moredict:
poscount *= 2.0
elif w in ishdict:
poscount *= 0.5
elif w in deny_word: c+= 1
if judgeodd(c) == 'odd': # 扫描情感词前的否定词数
poscount *= -1.0
poscount2 += poscount
poscount = 0
poscount3 = poscount + poscount2 + poscount3
poscount2 = 0
else:
poscount3 = poscount + poscount2 + poscount3
poscount = 0
a = i+1
elif word in negdict: # 消极情感的分析,与上面一致
negcount += 1
d = 0
for w in segtmp[a:i]:
if w in mostdict:
negcount *= 4.0
elif w in verydict:
negcount *= 3.0
elif w in moredict:
negcount *= 2.0
elif w in ishdict:
negcount *= 0.5
elif w in degree_word:
d += 1
if judgeodd(d) == 'odd':
negcount *= -1.0
negcount2 += negcount
negcount = 0
negcount3 = negcount + negcount2 + negcount3
negcount2 = 0
else:
negcount3 = negcount + negcount2 + negcount3
negcount = 0
a = i + 1
elif word == '!' or word == '!': # 判断句子是否有感叹号
for w2 in segtmp[::-1]: # 扫描感叹号前的情感词,发现后权值+2,然后退出循环
if w2 in posdict or negdict:
poscount3 += 2
negcount3 += 2
break
i += 1

# 以下是防止出现负数的情况
pos_count = 0
neg_count = 0
if poscount3 <0 and negcount3 > 0:
neg_count += negcount3 - poscount3
pos_count = 0
elif negcount3 <0 and poscount3 > 0:
pos_count = poscount3 - negcount3
neg_count = 0
elif poscount3 <0 and negcount3 < 0:
neg_count = -pos_count
pos_count = -neg_count
else:
pos_count = poscount3
neg_count = negcount3
count1.append([pos_count,neg_count])
count2.append(count1)
count1=[]

return count2

def sentiment_score(senti_score_list):
score = []
for review in senti_score_list:
score_array = np.array(review)
Pos = np.sum(score_array[:,0])
Neg = np.sum(score_array[:,1])
AvgPos = np.mean(score_array[:,0])
AvgPos = float('%.lf' % AvgPos)
AvgNeg = np.mean(score_array[:, 1])
AvgNeg = float('%.1f' % AvgNeg)
StdPos = np.std(score_array[:, 0])
StdPos = float('%.1f' % StdPos)
StdNeg = np.std(score_array[:, 1])
StdNeg = float('%.1f' % StdNeg)
score.append([Pos,Neg,AvgPos,AvgNeg,StdPos,StdNeg])
return score

data = '用了几天又来评价的,手机一点也不卡,玩荣耀的什么的不是问题,充电快,电池够大,玩游戏可以玩几个小时,待机应该可以两三天吧,很赞'
data2 = '不知道怎么讲,真心不怎么喜欢,通话时声音小,新手机来电话竟然卡住了接不了,原本打算退,刚刚手机摔了,又退不了,感觉不会再爱,像素不知道是我不懂还是怎么滴 感觉还没z11mini好,哎要我怎么评价 要我如何喜欢努比亚 太失望了'

print(sentiment_score(sentiment_score_list(data)))
print(sentiment_score(sentiment_score_list(data2)))

⑦ 用python找文献,并从文本中分析情绪,做一个数据分析

到你的系统“终端”(macOS, Linux)或者“命令提示符”(Windows)下,进入我们的工作目录demo,执行以下命令。
pip install snownlppip install -U textblobpython -m textblob.download_corpora

好了,至此你的情感分析运行环境已经配置完毕。
在终端或者命令提示符下键入:
jupyter notebook

你会看到目录里之前的那些文件,忽略他们就好。

⑧ 利用python爬虫技术可以做到哪些炫酷有趣的事

用python爬虫爬取股票公司网站数据,做短线买股票会提高你买入和抛售的判断。

⑨ 怎样用python实现SVM分类器,用于情感分析的二分类

这句话应该不是说你feature太多了,而是说for循环中,使用了两个变量去unpackfeaturesets太多了。所以应该是你的数据结构有问题,featuresets可能不是适合两个变量来解包的数据结构,或者中文编码有问题。

⑩ python情感分析

可以使用snownlp包,也可以用nltk

scikit-learn
结合,或者自己写算法实现。
简单话就是情感词典的匹配,想提高效果的需要考虑特征之间的搭配,语法顺序等,可以查询搜索相关的入门例子和算法详细了解。