Example usage for edu.stanford.nlp.util Pair setFirst

List of usage examples for edu.stanford.nlp.util Pair setFirst

Introduction

In this page you can find the example usage for edu.stanford.nlp.util Pair setFirst.

Prototype

public void setFirst(T1 o) 

Source Link

Usage

From source file:knu.univ.lingvo.coref.Document.java

License:Open Source License

private void findSpeakersInArticle(Dictionaries dict) {
    List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
    Pair<Integer, Integer> beginQuotation = new Pair<Integer, Integer>();
    Pair<Integer, Integer> endQuotation = new Pair<Integer, Integer>();
    boolean insideQuotation = false;
    int utterNum = -1;

    for (int i = 0; i < sentences.size(); i++) {
        List<CoreLabel> sent = sentences.get(i).get(CoreAnnotations.TokensAnnotation.class);
        for (int j = 0; j < sent.size(); j++) {
            int utterIndex = sent.get(j).get(CoreAnnotations.UtteranceAnnotation.class);

            if (utterIndex != 0 && !insideQuotation) {
                utterNum = utterIndex;/*from  w w  w . j av a  2  s  .c om*/
                insideQuotation = true;
                beginQuotation.setFirst(i);
                beginQuotation.setSecond(j);
            } else if (utterIndex == 0 && insideQuotation) {
                insideQuotation = false;
                endQuotation.setFirst(i);
                endQuotation.setSecond(j);
                findQuotationSpeaker(utterNum, sentences, beginQuotation, endQuotation, dict);
            }
        }
    }
}

From source file:knu.univ.lingvo.coref.Mention.java

License:Open Source License

private static Pair<IndexedWord, String> findDependentVerb(Mention m) {
    Pair<IndexedWord, String> ret = new Pair<IndexedWord, String>();
    int headIndex = m.headIndex + 1;
    try {// ww  w  . ja va  2s.  c  om
        IndexedWord w = m.dependency.getNodeByIndex(headIndex);
        if (w == null)
            return ret;
        while (true) {
            IndexedWord p = null;
            for (Pair<GrammaticalRelation, IndexedWord> parent : m.dependency.parentPairs(w)) {
                if (ret.second() == null) {
                    String relation = parent.first().getShortName();
                    ret.setSecond(relation);
                }
                p = parent.second();
            }
            if (p == null || p.get(CoreAnnotations.PartOfSpeechAnnotation.class).startsWith("V")) {
                ret.setFirst(p);
                break;
            }
            if (w == p)
                return ret;
            w = p;
        }
    } catch (Exception e) {
        return ret;
    }
    return ret;
}