概述
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import paddlehub as hub
In [2]: senta = hub.Module(name="senta_bilstm")
2019-07-06 22:33:01,181-INFO: Installing senta_bilstm module
2019-07-06 22:33:01,182-INFO: Module senta_bilstm already installed in /home/textminer/.paddlehub/modules/senta_bilstm
In [3]: test_text = ["这家餐厅很好吃", "这部电影真的很差劲","我爱自然语言处理"]
In [4]: input_dict = {"text": test_text}
In [5]: results = senta.sentiment_classify(data=input_dict)
2019-07-06 22:33:53,835-INFO: 13 pretrained paramaters loaded by PaddleHub
2019-07-06 22:33:53,839-INFO: 20 pretrained paramaters loaded by PaddleHub
In [6]: for result in results:
...: print(result)
...:
{'positive_probs': 0.9363, 'text': '这家餐厅很好吃', 'sentiment_key': 'positive', 'negative_probs': 0.0637, 'sentiment_label': 2}
{'positive_probs': 0.0213, 'text': '这部电影真的很差劲', 'sentiment_key': 'negative', 'negative_probs': 0.9787, 'sentiment_label': 0}
{'positive_probs': 0.9501, 'text': '我爱自然语言处理', 'sentiment_key': 'positive', 'negative_probs': 0.0499, 'sentiment_label': 2}
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import paddlehub as hub
In [2]: senta = hub.Module(name="senta_bilstm")
2019-07-06 22:33:01,181-INFO: Installing senta_bilstm module
2019-07-06 22:33:01,182-INFO: Module senta_bilstm already installed in /home/textminer/.paddlehub/modules/senta_bilstm
In [3]: test_text = ["这家餐厅很好吃", "这部电影真的很差劲","我爱自然语言处理"]
In [4]: input_dict = {"text": test_text}
In [5]: results = senta.sentiment_classify(data=input_dict)
2019-07-06 22:33:53,835-INFO: 13 pretrained paramaters loaded by PaddleHub
2019-07-06 22:33:53,839-INFO: 20 pretrained paramaters loaded by PaddleHub
In [6]: for result in results:
...: print(result)
...:
{'positive_probs': 0.9363, 'text': '这家餐厅很好吃', 'sentiment_key': 'positive', 'negative_probs': 0.0637, 'sentiment_label': 2}
{'positive_probs': 0.0213, 'text': '这部电影真的很差劲', 'sentiment_key': 'negative', 'negative_probs': 0.9787, 'sentiment_label': 0}
{'positive_probs': 0.9501, 'text': '我爱自然语言处理', 'sentiment_key': 'positive', 'negative_probs': 0.0499, 'sentiment_label': 2}
最后
以上就是标致外套为你收集整理的python情感分析语料库_中文情感分析工具的全部内容,希望文章能够帮你解决python情感分析语料库_中文情感分析工具所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复