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


Java MutableInteger.intValue方法代码示例

本文整理汇总了Java中edu.stanford.nlp.util.MutableInteger.intValue方法的典型用法代码示例。如果您正苦于以下问题:Java MutableInteger.intValue方法的具体用法?Java MutableInteger.intValue怎么用?Java MutableInteger.intValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.util.MutableInteger的用法示例。


在下文中一共展示了MutableInteger.intValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTerminal

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
static Tree getTerminal(Tree tree, MutableInteger i, int n) {
  if (i.intValue() == n) {
    if (tree.isLeaf()) {
      return tree;
    } else {
      return getTerminal(tree.children()[0], i, n);
    }
  } else {
    if (tree.isLeaf()) {
      i.set(i.intValue() + tree.yield().size());
      return null;
    } else {
      Tree[] kids = tree.children();
      for (int j = 0; j < kids.length; j++) {
        Tree result = getTerminal(kids[j], i, n);
        if (result != null) {
          return result;
        }
      }
      return null;
    }
  }
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:24,代码来源:Trees.java

示例2: getPreTerminal

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
static Tree getPreTerminal(Tree tree, MutableInteger i, int n) {
  if (i.intValue() == n) {
    if (tree.isPreTerminal()) {
      return tree;
    } else {
      return getPreTerminal(tree.children()[0], i, n);
    }
  } else {
    if (tree.isPreTerminal()) {
      i.set(i.intValue() + tree.yield().size());
      return null;
    } else {
      Tree[] kids = tree.children();
      for (int j = 0; j < kids.length; j++) {
        Tree result = getPreTerminal(kids[j], i, n);
        if (result != null) {
          return result;
        }
      }
      return null;
    }
  }
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:24,代码来源:Trees.java

示例3: indexSpans

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
/**
 * Assigns span indices (BeginIndexAnnotation and EndIndexAnnotation) to all nodes in a tree.
 * The beginning index is equivalent to the IndexAnnotation of the first leaf in the constituent.
 * The end index is equivalent to the first integer after the IndexAnnotation of the last leaf in the constituent. 
 * @param startIndex Begin indexing at this value
 */
public Pair<Integer, Integer> indexSpans(MutableInteger startIndex) {
  int start = Integer.MAX_VALUE;
  int end = Integer.MIN_VALUE;
      
  if(isLeaf()){
    start = startIndex.intValue();
    end = startIndex.intValue() + 1;
    startIndex.incValue(1);
  } else {
    for (Tree kid : children()) {
      Pair<Integer, Integer>  span = kid.indexSpans(startIndex);
      if(span.first < start) start = span.first;
      if(span.second > end) end = span.second;
    }
  }
  
  CoreMap afl = (CoreMap) label();
  afl.set(BeginIndexAnnotation.class, start);
  afl.set(EndIndexAnnotation.class, end);
  return new Pair<Integer, Integer>(start, end);
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:28,代码来源:Tree.java

示例4: getTerminal

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
static Tree getTerminal(Tree tree, MutableInteger i, int n) {
  if (i.intValue() == n) {
    if (tree.isLeaf()) {
      return tree;
    } else {
      return getTerminal(tree.children()[0], i, n);
    }
  } else {
    if (tree.isLeaf()) {
      i.set(i.intValue() + tree.yield().size());
      return null;
    } else {
      for (Tree kid : tree.children()) {
        Tree result = getTerminal(kid, i, n);
        if (result != null) {
          return result;
        }
      }
      return null;
    }
  }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:23,代码来源:Trees.java

示例5: getPreTerminal

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
static Tree getPreTerminal(Tree tree, MutableInteger i, int n) {
  if (i.intValue() == n) {
    if (tree.isPreTerminal()) {
      return tree;
    } else {
      return getPreTerminal(tree.children()[0], i, n);
    }
  } else {
    if (tree.isPreTerminal()) {
      i.set(i.intValue() + tree.yield().size());
      return null;
    } else {
      for (Tree kid : tree.children()) {
        Tree result = getPreTerminal(kid, i, n);
        if (result != null) {
          return result;
        }
      }
      return null;
    }
  }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:23,代码来源:Trees.java

示例6: indexSpans

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
/**
 * Assigns span indices (BeginIndexAnnotation and EndIndexAnnotation) to all nodes in a tree.
 * The beginning index is equivalent to the IndexAnnotation of the first leaf in the constituent.
 * The end index is equivalent to the first integer after the IndexAnnotation of the last leaf in the constituent.
 * @param startIndex Begin indexing at this value
 */
public Pair<Integer, Integer> indexSpans(MutableInteger startIndex) {
  int start = Integer.MAX_VALUE;
  int end = Integer.MIN_VALUE;

  if(isLeaf()){
    start = startIndex.intValue();
    end = startIndex.intValue() + 1;
    startIndex.incValue(1);
  } else {
    for (Tree kid : children()) {
      Pair<Integer, Integer>  span = kid.indexSpans(startIndex);
      if(span.first < start) start = span.first;
      if(span.second > end) end = span.second;
    }
  }

  CoreLabel afl = (CoreLabel) label();
  afl.set(BeginIndexAnnotation.class, start);
  afl.set(EndIndexAnnotation.class, end);
  return new Pair<Integer, Integer>(start, end);
}
 
开发者ID:chbrown,项目名称:stanford-parser,代码行数:28,代码来源:Tree.java

示例7: indexSpans

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
/**
 * Assigns span indices (BeginIndexAnnotation and EndIndexAnnotation) to all nodes in a tree.
 * The beginning index is equivalent to the IndexAnnotation of the first leaf in the constituent.
 * The end index is equivalent to the first integer after the IndexAnnotation of the last leaf in the constituent.
 * @param startIndex Begin indexing at this value
 */
public Pair<Integer, Integer> indexSpans(MutableInteger startIndex) {
  int start = Integer.MAX_VALUE;
  int end = Integer.MIN_VALUE;

  if(isLeaf()){
    start = startIndex.intValue();
    end = startIndex.intValue() + 1;
    startIndex.incValue(1);
  } else {
    for (Tree kid : children()) {
      Pair<Integer, Integer>  span = kid.indexSpans(startIndex);
      if(span.first < start) start = span.first;
      if(span.second > end) end = span.second;
    }
  }

  CoreLabel afl = (CoreLabel) label();
  afl.set(CoreAnnotations.BeginIndexAnnotation.class, start);
  afl.set(CoreAnnotations.EndIndexAnnotation.class, end);
  return new Pair<Integer, Integer>(start, end);
}
 
开发者ID:jaimeguzman,项目名称:data_mining,代码行数:28,代码来源:Tree.java

示例8: setFutureCosts

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
private double[] setFutureCosts(int sourceInputId, Derivation<TK, FV> hyp,
    FeatureExtractor<TK, FV> featurizer, Scorer<FV> scorer) {

  // Do we clear the cache of future cost?
  MutableInteger lastId = tlTranslationId.get();
  @SuppressWarnings("rawtypes")
  Map<SegId, Double> fcCache = tlCache.get();
  if (lastId.intValue() != sourceInputId) {
    fcCache.clear();
    lastId.set(sourceInputId);
  }

  DTURule<TK> opt = (DTURule<TK>) concreteOpt.abstractRule;
  double[] fc = new double[opt.dtus.length];

  assert (segmentIdx == 0);
  for (int i = segmentIdx + 1; i < opt.dtus.length; ++i) {
    SegId<TK> id = new SegId<TK>(opt, i);
    Double score = fcCache.get(id);
    if (score == null) {
      Featurizable<TK, FV> f = new DTUFeaturizable<TK, FV>(
          hyp.sourceSequence, hyp.sourceInputProperties, concreteOpt, sourceInputId, i);
      List<FeatureValue<FV>> phraseFeatures = featurizer
          .ruleFeaturize(f);
      score = scorer.getIncrementalScore(phraseFeatures);
      fcCache.put(id, score);
    }
    fc[i] = score;
    // System.err.printf("Future cost: id=%d phrase={%s} features=%s fc=%.3f\n",
    // translationId, opt.dtus[i], phraseFeatures, fc[i]);
  }
  return fc;
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:34,代码来源:DTUHypothesis.java

示例9: getIntCount

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
/**
 * Returns the current count for the given key, which is 0 if it hasn't
 * been
 * seen before. This is a convenient version of <code>get</code> that casts
 * and extracts the primitive value.
 */
public int getIntCount(E key) {
  MutableInteger count =  map.get(key);
  if (count == null) {
    return defaultValue; // haven't seen this object before -> 0 count
  }
  return count.intValue();
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:14,代码来源:IntCounter.java

示例10: leftEdge

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
/**
   * Returns the positional index of the left edge of a tree <i>t</i>
   * within a given root, as defined by the size of the yield of all
   * material preceding <i>t</i>.
   */
  public static int leftEdge(Tree t, Tree root) {
    MutableInteger i = new MutableInteger(0);
    if (leftEdge(t, root, i)) {
      return i.intValue();
    } else {
      throw new RuntimeException("Tree is not a descendent of root.");
//      return -1;
    }
  }
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:15,代码来源:Trees.java

示例11: rightEdge

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
/**
   * Returns the positional index of the right edge of a tree
   * <i>t</i> within a given root, as defined by the size of the yield
   * of all material preceding <i>t</i> plus all the material
   * contained in <i>t</i>.
   */
  public static int rightEdge(Tree t, Tree root) {
    MutableInteger i = new MutableInteger(root.yield().size());
    if (rightEdge(t, root, i)) {
      return i.intValue();
    } else {
      throw new RuntimeException("Tree is not a descendent of root.");
//      return root.yield().size() + 1;
    }
  }
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:16,代码来源:Trees.java

示例12: leftCharEdge

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
/**
 * Returns the positional index of the left edge of  <i>node</i> within the tree,
 * as measured by characters.  Returns -1 if <i>node is not found.</i>
 */
public int leftCharEdge(Tree node) {
  MutableInteger i = new MutableInteger(0);
  if (leftCharEdge(node, i)) {
    return i.intValue();
  }
  return -1;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:12,代码来源:Tree.java

示例13: rightCharEdge

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
/**
 * Returns the positional index of the right edge of  <i>node</i> within the tree,
 * as measured by characters. Returns -1 if <i>node is not found.</i>
 *
 * rightCharEdge returns the index of the rightmost character + 1, so that
 * rightCharEdge(getLeaves().get(i)) == leftCharEdge(getLeaves().get(i+1))
 *
 * @param node The subtree to look for in this Tree
 * @return The positional index of the right edge of node
 */
public int rightCharEdge(Tree node) {
  List<Tree> s = getLeaves();
  int length = 0;
  for (Tree leaf : s) {
    length += leaf.label().value().length();
  }
  MutableInteger i = new MutableInteger(length);
  if (rightCharEdge(node, i)) {
    return i.intValue();
  }
  return -1;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:23,代码来源:Tree.java

示例14: nodeNumber

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
/**
 * Calculates the node's <i>number</i>, defined as the number of nodes traversed in a left-to-right, depth-first search of the
 * tree starting at <code>root</code> and ending at <code>this</code>.  Returns -1 if <code>root</code> does not contain <code>this</code>.
 * @param root the root node of the relevant tree
 * @return the number of the current node, or -1 if <code>root</code> does not contain <code>this</code>.
 */
public int nodeNumber(Tree root) {
  MutableInteger i = new MutableInteger(1);
  if(nodeNumberHelper(root,i))
    return i.intValue();
  return -1;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:13,代码来源:Tree.java

示例15: getNodeNumberHelper

import edu.stanford.nlp.util.MutableInteger; //导入方法依赖的package包/类
private Tree getNodeNumberHelper(MutableInteger i, int target) {
  int i1 = i.intValue();
  if(i1 == target)
    return this;
  if(i1 > target)
    throw new IndexOutOfBoundsException("Error -- tree does not contain " + i + " nodes.");
  i.incValue(1);
  for(int j = 0; j < children().length; j++) {
    Tree temp = children()[j].getNodeNumberHelper(i, target);
    if(temp != null)
      return temp;
  }
  return null;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:15,代码来源:Tree.java


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