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


Java Counters.argmax方法代码示例

本文整理汇总了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));
}
 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:27,代码来源:KBPStatisticalExtractor.java

示例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));
}
 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:27,代码来源:KBPStatisticalExtractor.java

示例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");
		}
	}
}
 
开发者ID:zhangcongle,项目名称:NewsSpikeRe,代码行数:18,代码来源:NewsSpikeExtractor.java

示例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");
		}
	}
}
 
开发者ID:zhangcongle,项目名称:NewsSpikeRe,代码行数:22,代码来源:NewsSpikeGenerate.java

示例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);
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:7,代码来源:LinearClassifier.java

示例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);
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:5,代码来源:LinearClassifier.java

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

示例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));
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:9,代码来源:KBestSequenceFinder.java


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