当前位置: 首页>>代码示例>>Java>>正文


Java IntTuple.set方法代码示例

本文整理汇总了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;
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:26,代码来源:Document.java

示例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);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:21,代码来源:CorefChain.java

示例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);
      }
    }
  }
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:34,代码来源:Document.java

示例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;
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:38,代码来源:Document.java

示例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);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:34,代码来源:Document.java


注:本文中的edu.stanford.nlp.util.IntTuple.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。