我使用斯坦福大学的CoreNLP库,一拉从Twitter获得情绪试验https://www.openshift.com/blogs/day-20-stanford-corenlp-performing-sentiment-analysis-of-twitter-using-java -所以请看这里我正在实现的代码.
我得到了结果,但我注意到,在我的目标数据集和我使用的另一个数据集中,似乎存在对"负面"结果的偏见 - Sanders Analytics Twitter Sentiment Corpus http://www.sananalytics .com/lab/twitter-sentiment / - 即使地面实况数据没有这种偏见.
我发布这个问题是因为其他人经历过这个问题并且/或者可能知道这是我做过的事情的结果还是CoreNLP代码中的一些错误.
(编辑 - 对不起,我花了这么长时间才回复)我发布的链接显示了我的意思.我没有足够的声誉来发布图片,并且在这篇文章中只能包含两个链接,因此我将在评论中添加链接.
我正在尝试在Ubuntu 12.04.5 LTS上构建stanford NLP的python接口.需要两个步骤,第一步是:
这样做时,我收到以下错误:
In file included from src/native/common/jp_monitor.cpp:17:0:
src/native/common/include/jpype.h:45:17: fatal error: jni.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
rake aborted!
Command failed with status (1): [cd JPype-0.5.4.1 && python setup.py build...]
Run Code Online (Sandbox Code Playgroud)
错误消息说我失踪了jni.h,所以如果我运行命令得到这里的建议.dpkg-query -L openjdk-7-jdk | grep "jni.h"/usr/lib/jvm/java-7-openjdk-amd64/include/jni.h
我相信这意味着jni.h我的系统已经存在,所以我现在很困惑.是什么导致错误?你能建议任何修复吗?
谢谢你的帮助!
一些更多的见解
以下是导致错误的指令:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux -Isrc/native/common/include -Isrc/native/python/include -I/usr/include/python2.7 -c src/native/common/jp_class.cpp -o …Run Code Online (Sandbox Code Playgroud) 我必须将中文文本分成多个句子.我试过Stanford DocumentPreProcessor.它适用于英语,但不适用于中文.
请你能告诉我任何中文优秀的句子分割器,最好用Java或Python.
我正在研究NLP,我想用Stanford解析器从文本中提取名词短语,我使用的解析器版本是3.4.1这是我使用的示例代码
package stanfordparser;
import java.util.Collection;
import java.util.List;
import java.io.StringReader;
import edu.stanford.nlp.process.Tokenizer;
import edu.stanford.nlp.process.TokenizerFactory;
import edu.stanford.nlp.process.CoreLabelTokenFactory;
import edu.stanford.nlp.process.DocumentPreprocessor;
import edu.stanford.nlp.process.PTBTokenizer;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.HasWord;
import edu.stanford.nlp.ling.Sentence;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
class ParserDemo {
public static void main(String[] args) {
LexicalizedParser lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
if (args.length > 0) {
demoDP(lp, args[0]);
} else {
demoAPI(lp);
}
}
public static void demoDP(LexicalizedParser lp, String filename) {
TreebankLanguagePack tlp = new PennTreebankLanguagePack();
GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
for (List<HasWord> sentence : new DocumentPreprocessor(filename)) {
Tree …Run Code Online (Sandbox Code Playgroud) 问题:是否可以选择使用单词stanford-core-nlp?我找不到一个!我正在使用stanford-corenlp-3.5.2.jar.
码:
public class StanfordNLPTester {
public static void main (String args[]){
String paragraph = "A long paragraph here";
Properties properties = new Properties();
properties.put("annotators","tokenize,ssplit,pos,lemma,ner,depparse");
StanfordCoreNLP pipeline = new StanfordCoreNLP(properties);
Annotation annotation = new Annotation (paragraph);
pipeline.annotate(annotation);
pipeline.prettyPrint(annotation,System.out);
}
}
Run Code Online (Sandbox Code Playgroud) 当我从nltk执行stanford解析器时,我得到以下结果.
(S (VP (VB get) (NP (PRP me)) (ADVP (RB now))))
Run Code Online (Sandbox Code Playgroud)
但我需要它的形式
S -> VP
VP -> VB NP ADVP
VB -> get
PRP -> me
RB -> now
Run Code Online (Sandbox Code Playgroud)
如何使用递归函数获得此结果.有内置功能吗?
我正在尝试使用StanfordNERTagger和nltk从一段文本中提取关键字.
docText="John Donk works for POI. Brian Jones wants to meet with Xyz Corp. for measuring POI's Short Term performance Metrics."
words = re.split("\W+",docText)
stops = set(stopwords.words("english"))
#remove stop words from the list
words = [w for w in words if w not in stops and len(w) > 2]
str = " ".join(words)
print str
stn = StanfordNERTagger('english.all.3class.distsim.crf.ser.gz')
stp = StanfordPOSTagger('english-bidirectional-distsim.tagger')
stanfordPosTagList=[word for word,pos in stp.tag(str.split()) if pos == 'NNP']
print "Stanford POS Tagged"
print stanfordPosTagList
tagged = stn.tag(stanfordPosTagList)
print …Run Code Online (Sandbox Code Playgroud) 我知道我可以标注一个句子,让每个单词的引理,但我不知道该怎么做,如果我只是想lemmatize一个单一的词.我试过了
Annotation tokenAnnotation = new Annotation("wedding");
List<CoreMap> list = tokenAnnotation.get(SentencesAnnotation.class);
String tokenLemma = list
.get(0).get(TokensAnnotation.class)
.get(0).get(LemmaAnnotation.class);
Run Code Online (Sandbox Code Playgroud)
但tokenAnnotation只有一把TextAnnotation钥匙,这意味着list将在null这里.
那么我怎样才能将一个单词列为单词呢?
我有一个非常简单的问题-在文本中识别货币。示例测试案例:“ 零用钱每年不得超过4000印度卢比(100美元)。 ”默认的斯坦福解析器-在线-(使用7类模型,包括货币)失败http://nlp.stanford.edu:8080 / ner / process-仅适用于“ $ 100”之类的文本。
在炼金术演示网站- https://alchemy-language-demo.mybluemix.net/,“$ 100”被公认为是一个实体,而“100美元”的recogised作为一个概念-美国美元
我想在我的Google Colab笔记本中使用Stanford CoreNLP。为此,我需要Java。有没有办法在这些机器上安装Java?
我目前拥有的是:
!pip install StanfordCoreNLP
from stanfordcorenlp import StanfordCoreNLP
nlp = StanfordCoreNLP('stanford-corenlp', lang='de', memory='4g')
...
nlp.close()
Run Code Online (Sandbox Code Playgroud)
我得到错误:
FileNotFoundError: [Errno 2] No such file or directory: 'java': 'java'
Run Code Online (Sandbox Code Playgroud) stanford-nlp ×10
java ×4
nlp ×4
python ×4
nltk ×2
alchemyapi ×1
openjdk ×1
parsing ×1
pos-tagger ×1
recursion ×1
sentence ×1
tokenize ×1
twitter ×1