Java Pair.makePair方法代码示例(javapair.makepair方法的典型用法代码示例)

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


Java Pair.makePair方法代码示例(javapair.makepair方法的典型用法代码示例)

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

示例1: classify

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
@Override
public Pair<String, Double> classify(KBPInput input) {
    for (RelationType rel : RelationType.values()) {

        if (rules.containsKey(rel) &&
                rel.entityType == input.subjectType &&
                rel.validNamedEntityLabels.contains(input.objectType)) {
            Collection<SemgrexPattern> rulesForRel = rules.get(rel);
            CoreMap sentence = input.sentence.asCoreMap(Sentence::nerTags, Sentence::dependencyGraph);
            boolean matches
                    = matches(sentence, rulesForRel, input,
                    sentence.get(SemanticGraphCoreAnnotations.EnhancedPlusPlusDependenciesAnnotation.class)) ||
                    matches(sentence, rulesForRel, input,
                            sentence.get(SemanticGraphCoreAnnotations.AlternativeDependenciesAnnotation.class));
            if (matches) {
                //logger.log("MATCH for " + rel +  ". " + sentence: + sentence + " with rules for  " + rel);
                return Pair.makePair(rel.canonicalName, 1.0);
            }
        }
    }

    return Pair.makePair(NO_RELATION, 1.0);
} 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:24,代码来源:IntelKBPSemgrexExtractor.java

示例2: classify

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
@Override
public Pair<String, Double> classify(KBPInput input) {
  for (RelationType rel : RelationType.values()) {

    if (rules.containsKey(rel) &&
        rel.entityType == input.subjectType &&
        rel.validNamedEntityLabels.contains(input.objectType)) {
      Collection<SemgrexPattern> rulesForRel = rules.get(rel);
      CoreMap sentence = input.sentence.asCoreMap(Sentence::nerTags, Sentence::dependencyGraph);
      boolean matches
          = matches(sentence, rulesForRel, input,
          sentence.get(SemanticGraphCoreAnnotations.EnhancedPlusPlusDependenciesAnnotation.class)) ||
          matches(sentence, rulesForRel, input,
              sentence.get(SemanticGraphCoreAnnotations.AlternativeDependenciesAnnotation.class));
      if (matches) {
        //logger.log("MATCH for " + rel +  ". " + sentence: + sentence + " with rules for  " + rel);
        return Pair.makePair(rel.canonicalName, 1.0);
      }
    }
  }

  return Pair.makePair(NO_RELATION, 1.0);
} 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:24,代码来源:KBPSemgrexExtractor.java

示例3: classifyWithHighPrecision

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
private Pair<String, Double> classifyWithHighPrecision(KBPInput input) {
    Pair<String, Double> prediction = Pair.makePair(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION, 1.0);
    for (IntelKBPRelationExtractor extractor : extractors) {
        if (!extractor.getClass().equals(IntelKBPTokensregexExtractor.class)) continue;
        return extractor.classify(input);
    }
    return prediction;
} 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:9,代码来源:IntelKBPEnsembleExtractor.java

示例4: classifyWithHighRecall

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
private Pair<String, Double> classifyWithHighRecall(KBPInput input) {
    Pair<String, Double> prediction = Pair.makePair(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION, 1.0);
    for (IntelKBPRelationExtractor extractor : extractors) {
        Pair<String, Double> classifierPrediction = extractor.classify(input);
        logger.info(extractor.getClass().getSimpleName() + ": " + classifierPrediction + " for " + input.getObjectText() + " - " + input.getSubjectText());
        if (!classifierPrediction.first.equals(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION)) {
            if (prediction.first.equals(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION))
                prediction = classifierPrediction;
            else {
                prediction = classifierPrediction.second > prediction.second ? classifierPrediction : prediction;
            }
        }
    }
    return prediction;
} 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:16,代码来源:IntelKBPEnsembleExtractor.java

示例5: classifyWithVote

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
private Pair<String, Double> classifyWithVote(KBPInput input) {
    HashMap<String, Double> relation2Weights = new HashMap<>();
    Pair<String, Double> prediction = Pair.makePair(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION, 0.0);
    for (IntelKBPRelationExtractor extractor : extractors) {
        Pair<String, Double> classifierPrediction = extractor.classify(input);
        logger.info(extractor.getClass().getSimpleName() + ": " + classifierPrediction + " for " + input.getObjectText() + " - " + input.getSubjectText());
        Double weight = relation2Weights.get(classifierPrediction.first);
        Double newWeight = weight == null ? 1.0 / extractors.length : weight + 1.0 / extractors.length;
        relation2Weights.put(classifierPrediction.first, newWeight);
        if (newWeight > prediction.second) prediction = Pair.makePair(classifierPrediction.first, newWeight);
    }
    return prediction;
} 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:14,代码来源:IntelKBPEnsembleExtractor.java

