【问题标题】:How can I extract the Speaker annotation from a conversation?如何从对话中提取演讲者注释?
【发布时间】:2017-03-07 15:15:36
【问题描述】:

使用 Stanford CoreNLP 时,我会在 xml 输出文件中获得结果。在其中,我找到了一个带有演讲者姓名的列,例如:

        <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

谢谢。

【问题讨论】:

    标签: java stanford-nlp speaker


    【解决方案1】:

    【讨论】:

    • 是的,但我还需要改进生成的结果。我认为有一个我应该能够操纵的扬声器注释器。
    • 这个 XML sn-p 在 DOM 树的深处吗?所以这对多个发言者重复?您可以搜索包含 Speaker 作为子项的根元素,然后返回单词元素 Mike。
    【解决方案2】:

    首先,感谢@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 呈现两句分析:

    First Sentence

    , , 和 被认为是叙述者的演讲(PER0)。
    被视为第 1 个人的演讲。

    Second Sentence

    , , 和 被认为是叙述者的讲话(PER0)。
    被认为是彼得的演讲。 =>这里唯一的区别是我用小写写了peter,当我用大写写它时,speaker的结果变成了4。

    在斯坦福 CoreNLP 上的 JavaDoc 中搜索时,我发现有关演讲者的课程如下:
    - CoreAnnotations.SpeakerAnnotation
    - CoreNLPProtos.SpeakerInfo
    - CoreNLPProtos.SpeakerInfo.Builder
    - CoreNLPProtos.SpeakerInfoOrBuilder
    - 扬声器信息
    - 扬声器信息
    - 扬声器匹配

    首先,我想在我的 xmlOut 中获得更有效的结果,其次,我想知道如何在不使用 DOM XML 的情况下使用这些类来提取扬声器及其语音。

    【讨论】:

      猜你喜欢
      • 2022-11-17
      • 1970-01-01
      • 2015-07-06
      • 1970-01-01
      • 2017-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多