本文整理汇总了Java中edu.stanford.nlp.util.Pair.setFirst方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.setFirst方法的具体用法?Java Pair.setFirst怎么用?Java Pair.setFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.util.Pair
的用法示例。
在下文中一共展示了Pair.setFirst方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findSpeakersInArticle
import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
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;
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);
}
}
}
}
示例2: findDependentVerb
import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
private static Pair<IndexedWord, String> findDependentVerb(Mention m) {
Pair<IndexedWord, String> ret = new Pair<IndexedWord, String>();
int headIndex = m.headIndex+1;
try {
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;
}