【问题标题】:Prevent Stanford CoreNLP from Americanizing input防止斯坦福 CoreNLP 将输入美国化
【发布时间】:2015-07-15 20:09:29
【问题描述】:

我注意到斯坦福 CoreNLP 正在美国化输入,这破坏了我的一些代码,因为字符偏移不再累加。

我正在使用以下代码:

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))
[...]

请注意,输入包含单词honourable,但输出包含单词honorablecolourharbours 这样的词也会发生同样的情况。

有没有办法防止这种行为?我不介意在引理中使用它,但我想获得原始单词以便偏移匹配。

【问题讨论】:

标签: nlp stanford-nlp


【解决方案1】:

在 CoreNLP 的代码中,您要添加属性:

props.put("tokenize.options", "americanize=false");

【讨论】:

  • 谢谢!我使用的是props.put("options" 而不是props.put("tokenize.options"
猜你喜欢
  • 1970-01-01
  • 2019-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-05
相关资源
最近更新 更多