除了Keras和Spacy之外,我可以使用Stanford Core NLP进行深度学习吗?

问题描述 投票:-1回答:1

我正在尝试使用深度学习(RNN)对推特数据进行情绪分析。我知道还有其他各种深度学习库,如TF,keras,gensim等,但我想知道是否可以使用CoreNLP库进行深度学习。

https://github.com/charlescc9/deep-learning-sentiment-analysis

上面这个人试图比较gensim,tensorflow和core nlp进行深度学习。但是几乎没有任何文档,我无法理解如何运行文件(或)所需的dependecies。请帮帮我。

deep-learning nlp stanford-nlp lstm
1个回答
0
投票

我之前使用过RNN的原因相同,这就是我所做的:

做好准备

  1. 下载coreNLP包。你可以从here做到这一点。
  2. 通过运行pycorenlp wrapper安装pip install pycorenlp
  3. 如果没有安装,请安装Java>=1.8

用法

现在,让我们看看如何使用它:

  1. 将下载的zip文件解压缩到项目的目录中
  2. 打开终端并运行以下命令:java -mx5g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -timeout 10000
  3. 现在,默认情况下,服务器正在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"]
© www.soinside.com 2019 - 2024. All rights reserved.