2016-11-10 146 views
0

我想用Stabnford NLP分析句子(其他语言为英语)。斯坦福NLP其他语言的API

对于我运行在本地主机上的服务器的时刻: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上使用其他语言?

感谢

回答

2

你应该用你的要求此选项(例如:德国):

"pipelineLanguage":"german" 
0

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

我下载了stanford-corenlp-full,其中包含了stanford-french-corenlp-models-current.jar。当你看到斯坦福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的出现的错误。