防止Stanford CoreNLP将输入美国化
我注意到StanfordCorenlp正在美国化输入,这打破了我的一些代码,因为字符偏移量不再累加 我正在使用以下代码:防止Stanford CoreNLP将输入美国化,nlp,stanford-nlp,Nlp,Stanford Nlp,我注意到StanfordCorenlp正在美国化输入,这打破了我的一些代码,因为字符偏移量不再累加 我正在使用以下代码: String annotators = "tokenize, ssplit, pos, lemma, ner, parse, dcoref"; Properties props = new Properties(); props.put("annotators",annotators); this.pipeline = new StanfordCoreNLP(props);
String annotators = "tokenize, ssplit, pos, lemma, ner, parse, dcoref";
Properties props = new Properties();
props.put("annotators",annotators);
this.pipeline = new StanfordCoreNLP(props);
this.annotators = annotators;
Annotation document = new Annotation(text);
pipeline.annotate(document);
pipeline.prettyPrint(document, resp.getWriter());
通过以下输入:
But, at the other end of the town, in his own little hut, there dwelt an honourable laborer.
我得到:
[...]
[Text=an CharacterOffsetBegin=70 CharacterOffsetEnd=72 PartOfSpeech=DT]
[Text=honorable CharacterOffsetBegin=73 CharacterOffsetEnd=83 PartOfSpeech=JJ]
[Text=laborer CharacterOffsetBegin=84 CharacterOffsetEnd=91 PartOfSpeech=NN]
[...]
(NP (DT an) (JJ honorable) (NN laborer))
[...]
请注意,输入有单词honorible
,但输出有单词honorible
。像颜色
或港口
这样的词也会发生同样的情况
有没有办法防止这种行为?我不介意在引理中这样做,但我想让原始单词匹配偏移量。在CoreNLP的代码中,您想添加以下属性:
props.put("tokenize.options", "americanize=false");
使用本页中指定的选项
americanize=false
:谢谢!我使用的是props.put(“options”
,而不是props.put(“tokenize.options”