Tag: stanford nlp

在将stanford情绪分析与java集成时获取错误

我正在使用stanford情感nlp库和java进行情绪分析。 但是当我执行代码时,我收到错误。 无法搞清楚。 我的代码如下: package com.nlp; import java.util.Properties; import edu.stanford.nlp.ling.CoreAnnotations; import edu.stanford.nlp.pipeline.Annotation; import edu.stanford.nlp.pipeline.StanfordCoreNLP; import edu.stanford.nlp.rnn.RNNCoreAnnotations; import edu.stanford.nlp.sentiment.SentimentCoreAnnotations; import edu.stanford.nlp.trees.Tree; import edu.stanford.nlp.util.CoreMap; public class SemanticAnalysis { public static void main(String args[]) { sentimentAnalysis sentiment = new sentimentAnalysis(); sentiment.findSentiment(“france is a good city”); } } class sentimentAnalysis { public String findSentiment(String line) { Properties props = […]

如何通过CoreNLP识别小写的命名实体,如kobe bryant?

我遇到了一个问题,CoreNLP只能识别名为Kobe Bryant的命名实体,它以一个大写字母开头,但不能识别kobe bryant作为一个人! 那么如何识别CoreNLP以小写字母开头的命名实体???? 欣赏它!!!!

从信号中提取三次

我有这种格式的解析文本,我通过使用Standford nlp得到它。 (ROOT (S (NP (DT A) (NN passenger) (NN plane)) (VP (VBZ has) (VP (VBD crashed) (ADVP (RB shortly)) (PP (IN after) (NP (NP (NN take-off)) (PP (IN from) (NP (NNP Kyrgyzstan) (“ `) (NNP scapital) (, ,) (NNP Bishkek))))) (, ,) (VP (VBG killing) (NP (NP (DT a) (JJ large) (NN number)) (PP […]

如何从解析的文本中提取名词短语

我已经用constituency解析器解析了一个文本,将结果复制到如下文本文件中: (ROOT (S (NP (NN Yesterday)) (, ,) (NP (PRP we)) (VP (VBD went) (PP (TO to)…. (ROOT (FRAG (SBAR (SBAR (IN While) (S (NP (PRP I)) (VP (VBD was) (NP (NP (EX… (ROOT (S (NP (NN Yesterday)) (, ,) (NP (PRP I)) (VP (VBD went) (PP (TO to….. (ROOT (FRAG (SBAR (SBAR (IN While) […]

使用Stanford CoreNLP进行懒惰解析,以获得特定句子的情感

我正在寻找优化斯坦福CoreNLP情绪管道性能的方法。 因此,想要得到句子的情感,但只有那些包含特定关键词作为输入的句子。 我尝试了两种方法: 方法1:StanfordCoreNLP管道用情绪注释整个文本 我已经定义了一个注释器管道:tokenize,ssplit,parse,sentiment。 我在整篇文章中运行它,然后在每个句子中查找关键字,如果它们存在,则运行返回关键字值的方法。 虽然处理需要几秒钟,但我并不满意。 这是代码: List keywords = …; String text = …; Map sentenceSentiment = new HashMap(); Properties props = new Properties(); props.setProperty(“annotators”, “tokenize, ssplit, parse, sentiment”); props.setProperty(“parse.maxlen”, “20”); props.setProperty(“tokenize.options”, “untokenizable=noneDelete”); StanfordCoreNLP pipeline = new StanfordCoreNLP(props); Annotation annotation = pipeline.process(text); // takes 2 seconds!!!! List sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class); for (int i=0; […]

通过斯坦福解析器提取所有名词,形容词forms和文本

我试图通过斯坦福解析器从给定的文本中提取所有名词和形容词。 我目前的尝试是在Tree-Object的getChildrenAsList()中使用模式匹配来定位如下内容: (NN paper), (NN algorithm), (NN information), … 并将它们保存在一个数组中。 输入句子: 在本文中,我们提出了一种从任意文本中提取语义信息的算法。 结果 – 字符串: [(S (PP (IN In) (NP (DT this) (NN paper))) (NP (PRP we)) (VP (VBP present) (NP (NP (DT an) (NN algorithm)) (SBAR (WHNP (WDT that)) (S (VP (VBD extracts) (NP (JJ semantic) (NN information)) (PP (IN from) (NP (DT an) […]

使用stanford core nlp java代码获得情绪分析结果

当我们在斯坦福演示页面上测试它时: http : //nlp.stanford.edu : 8080/sentiment/rntnDemo.html 它给树提供每个节点的情感分数如下: 我试图使用命令在我的本地系统上测试它: H:\Drive E\Stanford\stanfor-corenlp-full-2013~>java -cp “*” edu.stanford.nlp.sen timent.Evaluate edu/stanford/nlp/models/sentiment/sentiment.ser.gz test.txt text.txt有 This movie doesn’t care about cleverness, wit or any other kind of intelligent humor. Those who find ugly meanings in beautiful things are corrupt without being charming. 结果如下: 任何人都可以告诉我为什么它是空的? 或许我在执行中犯了什么错误? 我的目的是分析文本并用分数得到情绪结果。

如何使用OpenNLP创建自定义模型?

我正在尝试使用OpenNLP Java API从文档中提取 名称,技能等实体 。 但它没有提取适当的名称 。 我正在使用opennlp sourceforge链接上提供的模型 这是一段java代码 – public class tikaOpenIntro { public static void main(String[] args) throws IOException, SAXException, TikaException { tikaOpenIntro toi = new tikaOpenIntro(); toi.filest(“”); String cnt = toi.contentEx(); toi.sentenceD(cnt); toi.tokenization(cnt); String names = toi.namefind(toi.Tokens); toi.files(names); } public String Tokens[]; public String contentEx() throws IOException, SAXException, TikaException { InputStream […]

从解析树中获取某些节点

我正在研究一个涉及通过Hobbs算法进行回指解析的项目。 我使用Stanford解析器解析了我的文本,现在我想操作节点以实现我的算法。 目前,我不明白如何: 基于其POS标签访问节点(例如,我需要以代词开头 – 我如何得到所有代词?)。 使用访客。 我有点像Java的菜鸟,但是在C ++中我需要实现一个Visitor functor然后处理它的钩子。 我找不到Stanford Parser的Tree结构。 那是jgrapht吗? 如果是的话,你能否提供一些关于代码片段的指示?

在NLP的帮助下分析句子并提取人名,组织和位置

我需要使用NLP解决以下问题,您能否指出如何使用OpenNLP API实现此目的 一个。 如何判断一个句子是否暗示过去,现在或将来的某种行为。 (eg) I was very sad last week – past I feel like hitting my neighbor – present I am planning to go to New York next week – future 湾 如何找到与个人,公司或国家相对应的单词 (eg) John is planning to specialize in Electrical Engineering in UC Berkley and pursue a career with IBM). 人=约翰 公司= […]