当我自己构建Core-NLP时,我收到以下消息:
incompatible types; no instance(s) of type variable(s) VALUE exist so that VALUE conforms to Map<Integer,String>
Run Code Online (Sandbox Code Playgroud)
违规行:
Map<Integer,String> roleMap = ((CoreLabel)t1.label()).get(CoreAnnotations.CoNLLSRLAnnotation.class);
Run Code Online (Sandbox Code Playgroud)
违规功能:
@SuppressWarnings("unchecked")
public <VALUE, KEY extends Key<CoreMap, VALUE>>
VALUE get(Class<KEY> key) {
for (int i = size; i > 0; ) {
if (keys[--i] == key) {
return (VALUE)values[i];
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
我真的不知道如何解决这个问题.我正在尝试使用Maven构建CoreNLP,以便我可以在项目中轻松使用它.想法?
我正在使用Eclipse来运行java程序类,而我运行它时遇到了这个错误
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
Run Code Online (Sandbox Code Playgroud)
然后我从属性>运行> VM选项中更改了VM,然后我再次运行程序,出现了新的错误,
Error occurred during initialization of VM
Incompatible initial and maximum heap sizes specified
Run Code Online (Sandbox Code Playgroud)
我正在尝试在我的程序中应用stanford库,任何想法如何解决这个错误.
我想使用stanford nlp解析文档并从中删除停用词,所以我的问题是如何使用stanford nlp删除停用词是否有任何api删除它,我找到StopWords类但我不知道如何使用这个,请建议我怎么弄这个?
谢谢
似乎有一些不同的设置:
iobtags
iobTags
entitySubclassification (IOB1 or IOB2?)
evaluateIOB
Run Code Online (Sandbox Code Playgroud)
我使用哪种设置,如何正确使用?
我试着像这样标记:
1997 B-DATE
volvo B-BRAND
wia64t B-MODEL
highway B-TYPE
tractor I-TYPE
Run Code Online (Sandbox Code Playgroud)
但是在训练输出上,似乎认为B-TYPE和I-TYPE是不同的类别.
我正在使用2013-11-12版本.
我在同时注释多个句子时面临并发问题.我不清楚我是做错了还是CoreNLP中有错误.
我的目标是使用并行运行的多个线程使用管道"tokenize,ssplit,pos,lemma,ner,parse,dcoref"来注释句子.每个线程分配自己的StanfordCoreNLP实例,然后将其用于注释.
问题是在某些时候抛出异常:
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1042)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:463)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.analyzeNode(GrammaticalStructure.java:488)
at edu.stanford.nlp.trees.GrammaticalStructure.<init>(GrammaticalStructure.java:201)
at edu.stanford.nlp.trees.EnglishGrammaticalStructure.<init>(EnglishGrammaticalStructure.java:89)
at edu.stanford.nlp.semgraph.SemanticGraphFactory.makeFromTree(SemanticGraphFactory.java:139)
at edu.stanford.nlp.pipeline.DeterministicCorefAnnotator.annotate(DeterministicCorefAnnotator.java:89)
at edu.stanford.nlp.pipeline.AnnotationPipeline.annotate(AnnotationPipeline.java:68)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:412)Run Code Online (Sandbox Code Playgroud)
我附上了一个应用程序的示例代码,该代码在我的Core i3 370M笔记本电脑(Win 7 64位,Java 1.8.0.45 64位)上大约20秒内重现问题.此应用程序读取识别文本蕴涵(RTE)语料库的XML文件,然后使用标准Java并发类同时解析所有句子.需要将本地RTE XML文件的路径作为命令行参数提供.在我的测试中,我使用了公开的XML文件:http: //www.nist.gov/tac/data/RTE/RTE3-DEV-FINAL.tar.gz
package semante.parser.stanford.server;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import …Run Code Online (Sandbox Code Playgroud)我正在使用Stanford的CoreNLP库以及Stanford CoreNLP Python Wrapper处理大量文档.我正在使用以下注释器:
tokenize, ssplit, pos, lemma, ner, entitymentions, parse, dcoref
Run Code Online (Sandbox Code Playgroud)
以及shift-reduce解析器模型englishSR.ser.gz.我主要使用CoreNLP进行共同参考解析/命名实体识别,据我所知,我正在使用最小的注释器集来实现此目的.
我可以采用哪些方法来加快文档注释?
其他SO答案都建议不要为每个文档加载模型,但我已经这样做了(因为包装器启动服务器一次然后来回传递文档/结果).
我正在处理的文件平均长度为20个句子,有些句子长达400个句子,有些句子短至1.每个句子的平均解析时间为1秒.我可以在一台机器上运行一个单线程进程,每天解析~2500个文档,但我想加倍(如果不是更多).
这是我的代码
from nltk.tag import StanfordNERTagger
st = StanfordNERTagger('english.all.3class.distsim.crf.ser.gz')
Run Code Online (Sandbox Code Playgroud)
我明白了
NLTK was unable to find stanford-ner.jar! Set the CLASSPATH
environment variable.
Run Code Online (Sandbox Code Playgroud)
这就是我.bashrc在ubuntu中的样子
export CLASSPATH=/home/wolfgang/Downloads/stanford-ner-2015-04-20/stanford-ner-3.5.2.jar
export STANFORD_MODELS=/home/wolfgang/Downloads/stanford-ner-2015-04-20/classifiers
Run Code Online (Sandbox Code Playgroud)
此外,我尝试以这种方式在python中打印环境变量
import os
os.environ.get('CLASSPATH')
Run Code Online (Sandbox Code Playgroud)
我接受了
'/home/wolfgang/Downloads/stanford-ner-2015-04-20/stanford-ner-3.5.2.jar'
Run Code Online (Sandbox Code Playgroud)
因此变量正在设置!
那有什么不对?
为什么不知道我的环境变量?
谁能想到加快我的CoreNLP情绪分析的方法(下图)?
我在服务器启动时初始化CoreNLP管道:
// Initialize the CoreNLP text processing pipeline
public static Properties props = new Properties();
public static StanfordCoreNLP pipeline;
// Set text processing pipeline's annotators
props.setProperty("annotators", "tokenize, ssplit, pos, parse, sentiment");
// Use Shift-Reduce Constituency Parsing (O(n),
// http://nlp.stanford.edu/software/srparser.shtml) vs CoreNLP's default
// Probabilistic Context-Free Grammar Parsing (O(n^3))
props.setProperty("parse.model", "edu/stanford/nlp/models/srparser/englishSR.ser.gz");
pipeline = new StanfordCoreNLP(props);
Run Code Online (Sandbox Code Playgroud)
然后我从我的控制器调用管道:
String text = 'A sample string.'
Annotation annotation = pipeline.process(text);
List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
Tree tree = sentence.get(SentimentCoreAnnotations.SentimentAnnotatedTree.class); …Run Code Online (Sandbox Code Playgroud) java optimization performance stanford-nlp sentiment-analysis
我发现了stanford-NLP的工具,发现它非常有趣.我是法国数据管理员/数据科学家,喜欢文本分析,并且很乐意使用你的工具,但是法语中没有的NER对我来说非常令人费解.
我很想制作我自己的法国NER,如果它被认为是值得的话,甚至可以提供它作为包的贡献,那么......你能否向我简要介绍基于stanford coreNLP训练法国NER的CRF的要求?
谢谢.
我正在使用NLTK包装器测试StanfordNERTagger并出现此警告:
DeprecationWarning: The StanfordTokenizer will be deprecated in version
3.2.5. Please use nltk.tag.corenlp.CoreNLPPOSTagger or
nltk.tag.corenlp.CoreNLPNERTagger instead.
super(StanfordNERTagger, self).__init__(*args, **kwargs)
Run Code Online (Sandbox Code Playgroud)
我的代码看起来像这样:
from nltk import word_tokenize, pos_tag, ne_chunk
from nltk.tag import StanfordNERTagger
sentence = "Today George went to school and met his friend Peter."
# stanford's NER tagger 3 entity classification
st = StanfordNERTagger('/home/hercules/Desktop/PhD/Tools/stanford-ner-
2017-06-09/classifiers/english.all.3class.distsim.crf.ser.gz',
'/home/hercules/Desktop/PhD/Tools/stanford-ner-2017-06-09/stanford-
ner.jar',
encoding='utf-8')
tokenized_text = word_tokenize(sentence)
classified_text = st.tag(tokenized_text)
print("Stanford NER tagger:")
print(classified_text)
Run Code Online (Sandbox Code Playgroud)
我试图使用CoreNLPNERTagger,但我找不到任何示例或文档.我只发现了这个链接: 它在类CoreNLPNERTagger(CoreNLPTagger)的注释中提供类似示例(我通过搜索关键字"CoreNLPNERTagger"找到它)
我试着不遵循这个例子.我想我应该首先启动(如果这是正确的术语)coreNLP服务器,但如果是这样,我不知道如何.
如果有人有任何想法或建议,我将不胜感激.
stanford-nlp ×10
java ×4
python ×3
nlp ×2
nltk ×2
concurrency ×1
eclipse ×1
optimization ×1
parsing ×1
performance ×1
stop-words ×1