0

我想用 Stabnford NLP 分析句子(其他语言到英语)。

目前我在 localhost:9000 上运行服务器

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer

在我的节点服务器中,我这样调用 api:

output=$(wget --post-data '+"'"+text+"' "+"'localhost:"+port+'
/?properties=
{
    "props": "StanfordCoreNLP-[OTHER LANGUAGE].properties", 
    "annotators": "ssplit,parse", 
    "outputFormat": "json"
}' 
-qO -) && echo $output",{ encoding: 'utf8' }

但是结果仍然是英语,我不知道为什么?有人想在斯坦福 NLP 上使用其他语言吗?

谢谢

4

2 回答 2

2

您应该在您的请求中使用此选项(例如:德语):

"pipelineLanguage":"german"
于 2016-11-11T00:50:44.200 回答
0

感谢您的回答。但是,例如,当我使用“法语”语言添加此选项时,命令 wget 失败。

我下载了 stanford-corenlp-full,其中包含 stanford-french-corenlp-models-current.jar。当您看到 stanford NLP 的日志时,我的印象是 NLP 尝试加载英语。

我该如何解决?在我的日志上方:

[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator tokenize
    [main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ssplit
    [main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator pos
    [main] INFO edu.stanford.nlp.tagger.maxent.MaxentTagger - Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [4,6 sec].
    [main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator lemma
    [main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ner
    [main] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [8,0 sec].
    [main] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [5,1 sec].
    [main] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [3,2 sec].
    [main] INFO edu.stanford.nlp.time.JollyDayHolidays - Initializing JollyDayHoliday for SUTime from classpath edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml as sutime.binder.1.
    [main] INFO edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor - Reading TokensRegex rules from edu/stanford/nlp/models/sutime/defs.sutime.txt
    [main] INFO edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor - Read 83 rules
    [main] INFO edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor - Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.sutime.txt
    [main] INFO edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor - Read 267 rules
    [main] INFO edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor - Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.holidays.sutime.txt
    [main] INFO edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor - Read 25 rules
    [main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator depparse
    [main] INFO edu.stanford.nlp.parser.nndep.DependencyParser - Loading depparse model file: edu/stanford/nlp/models/parser/nndep/english_UD.gz ...
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
            at edu.stanford.nlp.parser.nndep.Classifier.preCompute(Classifier.java:661)
            at edu.stanford.nlp.parser.nndep.Classifier.preCompute(Classifier.java:643)
            at edu.stanford.nlp.parser.nndep.DependencyParser.initialize(DependencyParser.java:1168)
            at edu.stanford.nlp.parser.nndep.DependencyParser.loadModelFile(DependencyParser.java:605)
            at edu.stanford.nlp.parser.nndep.DependencyParser.loadFromModelFile(DependencyParser.java:498)
            at edu.stanford.nlp.pipeline.DependencyParseAnnotator.<init>(DependencyParseAnnotator.java:57)
            at edu.stanford.nlp.pipeline.AnnotatorImplementations.dependencies(AnnotatorImplementations.java:273)
            at edu.stanford.nlp.pipeline.AnnotatorFactories$18.create(AnnotatorFactories.java:478)
            at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:152)
            at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:451)
            at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:154)
            at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:150)
            at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:137)
            at edu.stanford.nlp.pipeline.StanfordCoreNLP.main(StanfordCoreNLP.java:1326)

PS:当我运行 wget 时发生错误。

于 2016-11-17T10:03:45.443 回答