Example usage for edu.stanford.nlp.coref.data CorefChain getRepresentativeMention

List of usage examples for edu.stanford.nlp.coref.data CorefChain getRepresentativeMention

Introduction

In this page you can find the example usage for edu.stanford.nlp.coref.data CorefChain getRepresentativeMention.

Prototype

public CorefMention getRepresentativeMention() 

Source Link

Document

Return the most representative mention in the chain.

Usage

From source file:edu.illinois.cs.cogcomp.pipeline.handlers.StanfordCorefHandler.java

License:Open Source License

@Override
protected void addView(TextAnnotation ta) throws AnnotatorException {
    Annotation document = new Annotation(ta.text);
    pipeline.annotate(document);/*from  w w  w . ja  va  2s .com*/
    CoreferenceView vu = new CoreferenceView(viewName, ta);

    Map corefChain = document.get(CorefCoreAnnotations.CorefChainAnnotation.class);
    for (Object key : corefChain.keySet()) {
        CorefChain chain = (CorefChain) corefChain.get(key);
        Constituent representative = createConstituentGivenMention(document, chain,
                chain.getRepresentativeMention(), ta);
        List<Constituent> consList = new ArrayList<>();
        for (CorefChain.CorefMention m : chain.getMentionsInTextualOrder()) {
            consList.add(createConstituentGivenMention(document, chain, m, ta));
        }
        consList.remove(representative); // remove the representative itself
        vu.addCorefEdges(representative, consList);
    }
    ta.addView(viewName, vu);
}