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


Java ImmutableMultimap.get方法代码示例

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


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

示例1: blame

import com.google.common.collect.ImmutableMultimap; //导入方法依赖的package包/类
public String blame(XmlDocument xmlDocument)
        throws IOException, SAXException, ParserConfigurationException {

    ImmutableMultimap<Integer, Record> resultingSourceMapping =
            getResultingSourceMapping(xmlDocument);
    LineReader lineReader = new LineReader(
            new StringReader(xmlDocument.prettyPrint()));

    StringBuilder actualMappings = new StringBuilder();
    String line;
    int count = 1;
    while ((line = lineReader.readLine()) != null) {
        actualMappings.append(count).append(line).append("\n");
        if (resultingSourceMapping.containsKey(count)) {
            for (Record record : resultingSourceMapping.get(count)) {
                actualMappings.append(count).append("-->")
                        .append(record.getActionLocation().toString())
                        .append("\n");
            }
        }
        count++;
    }
    return actualMappings.toString();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:25,代码来源:Actions.java

示例2: immutableMultiMapCollector

import com.google.common.collect.ImmutableMultimap; //导入方法依赖的package包/类
@Test
public void immutableMultiMapCollector() {
	ImmutableMultimap<Integer, Integer> result = Stream.iterate(0, p -> p+1)
			.parallel()
			.limit(GENERATED_ITEMS)
			.collect(Collectors.groupingBy(i -> i % 10));
	
	assertEquals(GENERATED_ITEMS,result.size());
	assertEquals(10,result.asMap().size());
	for (int i=0;i<10;i++) {
		int key=i;
		ImmutableCollection<Integer> values = result.get(key);
		values.forEach(v -> {
			assertEquals(key,v % 10);
		});
	}
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:18,代码来源:CollectorsTest.java

示例3: align

import com.google.common.collect.ImmutableMultimap; //导入方法依赖的package包/类
@Override
public EventArgScoringAlignment<EquivClassType> align(final AnswerKey answerKey,
    final ArgumentOutput argumentOutput) {
  checkArgument(answerKey.docId() == argumentOutput.docId());
  final ImmutableMultimap<EquivClassType, Response> equivClassToSystemResponses = Multimaps.index(
      argumentOutput.responses(), equivClassFunction);
  final ImmutableMultimap<EquivClassType, AssessedResponse> equivClassToAnswerKeyResponses =
      Multimaps.index(
          answerKey.annotatedResponses(),
          Functions.compose(equivClassFunction, AssessedResponseFunctions.response()));

  final ImmutableSet<EquivClassType> allEquivClasses =
      Sets.union(equivClassToSystemResponses.keySet(),
          equivClassToAnswerKeyResponses.keySet()).immutableCopy();

  final ImmutableSet.Builder<EquivClassType> truePositives = ImmutableSet.builder();
  final ImmutableSet.Builder<EquivClassType> falsePositives = ImmutableSet.builder();
  final ImmutableSet.Builder<EquivClassType> falseNegatives = ImmutableSet.builder();
  final ImmutableSet.Builder<EquivClassType> unassessed = ImmutableSet.builder();

  for (final EquivClassType eqivClass : allEquivClasses) {
    // a key equivalence class is correct if anyone found a correct response in that class
    final ImmutableCollection<AssessedResponse> answerKeyResponsesForEC =
        equivClassToAnswerKeyResponses.get(eqivClass);
    final boolean isCorrectEquivClass = !FluentIterable.
        from(answerKeyResponsesForEC)
        .filter(AssessedResponse.IsCorrectUpToInexactJustifications)
        .isEmpty();

    final ImmutableCollection<Response> systemResponsesForEC = equivClassToSystemResponses.get(
        eqivClass);

    if (isCorrectEquivClass) {
      // only the top-scoring system response for an equivalence class counts
      final Optional<Response> selectedSystemResponse =
          argumentOutput.selectFromMultipleSystemResponses(
              equivClassToSystemResponses.get(eqivClass));

      if (selectedSystemResponse.isPresent()) {
        final Optional<AssessedResponse> assessmentOfSelectedResponse =
            AssessedResponse.findAnnotationForArgument(
                selectedSystemResponse.get(), answerKeyResponsesForEC);
        if (assessmentOfSelectedResponse.isPresent()) {
          if (assessmentOfSelectedResponse.get().isCorrectUpToInexactJustifications()) {
            truePositives.add(eqivClass);
          } else {
            // it was a correct equivalence class, but we the system response for that
            // equivalence class was incorrect (e.g. due to bad justifications).
            // This counts as both a false positive and a false negative. Note that there
            // could be a correct system response for the equivalence class which has a lower
            // confidence, but it won't count.
            falseNegatives.add(eqivClass);
            falsePositives.add(eqivClass);
          }
        } else {
          // the best system response for this equivalence class is unassessed
          unassessed.add(eqivClass);
        }
      } else {
        // it was a correct equivalence class, but we didn't find any responses
        falseNegatives.add(eqivClass);
      }
    } else {
      // if the equivalence class is incorrect, the system is wrong if it returned *any* response
      if (!systemResponsesForEC.isEmpty()) {
        falsePositives.add(eqivClass);
      } else {
        // do nothing - it was a true negative
      }
    }
  }

  return EventArgScoringAlignment
      .create(argumentOutput.docId(), argumentOutput, answerKey, truePositives.build(),
          falsePositives.build(),
          falseNegatives.build(), unassessed.build(), equivClassToAnswerKeyResponses,
          equivClassToSystemResponses);
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:79,代码来源:StandardScoringAligner.java


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