- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试在 Eclipse 中实现 coreNLP 情绪分析器。得到错误:
Unable to resolve "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"
作为类路径、文件名或 URL。我使用 maven 安装了所有 NLP 文件,所以我不确定它为什么要寻找其他东西。这是我遇到错误的代码。
import java.util.Properties;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.neural.rnn.RNNCoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.sentiment.SentimentCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.util.CoreMap;
public class StanfordSentiment {
StanfordCoreNLP pipeline;
public StanfordSentiment(){
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, parse, sentiment");
pipeline = new StanfordCoreNLP(props);
}
public float calculateSentiment (String text) {
float mainSentiment = 0;
int longest = 0;
Annotation annotation = pipeline.process(text);
for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
Tree tree = sentence.get(SentimentCoreAnnotations.AnnotatedTree.class);
int sentiment = RNNCoreAnnotations.getPredictedClass(tree) - 2;
String partText = sentence.toString();
if (partText.length() > longest) {
mainSentiment = sentiment;
longest = partText.length();
}
}
return mainSentiment;
}
}
最佳答案
public class SentimentAnalysis {
public static void main(String[] args) throws IOException {
String text = "I am very happy";
Properties props = new Properties();
props.setProperty("annotators",
"tokenize, ssplit, pos, lemma, parse, sentiment");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation annotation = pipeline.process(text);
List<CoreMap> sentences = annotation
.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
String sentiment = sentence
.get(SentimentCoreAnnotations.ClassName.class);
System.out.println(sentiment + "\t" + sentence);
}
}
}
希望对你有帮助..:)
关于java - 斯坦福 CoreNLP 观点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23063980/
我在检测以小写字母开头的命名实体时遇到问题。如果我只用小写单词训练模型,那么准确率是合理的;但是,当模型使用完全大写的标记或什至是小写和大写混合训练时,结果非常糟糕。我尝试了斯坦福 NLP 小组提供的
这可能是一个愚蠢的问题,但是如何迭代解析树作为 NLP 解析器(如斯坦福 NLP)的输出?它都是嵌套的括号,既不是 array 也不是 dictionary 或我使用过的任何其他集合类型。 (ROOT
如何使用斯坦福解析器在 java 类中标记字符串? 我只能找到 documentProcessor 和 PTBTokenizer 从外部文件获取文本的示例。 DocumentPreprocessor
我的代码开头有以下内容: import twitter4j.*; import java.util.List; import java.util.Properties; import ja
这是我第一次在这里发帖;因此,如果我表现出任何不好的做法,请告诉我。 所以目前我正在尝试使用斯坦福大学的 OpenIE 从网络挖掘的数据中提取信息。由于我对 Java 很陌生,我只是从他们的页面复制了
我正在尝试使用斯坦福 CoreNLP 关系提取器 ( http://nlp.stanford.edu/software/relationExtractor.shtml )。 我已经安装了 CoreNL
我最近在使用Stanford Lexparser。不幸的是,我遇到了一个问题,因为它需要很长时间,特别是当我传递一个大文件时。多线程有助于提高性能吗?我知道多线程可以在命令行中轻松完成。但是,我想在内
原始推文已保存到以下结构的文件中: tweet language || tweet 以下是我的预处理阶段,用于删除 URL、RT、用户名和任何非字母数字字符。 def cleanTweets() {
在哪里可以找到有关基因、蛋白质、激素、转录因子、神经递质、细胞因子、生物标志物、表观遗传标志物、 enzyme 、RNA、器官、细胞、药物和疾病的斯坦福 NLP 命名实体识别库? 最佳答案 简而言之:
我在使用斯坦福大学的句子注释器时遇到了问题。作为输入,我得到了文本,其中包含句子,但其中某些部分的点后没有空格。像这样: Dog loves cat.Cat loves mouse. Mouse ha
通常,当您使用 corenlp 注释管道进行 NER 时,您将编写以下代码 Properties props = new Properties(); props.put("annotators", "
我正在尝试对推文进行情感分析,但出现奇怪的异常。 我正在使用属性文件初始化管道,并将属性文件放置在 src->main 文件夹内的资源目录中。 但在 init 函数中仍然出现异常: Exception
我正在尝试使用斯坦福库设置我的 NLP 解析器。在我下载的网站上 stanford-corenlp-full-2015-12-09.zip standford-french-corenlp-2016-
我正在尝试使用文件输入运行此代码并将其输出到另一个文件: import java.util.*; import edu.stanford.nlp.pipeline.*; import edu.stan
我正在Windows中做一个NLP项目,问题是每当我从命令提示符运行Stanford CoreNLP时,大约需要14-15秒才能生成给定输入文本文件的XML输出。我认为这个问题是因为库需要相当多的时间
我在 python 中使用斯坦福 NER 标记器。它没有标记日期和时间。相反,每个单词都返回 O。我的句子是: “多少钱才能在 3 年内以年利率 12% 的利率赚取 162 美元的利息” 我标记后得到
Soo... 该程序完全按照应有的方式运行,但我不明白该程序输出的花哨缩写是什么。 如果我输入'I wish today was a school day',程序会输出 I/PRP : wish/VB
我在 http://nlp.stanford.edu/software/stanford-corenlp-full-2015-04-20.zip 下载了 Stanford NLP 3.5.2 然后我解
在斯坦福自然语言处理中,有命名实体识别器功能来识别对话中的实体。有没有一种方法可以配置可以训练以指向特定意图的话语?类似于 LUIS (Microsoft)。 最佳答案 我正在使用 SharpNLP
我正在使用 Stanford CoreNLP 在 Windows 机器上运行 Java 的 NLP 项目。我想从这个注释一篇大文本文章。我写的代码如下; Properties props = new
我是一名优秀的程序员,十分优秀!