本文整理汇总了Java中edu.stanford.nlp.stats.Counters.argmax方法的典型用法代码示例。如果您正苦于以下问题:Java Counters.argmax方法的具体用法?Java Counters.argmax怎么用?Java Counters.argmax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.stats.Counters
的用法示例。
在下文中一共展示了Counters.argmax方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: classify
import edu.stanford.nlp.stats.Counters; //导入方法依赖的package包/类
/**
* Score the given input, returning both the classification decision and the
* probability of that decision.
* Note that this method will not return a relation which does not type check.
*
* @param input The input to classify.
* @return A pair with the relation we classified into, along with its confidence.
*/
public Pair<String, Double> classify(KBPInput input) {
RVFDatum<String, String> datum = new RVFDatum<>(features(input));
Counter<String> scores = classifier.scoresOf(datum);
Counters.expInPlace(scores);
Counters.normalize(scores);
String best = Counters.argmax(scores);
// While it doesn't type check, continue going down the list.
// NO_RELATION is always an option somewhere in there, so safe to keep going...
while (!NO_RELATION.equals(best) &&
(RelationType.fromString(best).isPresent()
&& (!RelationType.fromString(best).get().validNamedEntityLabels.contains(input.objectType) ||
RelationType.fromString(best).get().entityType != input.subjectType))) {
scores.remove(best);
Counters.normalize(scores);
best = Counters.argmax(scores);
}
return Pair.makePair(best, scores.getCount(best));
}
示例2: classify
import edu.stanford.nlp.stats.Counters; //导入方法依赖的package包/类
/**
* Score the given input, returning both the classification decision and the
* probability of that decision.
* Note that this method will not return a relation which does not type check.
*
*
* @param input The input to classify.
* @return A pair with the relation we classified into, along with its confidence.
*/
public Pair<String,Double> classify(KBPInput input) {
RVFDatum<String, String> datum = new RVFDatum<>(features(input));
Counter<String> scores = classifier.scoresOf(datum);
Counters.expInPlace(scores);
Counters.normalize(scores);
String best = Counters.argmax(scores);
// While it doesn't type check, continue going down the list.
// NO_RELATION is always an option somewhere in there, so safe to keep going...
while (!NO_RELATION.equals(best) &&
(!edu.stanford.nlp.ie.KBPRelationExtractor.RelationType.fromString(best).get().validNamedEntityLabels.contains(input.objectType) ||
RelationType.fromString(best).get().entityType != input.subjectType) ) {
scores.remove(best);
Counters.normalize(scores);
best = Counters.argmax(scores);
}
return Pair.makePair(best, scores.getCount(best));
}
示例3: featurizeEecFineMaxNer
import edu.stanford.nlp.stats.Counters; //导入方法依赖的package包/类
public static void featurizeEecFineMaxNer(ConnectedComponent cc) {
for (int i = 0; i < cc.tuples.size(); i++) {
Tuple t = cc.tuples.get(i);
Factor tf = cc.tupleFactors.get(i);
Counter<String> t1s = t.getArg1FineGrainedNer();
Counter<String> t2s = t.getArg2FineGrainedNer();
String fner1max = Counters.argmax(t1s);
String fner2max = Counters.argmax(t2s);
if ((fner1max.equals(cc.eventtype.arg1type)
|| cc.eventtype.arg1typelen > 1 && t1s.getCount(cc.eventtype.arg1type) > 0)
&& (fner2max.equals(cc.eventtype.arg2type)
|| cc.eventtype.arg2typelen > 1 && t2s.getCount(cc.eventtype.arg2type) > 0)) {
tf.add("[email protected]" + cc.eventtype.arg1type + "_" + cc.eventtype.arg2type);
// tf.add("fnermax");
}
}
}
示例4: featurizeEecFineMaxNer
import edu.stanford.nlp.stats.Counters; //导入方法依赖的package包/类
public static void featurizeEecFineMaxNer(ConnectedComponent cc) {
for (int i = 0; i < cc.tuples.size(); i++) {
Tuple t = cc.tuples.get(i);
Factor tf = cc.tupleFactors.get(i);
Counter<String> t1s = t.getArg1FineGrainedNer();
Counter<String> t2s = t.getArg2FineGrainedNer();
String fner1max = Counters.argmax(t1s);
String fner2max = Counters.argmax(t2s);
if ((fner1max.equals(cc.eventtype.arg1type) ||
cc.eventtype.arg1typelen > 1
&& t1s.getCount(cc.eventtype.arg1type) > 0)
&&
(fner2max.equals(cc.eventtype.arg2type) ||
cc.eventtype.arg2typelen > 1
&& t2s.getCount(cc.eventtype.arg2type) > 0)) {
tf.add("[email protected]" + cc.eventtype.arg1type + "_"
+ cc.eventtype.arg2type);
// tf.add("fnermax");
}
}
}
示例5: classOf
import edu.stanford.nlp.stats.Counters; //导入方法依赖的package包/类
@Override
public L classOf(Datum<L, F> example) {
if(example instanceof RVFDatum<?, ?>)return classOfRVFDatum((RVFDatum<L,F>)example);
Counter<L> scores = scoresOf(example);
return Counters.argmax(scores);
}
示例6: classOfRVFDatum
import edu.stanford.nlp.stats.Counters; //导入方法依赖的package包/类
private L classOfRVFDatum(RVFDatum<L, F> example) {
Counter<L> scores = scoresOfRVFDatum(example);
return Counters.argmax(scores);
}
示例7: classOf
import edu.stanford.nlp.stats.Counters; //导入方法依赖的package包/类
public L classOf(Datum<L, F> example) {
if(example instanceof RVFDatum<?, ?>)return classOfRVFDatum((RVFDatum<L,F>)example);
Counter<L> scores = scoresOf(example);
return Counters.argmax(scores);
}
示例8: bestSequence
import edu.stanford.nlp.stats.Counters; //导入方法依赖的package包/类
/**
* Runs the Viterbi algorithm on the sequence model given by the TagScorer
* in order to find the best sequence.
* @return an array containing the int tags of the best sequence
*/
public int[] bestSequence(SequenceModel ts) {
return Counters.argmax(kBestSequences(ts, 1));
}