赞
踩
第一个snownlp :
# pip install snownlp -i https://mirror.baidu.com/pypi/simple from snownlp import SnowNLP text="大牛市来啦,发财啦" nlp=SnowNLP(text) print(nlp.sentiments)
第二个 paddlehub:
会有很多包搭配的问题:
- #https://blog.csdn.net/u010751000/article/details/106747421?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0-106747421-blog-120609993.pc_relevant_blogantidownloadv1&spm=1001.2101.3001.4242.1&utm_relevant_index=2
- # from snownlp import SnowNLP
- # text="大牛市来啦,发财啦"
- # nlp=SnowNLP(text)
- # print(nlp.sentiments)
- # pip install paddlehub==1.8.0 -i https://mirror.baidu.com/pypi/simple
- # pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
- # pip install protobuf==3.20.1 -i https://mirror.baidu.com/pypi/simple
- # pip install opencv-contrib-python -i https://mirror.baidu.com/pypi/simple
- # python -m pip install -U pip -i https://mirror.baidu.com/pypi/simple
- import paddlehub as hub
- import paddlehub as hub
- # 加载模型
- senta = hub.Module(name="senta_lstm")
- # 待分类文本
- test_text = [
- "三百多块比亚迪一股分红一毛,四百多的宁王分二毛呵呵这就是成长性",
- "刘背离死叉",
- "牛市来了",
- "$上证指数(SH000001)$主力这几天紧张、小心的计划割韭菜!小散们马上清仓",
- "散户明摆着被洗了一把,还没察觉呢,早盘低开回踩一"
- ]
- # 情感分类
- results = senta.sentiment_classify(data={"text": test_text})
- # 得到结果
- for result in results:
- print(result)
-
具体的包的 配置:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。