本文整理汇总了Java中edu.stanford.nlp.util.MutableInteger类的典型用法代码示例。如果您正苦于以下问题:Java MutableInteger类的具体用法?Java MutableInteger怎么用?Java MutableInteger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MutableInteger类属于edu.stanford.nlp.util包,在下文中一共展示了MutableInteger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toString
import edu.stanford.nlp.util.MutableInteger; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public String toString(NumberFormat nf, String preAppend, String postAppend, String keyValSeparator, String itemSeparator) {
StringBuilder sb = new StringBuilder();
sb.append(preAppend);
List<E> list = new ArrayList<E>(map.keySet());
try {
Collections.sort((List)list); // see if it can be sorted
} catch (Exception e) {
}
for (Iterator<E> iter = list.iterator(); iter.hasNext();) {
Object key = iter.next();
MutableInteger d = map.get(key);
sb.append(key + keyValSeparator);
sb.append(nf.format(d));
if (iter.hasNext()) {
sb.append(itemSeparator);
}
}
sb.append(postAppend);
return sb.toString();
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:22,代码来源:IntCounter.java
示例2: leftEdge
import edu.stanford.nlp.util.MutableInteger; //导入依赖的package包/类
static boolean leftEdge(Tree t, Tree t1, MutableInteger i) {
if (t == t1) {
return true;
} else if (t1.isLeaf()) {
int j = t1.yield().size(); // so that empties don't add size
i.set(i.intValue() + j);
return false;
} else {
Tree[] kids = t1.children();
for (int j = 0, n = kids.length; j < n; j++) {
if (leftEdge(t, kids[j], i)) {
return true;
}
}
return false;
}
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:18,代码来源:Trees.java
示例3: rightEdge
import edu.stanford.nlp.util.MutableInteger; //导入依赖的package包/类
static boolean rightEdge(Tree t, Tree t1, MutableInteger i) {
if (t == t1) {
return true;
} else if (t1.isLeaf()) {
int j = t1.yield().size(); // so that empties don't add size
i.set(i.intValue() - j);
return false;
} else {
Tree[] kids = t1.children();
for (int j = kids.length - 1; j >= 0; j--) {
if (rightEdge(t, kids[j], i)) {
return true;
}
}
return false;
}
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:18,代码来源:Trees.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 {
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
示例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 {
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
示例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;
}
}
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
示例7: 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
示例8: 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
示例9: 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:paulirwin,项目名称:Stanford.NER.Net,代码行数:28,代码来源:Tree.java
示例10: 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:amark-india,项目名称:eventspotter,代码行数:28,代码来源:Tree.java
示例11: leftEdge
import edu.stanford.nlp.util.MutableInteger; //导入依赖的package包/类
static boolean leftEdge(Tree t, Tree t1, MutableInteger i) {
if (t == t1) {
return true;
} else if (t1.isLeaf()) {
int j = t1.yield().size(); // so that empties don't add size
i.set(i.intValue() + j);
return false;
} else {
for (Tree kid : t1.children()) {
if (leftEdge(t, kid, i)) {
return true;
}
}
return false;
}
}
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:17,代码来源:Trees.java
示例12: toString
import edu.stanford.nlp.util.MutableInteger; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public String toString(NumberFormat nf) {
StringBuilder sb = new StringBuilder();
sb.append("{");
List<E> list = new ArrayList<E>(map.keySet());
try {
Collections.sort((List)list); // see if it can be sorted
} catch (Exception e) {
}
for (Iterator<E> iter = list.iterator(); iter.hasNext();) {
Object key = iter.next();
MutableInteger d = map.get(key);
sb.append(key + "=");
sb.append(nf.format(d));
if (iter.hasNext()) {
sb.append(", ");
}
}
sb.append("}");
return sb.toString();
}
开发者ID:chbrown,项目名称:stanford-parser,代码行数:22,代码来源:IntCounter.java
示例13: 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
示例14: 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
示例15: remove
import edu.stanford.nlp.util.MutableInteger; //导入依赖的package包/类
/**
* Removes the given key from this Counter. Its count will now be 0 and it
* will no longer be considered previously seen.
*/
public double remove(E key) {
totalCount -= getCount(key); // subtract removed count from total (may be 0)
MutableInteger val = map.remove(key);
if (val == null) {
return Double.NaN;
} else {
return val.doubleValue();
}
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:14,代码来源:IntCounter.java
示例16: values
import edu.stanford.nlp.util.MutableInteger; //导入依赖的package包/类
public Collection<Double> values() {
return new AbstractCollection<Double>() {
@Override
public Iterator<Double> iterator() {
return new Iterator<Double>() {
Iterator<MutableInteger> inner = map.values().iterator();
public boolean hasNext() {
return inner.hasNext();
}
public Double next() {
return inner.next().doubleValue();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
@Override
public int size() {
return map.size();
}
};
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:28,代码来源:IntCounter.java
示例17: 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
示例18: 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
示例19: 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
示例20: nodeNumberHelper
import edu.stanford.nlp.util.MutableInteger; //导入依赖的package包/类
private boolean nodeNumberHelper(Tree t, MutableInteger i) {
if(this==t)
return true;
i.incValue(1);
for(int j = 0; j < t.children().length; j++) {
if(nodeNumberHelper(t.children()[j],i))
return true;
}
return false;
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:11,代码来源:Tree.java
注:本文中的edu.stanford.nlp.util.MutableInteger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论