本文整理汇总了Java中edu.stanford.nlp.util.IntTuple.set方法的典型用法代码示例。如果您正苦于以下问题:Java IntTuple.set方法的具体用法?Java IntTuple.set怎么用?Java IntTuple.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.util.IntTuple
的用法示例。
在下文中一共展示了IntTuple.set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findNextParagraphSpeaker
import edu.stanford.nlp.util.IntTuple; //导入方法依赖的package包/类
private String findNextParagraphSpeaker(List<CoreMap> paragraph, int paragraphOffset, Dictionaries dict) {
CoreMap lastSent = paragraph.get(paragraph.size()-1);
String speaker = "";
for(CoreLabel w : lastSent.get(CoreAnnotations.TokensAnnotation.class)) {
if(w.get(CoreAnnotations.LemmaAnnotation.class).equals("report") || w.get(CoreAnnotations.LemmaAnnotation.class).equals("say")) {
String word = w.get(CoreAnnotations.TextAnnotation.class);
SemanticGraph dependency = lastSent.get(SemanticGraphCoreAnnotations.CollapsedDependenciesAnnotation.class);
IndexedWord t = dependency.getNodeByWordPattern(word);
for(Pair<GrammaticalRelation,IndexedWord> child : dependency.childPairs(t)){
if(child.first().getShortName().equals("nsubj")) {
int subjectIndex = child.second().index(); // start from 1
IntTuple headPosition = new IntTuple(2);
headPosition.set(0, paragraph.size()-1 + paragraphOffset);
headPosition.set(1, subjectIndex-1);
if(mentionheadPositions.containsKey(headPosition)
&& mentionheadPositions.get(headPosition).nerString.startsWith("PER")) {
speaker = Integer.toString(mentionheadPositions.get(headPosition).mentionID);
}
}
}
}
}
return speaker;
}
示例2: CorefMention
import edu.stanford.nlp.util.IntTuple; //导入方法依赖的package包/类
public CorefMention(Mention m, IntTuple pos){
mentionType = m.mentionType;
number = m.number;
gender = m.gender;
animacy = m.animacy;
startIndex = m.startIndex + 1;
endIndex = m.endIndex + 1;
headIndex = m.headIndex + 1;
corefClusterID = m.corefClusterID;
sentNum = m.sentNum + 1;
mentionID = m.mentionID;
mentionSpan = m.spanToString();
// index starts from 1
position = new IntTuple(2);
position.set(0, pos.get(0)+1);
position.set(1, pos.get(1)+1);
m.headWord.set(CorefCoreAnnotations.CorefClusterIdAnnotation.class, corefClusterID);
}
示例3: initializeCorefCluster
import edu.stanford.nlp.util.IntTuple; //导入方法依赖的package包/类
/** initialize positions and corefClusters (put each mention in each CorefCluster) */
private void initializeCorefCluster() {
for(int i = 0; i < predictedOrderedMentionsBySentence.size(); i ++){
for(int j = 0; j < predictedOrderedMentionsBySentence.get(i).size(); j ++){
Mention m = predictedOrderedMentionsBySentence.get(i).get(j);
if (allPredictedMentions.containsKey(m.mentionID)) {
SieveCoreferenceSystem.logger.warning("WARNING: Already contain mention " + m.mentionID);
Mention m1 = allPredictedMentions.get(m.mentionID);
SieveCoreferenceSystem.logger.warning("OLD mention: " + m1.spanToString() + "[" + m1.startIndex + "," + m1.endIndex + "]");
SieveCoreferenceSystem.logger.warning("NEW mention: " + m.spanToString() + "[" + m.startIndex + "," + m.endIndex + "]");
// SieveCoreferenceSystem.debugPrintMentions(System.err, "PREDICTED ORDERED", predictedOrderedMentionsBySentence);
// SieveCoreferenceSystem.debugPrintMentions(System.err, "GOLD ORDERED", goldOrderedMentionsBySentence);
}
assert(!allPredictedMentions.containsKey(m.mentionID));
allPredictedMentions.put(m.mentionID, m);
IntTuple pos = new IntTuple(2);
pos.set(0, i);
pos.set(1, j);
positions.put(m, pos);
m.sentNum = i;
assert(!corefClusters.containsKey(m.mentionID));
corefClusters.put(m.mentionID, new CorefCluster(m.mentionID, Generics.newHashSet(Arrays.asList(m))));
m.corefClusterID = m.mentionID;
IntTuple headPosition = new IntTuple(2);
headPosition.set(0, i);
headPosition.set(1, m.headIndex);
mentionheadPositions.put(headPosition, m);
}
}
}
示例4: findSpeaker
import edu.stanford.nlp.util.IntTuple; //导入方法依赖的package包/类
private boolean findSpeaker(int utterNum, int sentNum, List<CoreMap> sentences,
int startIndex, int endIndex, Dictionaries dict) {
List<CoreLabel> sent = sentences.get(sentNum).get(CoreAnnotations.TokensAnnotation.class);
for(int i = startIndex ; i < endIndex ; i++) {
if(sent.get(i).get(CoreAnnotations.UtteranceAnnotation.class)!=0) continue;
String lemma = sent.get(i).get(CoreAnnotations.LemmaAnnotation.class);
String word = sent.get(i).get(CoreAnnotations.TextAnnotation.class);
if(dict.reportVerb.contains(lemma)) {
// find subject
SemanticGraph dependency = sentences.get(sentNum).get(SemanticGraphCoreAnnotations.CollapsedDependenciesAnnotation.class);
IndexedWord w = dependency.getNodeByWordPattern(word);
if (w != null) {
for(Pair<GrammaticalRelation,IndexedWord> child : dependency.childPairs(w)){
if(child.first().getShortName().equals("nsubj")) {
String subjectString = child.second().word();
int subjectIndex = child.second().index(); // start from 1
IntTuple headPosition = new IntTuple(2);
headPosition.set(0, sentNum);
headPosition.set(1, subjectIndex-1);
String speaker;
if(mentionheadPositions.containsKey(headPosition)) {
speaker = Integer.toString(mentionheadPositions.get(headPosition).mentionID);
} else {
speaker = subjectString;
}
speakers.put(utterNum, speaker);
return true;
}
}
} else {
SieveCoreferenceSystem.logger.warning("Cannot find node in dependency for word " + word);
}
}
}
return false;
}
示例5: findParagraphSpeaker
import edu.stanford.nlp.util.IntTuple; //导入方法依赖的package包/类
private String findParagraphSpeaker(List<CoreMap> paragraph,
int paragraphUtterIndex, String nextParagraphSpeaker, int paragraphOffset, Dictionaries dict) {
if(!speakers.containsKey(paragraphUtterIndex)) {
if(!nextParagraphSpeaker.equals("")) {
speakers.put(paragraphUtterIndex, nextParagraphSpeaker);
} else { // find the speaker of this paragraph (John, nbc news)
CoreMap lastSent = paragraph.get(paragraph.size()-1);
String speaker = "";
boolean hasVerb = false;
for(int i = 0 ; i < lastSent.get(CoreAnnotations.TokensAnnotation.class).size() ; i++){
CoreLabel w = lastSent.get(CoreAnnotations.TokensAnnotation.class).get(i);
String pos = w.get(CoreAnnotations.PartOfSpeechAnnotation.class);
String ner = w.get(CoreAnnotations.NamedEntityTagAnnotation.class);
if(pos.startsWith("V")) {
hasVerb = true;
break;
}
if(ner.startsWith("PER")) {
IntTuple headPosition = new IntTuple(2);
headPosition.set(0, paragraph.size()-1 + paragraphOffset);
headPosition.set(1, i);
if(mentionheadPositions.containsKey(headPosition)) {
speaker = Integer.toString(mentionheadPositions.get(headPosition).mentionID);
}
}
}
if(!hasVerb && !speaker.equals("")) {
speakers.put(paragraphUtterIndex, speaker);
}
}
}
return findNextParagraphSpeaker(paragraph, paragraphOffset, dict);
}