示例6: classifyWithWeightedVote

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
private Pair<String, Double> classifyWithWeightedVote(KBPInput input) {
        HashMap<String, Double> relation2Weights = new HashMap<>();
        Pair<String, Double> prediction = Pair.makePair(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION, 0.0);
        for (IntelKBPRelationExtractor extractor : extractors) {
            Pair<String, Double> classifierPrediction = extractor.classify(input);
            logger.info(extractor.getClass().getSimpleName() + ": " + classifierPrediction + " for " + input.getObjectText() + " - " + input.getSubjectText());
//            if (classifierPrediction.first.equals(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION)) continue;
            Double weight = relation2Weights.get(classifierPrediction.first);
            Double newWeight = weight == null ? ModelWeight.getWeight(extractor) : weight + ModelWeight.getWeight(extractor);
            relation2Weights.put(classifierPrediction.first, newWeight);
            if (newWeight > prediction.second) prediction = Pair.makePair(classifierPrediction.first, newWeight);
        }
        return prediction;
    } 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:15,代码来源:IntelKBPEnsembleExtractor.java

示例7: classifyWithHighestScore

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
private Pair<String, Double> classifyWithHighestScore(KBPInput input) {
    Pair<String, Double> prediction = Pair.makePair(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION, 1.0);
    for (IntelKBPRelationExtractor extractor : extractors) {
        Pair<String, Double> classifierPrediction = extractor.classify(input);
        logger.info(extractor.getClass().getSimpleName() + ": " + classifierPrediction + " for " + input.getObjectText() + " - " + input.getSubjectText());
        if (prediction.first.equals(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION) ||
                (!classifierPrediction.first.equals(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION) &&
                        classifierPrediction.second > prediction.second)
                ) {
            // The last prediction was NO_RELATION, or this is not NO_RELATION and has a higher score
            prediction = classifierPrediction;
        }
    }
    return prediction;
} 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:16,代码来源:IntelKBPEnsembleExtractor.java

示例8: classifyDefault

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
private Pair<String, Double> classifyDefault(KBPInput input) {
    Pair<String, Double> prediction = Pair.makePair(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION, 1.0);
    for (IntelKBPRelationExtractor extractor : extractors) {
        Pair<String, Double> classifierPrediction = extractor.classify(input);
        if (prediction.first.equals(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION) ||
                (!classifierPrediction.first.equals(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION) &&
                        classifierPrediction.second > prediction.second)
                ){
            // The last prediction was NO_RELATION, or this is not NO_RELATION and has a higher score
            prediction = classifierPrediction;
        }
    }
    return prediction;
} 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:15,代码来源:IntelKBPEnsembleExtractor.java

示例9: classify

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
@Override
public Pair<String, Double> classify(KBPInput input) {
  Pair<String, Double> prediction = Pair.makePair(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION, 1.0);
  for (edu.stanford.nlp.ie.KBPRelationExtractor extractor : extractors) {
    Pair<String, Double> classifierPrediction = extractor.classify(input);
    if (prediction.first.equals(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION) ||
        (!classifierPrediction.first.equals(edu.stanford.nlp.ie.KBPRelationExtractor.NO_RELATION) &&
            classifierPrediction.second > prediction.second)
        ){
      // The last prediction was NO_RELATION, or this is not NO_RELATION and has a higher score
      prediction = classifierPrediction;
    }
  }
  return prediction;
} 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:16,代码来源:KBPEnsembleExtractor.java

示例10: annotate

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
@Override
public void annotate(Annotation annotation) {
    if (stopwords != null && stopwords.size() > 0 && annotation.containsKey(TokensAnnotation.class)) {
        List<CoreLabel> tokens = annotation.get(TokensAnnotation.class);
        for (CoreLabel token : tokens) {
            boolean isWordStopword = stopwords.contains(token.word().toLowerCase());
            boolean isLemmaStopword = checkLemma ? stopwords.contains(token.lemma().toLowerCase()) : false;
            Pair<Boolean, Boolean> pair = Pair.makePair(isWordStopword, isLemmaStopword);
            token.set(StopwordAnnotator.class, pair);
        }
    }
} 
开发者ID:asimihsan,项目名称:handytrowel,代码行数:13,代码来源:StopwordAnnotator.java

示例11: annotate

import edu.stanford.nlp.util.Pair; //导入方法依赖的package包/类
@Override
public void annotate(Annotation annotation) {
    if (stopwords != null && stopwords.size() > 0 && annotation.containsKey(TokensAnnotation.class)) {
        List<CoreLabel> tokens = annotation.get(TokensAnnotation.class);
        for (CoreLabel token : tokens) {
            boolean isWordStopword = stopwords.contains(token.word().toLowerCase());
            boolean isLemmaStopword = checkLemma ? stopwords.contains(token.word().toLowerCase()) : false;
            Pair<Boolean, Boolean> pair = Pair.makePair(isWordStopword, isLemmaStopword);
            token.set(StopwordAnnotator.class, pair);
        }
    }
} 
开发者ID:jconwell,项目名称:coreNlp,代码行数:13,代码来源:StopwordAnnotator.java

本文标签属性:

示例:示例志愿表

代码:代码大全可复制

java:java模拟器

Pair:pairs

makePair:makePair

上一篇:储量的意思储量的意思是什么(储量的词语解释)
下一篇:C++ Lobby::run方法代码示例(c++lobby::run方法的典型用法代码示例)

为您推荐