deep-learning - 除了 Keras 和 Spacy,我可以使用 Stanford Core NLP 进行深度学习吗?
问题描述
我正在尝试使用深度学习 (RNN) 对 Twitter 数据进行情感分析。我知道还有其他各种深度学习库,例如 TF、keras、gensim 等,但我想知道是否可以使用 CoreNLP 库执行深度学习。
https://github.com/charlescc9/deep-learning-sentiment-analysis
上面这个人尝试比较深度学习的 gensim、tensorflow 和 core nlp。但是几乎没有任何文档,我无法理解如何运行文件(或)所需的依赖项。请帮帮我。
解决方案
我之前出于同样的原因使用过 RNN,这就是我所做的:
准备
- 下载 coreNLP 包。你可以从这里开始。
- 通过运行安装pycorenlp 包装器
pip install pycorenlp
。 Java>=1.8
如果没有安装,请安装。
用法
现在,让我们看看如何使用它:
- 将下载的 zip 文件解压到项目目录中
- 打开终端并运行以下命令:
java -mx5g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -timeout 10000
- 现在,服务器
localhost:9000
默认运行。现在,您可以编写程序了。
这是一个简单的例子:
>>> from pycorenlp import StanfordCoreNLP
>>>
>>> sentence = "NLP is great"
>>> nlp = StanfordCoreNLP('http://localhost:9000')
>>> res = nlp.annotate(sentence, properties={ 'annotators': 'sentiment',
... 'outputFormat': 'json',
... 'timeout': 10000,})
>>> #you can get the class by:
>>> klass = res["sentences"][0]["sentimentValue"]
推荐阅读
- python - 如何使用python对同一excel文件的几个excel表进行countplot?
- python - pandas df 按列表屏蔽特定行
- algorithm - 为什么 Kruskal 算法必须迭代所有边?
- asp.net-core - AutoMapper 从父类型属性分配属性
- python - 如何将两个表合二为一?
- javascript - 使用按钮将表格行的数据发送到服务器。我正在使用数据表
- qt - 如何让 QTableWidge 根据其内容调整大小
- oracle - 编写一个不带参数 Ins_Job 的 PL/SQL 过程,在表 JOBS 中插入新记录
- python - 在熊猫中删除过滤的行
- single-page-application - 使用谷歌标签管理器为 SPA 安装 GA4 但字段页面不起作用