We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SnowNLP(u'一直用苹果的老粉。用了几天真实评价,买正品国行必须来这家。客服和物流都相当满意。快递小哥当面喊拆封无任何问题才离开。空气塑料包装,安全可靠。话不多说,实拍图鉴赏').sentiments 得分:0.020775001949364325
The text was updated successfully, but these errors were encountered:
可能需要训练集自己训练了,作者的训练结果集很局限
Sorry, something went wrong.
自定义训练吧,把词拆开自己标注词性后再训练试试
看看我的:
from snownlp import SnowNLP # # 示例中文文本 # texts = [ # "这部电影真是太棒了,我非常喜欢!", # "今天的天气很糟糕,心情不好。", # "这个产品质量一般,没有想象中好。", # "服务态度非常好,下次还会再来。", # "下次还会再来,服务态度非常差差差差," # ] # for text in texts: # s = SnowNLP(text) # sentiment = s.sentiments # 返回一个0到1之间的浮点数,越接近1表示情感越正面 # print(f"文本: {text}\n情感得分: {sentiment:.2f}\n") def sentiment_analysis(text): # 使用SnowNLP对中文文本进行情感分析 s = SnowNLP(text) # SnowNLP的sentiments方法返回情感倾向分数,越接近1表明情感越积极,越接近0表明情感越消极 sentiment_score = s.sentiments return sentiment_score text = "角色塑造太单调,毫无震撼力!" score = sentiment_analysis(text) print(f"情感分数: {score}") if score > 0.5: print("该语句是积极的。") else: print("该语句是消极的。")
$ python test_snownlp.py 情感分数: 0.8197750666409178 该语句是积极的。
No branches or pull requests
用的0.12.3版本,分析了3条语句,语句及得分如下,这三条分析结果都不太准,第一条结果还算靠谱,第二条得分明显偏高,第三条低的离谱。
SnowNLP(u'质量还行,要是能再送个小礼品就更好了。').sentiments
得分:0.725280484790826
SnowNLP(u'用了一天,先说今天的感受。手机外观没问题,流畅,两三年没用苹果了还在熟悉回来。然后是拍照,我懒得拿以前的苹果出来对比,对比了手里的fingx,真实不黄。今天一天电池续航挺好的,到手后又充了百分之二三十,然后熬到晚上十点。屏幕的话,把原彩关了,就是正常颜色,不显黄。但是!!!我想吐槽这个信号,是真差,嗯非常差,暂时只有这个想吐槽,信号永远不满格。是F开头,国行。').sentiments
得分:0.8826779192350063
SnowNLP(u'一直用苹果的老粉。用了几天真实评价,买正品国行必须来这家。客服和物流都相当满意。快递小哥当面喊拆封无任何问题才离开。空气塑料包装,安全可靠。话不多说,实拍图鉴赏').sentiments
得分:0.020775001949364325
The text was updated successfully, but these errors were encountered: