本文整理汇总了Java中edu.stanford.nlp.util.Generics.newPair方法的典型用法代码示例。如果您正苦于以下问题:Java Generics.newPair方法的具体用法?Java Generics.newPair怎么用?Java Generics.newPair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.util.Generics
的用法示例。
在下文中一共展示了Generics.newPair方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evalPrecision
import edu.stanford.nlp.util.Generics; //导入方法依赖的package包/类
Pair<ClassicCounter<OUT>, ClassicCounter<OUT>> evalPrecision(Collection<IN> guesses, Collection<IN> golds) {
Collection<IN> internalGuesses = null;
Collection<IN> internalGolds = null;
if(bagEval) {
internalGuesses = new ArrayList<IN>(guesses.size());
internalGolds = new ArrayList<IN>(golds.size());
}
else {
internalGuesses = new HashSet<IN>(guesses.size());
internalGolds = new HashSet<IN>(golds.size());
}
internalGuesses.addAll(guesses);
internalGolds.addAll(golds);
ClassicCounter<OUT> thisGuessed = new ClassicCounter<OUT>();
ClassicCounter<OUT> thisCorrect = new ClassicCounter<OUT>();
for (IN o : internalGuesses) {
OUT equivalenceClass = eq.equivalenceClass(o);
thisGuessed.incrementCount(equivalenceClass);
if (checker.contained(o, internalGolds)) {
thisCorrect.incrementCount(equivalenceClass);
removeItem(o,internalGolds,checker);
} else {
if (verbose) {
System.out.println("Eval missed " + o);
}
}
}
return Generics.newPair(thisGuessed, thisCorrect);
}
示例2: addArc
import edu.stanford.nlp.util.Generics; //导入方法依赖的package包/类
/**
* @return true if and only if it added Arc a to the graph.
* determinism.
*/
protected boolean addArc(Arc a) {
Object source = a.getSourceNode();
Object target = a.getTargetNode();
Object input = a.getInput();
if (source == null || target == null || input == null) {
return false;
}
// add to data structures
if (arcs.contains(a)) {
return false;
}
// it's new, so add to the rest of the data structures
// add to source and input map
Pair p = Generics.newPair(source, input);
if (arcsBySourceAndInput.containsKey(p) && checkDeterminism) {
throw new RuntimeException("Creating nondeterminism while inserting arc " + a + " because it already has arc " + arcsBySourceAndInput.get(p) + checkDeterminism);
}
arcsBySourceAndInput.put(p, a);
Maps.putIntoValueHashSet(arcsBySource, source, a);
p = Generics.newPair(target, input);
Maps.putIntoValueHashSet(arcsByTargetAndInput, p, a);
Maps.putIntoValueHashSet(arcsByTarget, target, a);
Maps.putIntoValueHashSet(arcsByInput, input, a);
// add to arcs
arcs.add(a);
return true;
}
示例3: canAddArc
import edu.stanford.nlp.util.Generics; //导入方法依赖的package包/类
public boolean canAddArc(Object source, Object target, Object input, Object output) {
Arc a = new Arc(source, target, input, output);
if (arcs.contains(a)) // inexpensive check
{
return false;
}
Pair p = Generics.newPair(source, input);
return !arcsBySourceAndInput.containsKey(p); // expensive check
}
示例4: removeArc
import edu.stanford.nlp.util.Generics; //导入方法依赖的package包/类
public boolean removeArc(Arc a) {
Object source = a.getSourceNode();
Object target = a.getTargetNode();
Object input = a.getInput();
// remove from arcs
if (!arcs.remove(a)) {
return false;
}
// remove from arcsBySourceAndInput
Pair p = Generics.newPair(source, input);
if (!arcsBySourceAndInput.containsKey(p)) {
return false;
}
arcsBySourceAndInput.remove(p);
// remove from arcsBySource
Set<Arc> s = arcsBySource.get(source);
if (s == null) {
return false;
}
if (!s.remove(a)) {
return false;
}
// remove from arcsByTargetAndInput
p = Generics.newPair(target, input);
s = arcsByTargetAndInput.get(p);
if (s == null) {
return false;
}
if (!s.remove(a)) {
return false;
}
// remove from arcsByTarget
s = arcsByTarget.get(target);
if (s == null) {
return false;
}
s = arcsByInput.get(input);
if (s == null) {
return false;
}
if (!s.remove(a)) {
return false;
}
return true;
}