当使用Stanford时,我在CoreNLP输出文件中得到结果。在它里面,我找到了一个列,上面有演讲者的名字,例如:
<word>Mike</word>
<lemma>Mike</lemma>
<CharacterOffsetBegin>0</CharacterOffsetBegin>
<CharacterOffsetEnd>4</CharacterOffsetEnd>
<POS>NNP</POS>
<NER>PERSON</NER>
*<Speaker>PER0</Speaker>*
<TrueCase>INIT_UPPER</TrueCase>
<TrueCaseText>Mike</TrueCaseText>
<sentiment>Neutral</sentiment>那么我如何在java代码中操作Speaker结果呢?我怎样才能提高它的结果呢?例如,在一次对话中,我希望得到Mike而不是PER0
谢谢。
发布于 2017-03-07 23:29:59
使用DOM XML解析器:
发布于 2017-03-08 18:01:28
首先,感谢您@Thomas Bigger的回答
我会尽量说得更清楚,
在这段代码中,
PrintWriter xmlOut = new PrintWriter("xmlOutput.xml");
Properties props = new Properties();
props.setProperty("annotators","tokenize, ssplit, pos, lemma, truecase, ner, parse,quote, mention, dcoref, sentiment");
props.put("truecase.overwriteText", "true");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation annotation = new Annotation("Mike said : \"I vote for Hillary.\"\n
peter said : \"I vote for Donald.\"");
pipeline.annotate(annotation);
pipeline.xmlPrint(annotation, xmlOut);xmlOut.xml提供了两个句子的分析:
< Mike said >,<:>,<“>和<”>被认为是叙述者的言语(PER0)。
<我投票给希拉里>被认为是第一人的演讲。
<彼得·赛义德>、<:>、<“>和<”>被认为是叙述者的言语(PER0)。
<我投票给唐纳德。>被认为是彼得的演讲。这里唯一的区别是我把peter写成了小写,当我写成大写的时候,=>的结果变成了4。
在斯坦福大学CoreNLP上搜索JavaDoc时,我发现讨论Speaker的课程是这样的:
因此,首先,我希望在我的xmlOut中得到更有效的结果,其次,我想知道如何使用这些类在不使用DOM的情况下提取发言者及其语音。
https://stackoverflow.com/questions/42651884
复制相似问题