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


Java ImmutableTriple类代码示例

本文整理汇总了Java中org.apache.commons.lang3.tuple.ImmutableTriple的典型用法代码示例。如果您正苦于以下问题:Java ImmutableTriple类的具体用法?Java ImmutableTriple怎么用?Java ImmutableTriple使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ImmutableTriple类属于org.apache.commons.lang3.tuple包,在下文中一共展示了ImmutableTriple类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMinMaxAvg

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
public static Triple<Double, Double, Double> getMinMaxAvg(List<Double> values) {
	if (values.isEmpty())
		return new ImmutableTriple<Double, Double, Double>(0.0, 0.0, 0.0);

	double minVal = Double.POSITIVE_INFINITY;
	double maxVal = Double.NEGATIVE_INFINITY;
	double avgVal = 0.0;
	for (double v : values) {
		minVal = Math.min(v, minVal);
		maxVal = Math.max(v, maxVal);
		avgVal += v / values.size();
	}

	return new ImmutableTriple<Double, Double, Double>(minVal, maxVal,
			avgVal);
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:17,代码来源:SmaphUtils.java

示例2: getBoldsEDCapitalizedWordcount

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
private static Triple<Double, Double, Double> getBoldsEDCapitalizedWordcount(String query, int rank, List<Pair<String, Integer>> websearchBolds){
	double minEdDist = 1.0;
	double capitalized = 0;
	double avgNumWords = 0;
	int boldsCount = 0;
	for (Pair<String, Integer> p : websearchBolds)
		if (p.second == rank) {
			boldsCount++;
			minEdDist = Math.min(minEdDist,
					SmaphUtils.getMinEditDist(query, p.first));
			if (Character.isUpperCase(p.first.charAt(0)))
				capitalized++;
			avgNumWords += p.first.split("\\W+").length;
		}
	if (boldsCount != 0)
		avgNumWords /= boldsCount;
	return new ImmutableTriple<>(minEdDist, capitalized, avgNumWords);
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:19,代码来源:EntityFeaturePack.java

示例3: getAdvancedARToFtrsAndPresence

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
private List<Triple<Annotation, AnnotationFeaturePack, Boolean>> getAdvancedARToFtrsAndPresence(
		String query, QueryInformation qi,
		HashSet<Annotation> goldStandardAnn,
		MatchRelation<Annotation> annotationMatch) {

	List<Triple<Annotation, AnnotationFeaturePack, Boolean>> annAndFtrsAndPresence = new Vector<>();
	for (Annotation a : IndividualLinkback.getAnnotations(query,
			qi.allCandidates(), anchorMaxED, e2a, wikiApi)) {
		boolean inGold = false;
		for (Annotation goldAnn : goldStandardAnn)
			if (annotationMatch.match(goldAnn, a)) {
				inGold = true;
				break;
			}
		//if (e2a.containsId(a.getConcept())) {
			AnnotationFeaturePack features = new AnnotationFeaturePack(a, query, qi, wikiApi, wikiToFreeb, e2a);
			annAndFtrsAndPresence.add(new ImmutableTriple<Annotation, AnnotationFeaturePack, Boolean>(a, features, inGold));
		//} else
		//	LOG.warn("No anchors found for id={}", a.getConcept());
	}

	return annAndFtrsAndPresence;
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:24,代码来源:SmaphAnnotator.java

示例4: getLBBindingToFtrsAndF1

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
private List<Triple<HashSet<Annotation>, BindingFeaturePack, Double>> getLBBindingToFtrsAndF1(String query,
        QueryInformation qi, HashSet<Annotation> goldStandardAnn, MatchRelation<Annotation> match,
        Set<Tag> acceptedEntities, SmaphDebugger debugger) {

	Collection<Pair<HashSet<Annotation>, BindingFeaturePack>> bindingAndFeaturePacks = CollectiveLinkBack
	        .getBindingFeaturePacks(query, acceptedEntities, qi, bg, wikiApi, wikiToFreeb, e2a, debugger);

	List<Triple<HashSet<Annotation>, BindingFeaturePack, Double>> res = new Vector<>();
	for (Pair<HashSet<Annotation>, BindingFeaturePack> bindingAndFeaturePack : bindingAndFeaturePacks) {
		HashSet<Annotation> binding = bindingAndFeaturePack.first;
		BindingFeaturePack bindingFeatures = bindingAndFeaturePack.second;

		Metrics<Annotation> m = new Metrics<>();
		float f1 = m.getSingleF1(goldStandardAnn, binding, match);

		res.add(new ImmutableTriple<HashSet<Annotation>, BindingFeaturePack, Double>(
				binding, bindingFeatures, (double) f1));
	}
	return res;
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:21,代码来源:SmaphAnnotator.java

示例5: GrpcHystrixCommand

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
public GrpcHystrixCommand(String serviceName, String methodName, Boolean isEnabledFallBack) {
  super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(serviceName))//
      .andCommandKey(HystrixCommandKey.Factory.asKey(serviceName + ":" + methodName))//
      .andCommandPropertiesDefaults(
          HystrixCommandProperties.Setter().withCircuitBreakerRequestVolumeThreshold(20)// 10秒钟内至少19此请求失败,熔断器才发挥起作用
              .withCircuitBreakerSleepWindowInMilliseconds(30000)// 熔断器中断请求30秒后会进入半打开状态,放部分流量过去重试
              .withCircuitBreakerErrorThresholdPercentage(50)// 错误率达到50开启熔断保护
              .withExecutionTimeoutEnabled(false)// 禁用这里的超时
              .withFallbackEnabled(isEnabledFallBack))//
      .andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(100)
          .withAllowMaximumSizeToDivergeFromCoreSize(true).withMaximumSize(Integer.MAX_VALUE)));
  this.serviceName = serviceName;
  this.methodName = methodName;
  this.start = System.currentTimeMillis();
  this.rpcContext = new ImmutableTriple<Map<String, String>, Map<String, Object>, Set<Class>>(
      RpcContext.getContext().getAttachments(), RpcContext.getContext().get(),
      RpcContext.getContext().getHoldenGroups());
  RpcContext.removeContext();
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:20,代码来源:GrpcHystrixCommand.java

示例6: initClass

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
@BeforeClass
public static void initClass() throws IOException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    CONTENTS.add(new ImmutableTriple<MsgData[], String[], Hint[]>(new MsgData[]{
            new MsgData(Origin.User, "Ich suche ein ruhiges und romantisches Restaurant in Berlin für heute Abend.")},
            new String[]{"ruhiges", "romantisches"},
            new Hint[]{}));
    CONTENTS.add(new ImmutableTriple<MsgData[], String[], Hint[]>(new MsgData[]{
            new MsgData(Origin.User, "Ich suche ein nettes Restaurant in Berlin für den kommenden Montag.")},
            new String[]{"nettes"}, //NOTE: not kommenden, because this is in the ignored list
            new Hint[]{}));
    CONTENTS.add(new ImmutableTriple<MsgData[], String[], Hint[]>(new MsgData[]{
            new MsgData(Origin.User, "Bitte kein chinesisches oder indisches Restaurant.")},
            new String[]{"chinesisches","indisches"},
            new Hint[]{Hint.negated})); //those attributes are negated
    
    OpenNlpPosProcessor pos = new OpenNlpPosProcessor(Collections.singleton(new LanguageGerman()));
    NegationProcessor negation = new NegationProcessor(Arrays.asList(new GermanNegationRule()));
    
    REQUIRED_PREPERATORS = Arrays.asList(pos, negation);
    
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:22,代码来源:PosCollectorAndNegationHandlerTest.java

示例7: execute

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
@Override
public void execute() {
    ArrayList<TaskAttributes> fullMatches = taskDb.getAll().stream()
            .map(this::constructFullMatchCancidate)
            .filter(this::isValidCandidate)
            .sorted(this::candidateCompare)
            .map(ImmutableTriple::getRight)
            .collect(Collectors.toCollection(ArrayList::new));

    results = new ArrayList<>(fullMatches);

    results.addAll(taskDb.getAll().stream()
            .map(this::constructStemMatchCandidate)
            .filter(this::isValidCandidate)
            .sorted(this::candidateCompare)
            .map(ImmutableTriple::getRight)
            .filter(task -> !fullMatches.contains(task))
            .collect(Collectors.toCollection(ArrayList::new)));

    logger.info(String.format("Search completed. %d results found.", results.size()));

    eventBus.post(new SearchDoneEvent(results, keywords));
}
 
开发者ID:cs2103jan2016-w13-4j,项目名称:main,代码行数:24,代码来源:SearchCommand.java

示例8: evaluate

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
private void evaluate() {
	scoredTest = new ArrayList<>();

	// run through all example chunks
	for(int i = 0; i < featuresTest.size(); i++) {
		INDArray testData = featuresTest.get(i);
		INDArray labels = labelsTest.get(i);
		int nRows = testData.rows();

		// go through each example individually
		for(int j = 0; j < nRows; j++) {
			INDArray example = testData.getRow(j);
			int digit = (int)labels.getDouble(j);
			double score = net.score(new DataSet(example,example));
			scoredTest.add(new ImmutableTriple<Double, Integer, INDArray>(new Double(score), new Integer(digit), example));
		}
	}

	// sort for increasing score
	Collections.sort(scoredTest, new Comparator<Triple<Double, Integer, INDArray>>() {
		@Override
		public int compare(Triple<Double, Integer, INDArray> o1, Triple<Double, Integer, INDArray> o2) {
			return(o1.getLeft().compareTo(o2.getLeft()));
		}
	});
}
 
开发者ID:matthiaszimmermann,项目名称:ml_demo,代码行数:27,代码来源:WDBCAutoencoder.java

示例9: findResourcePathFromFreemarkerRouteMap

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
private ImmutableTriple<String, String, String> findResourcePathFromFreemarkerRouteMap(String uri)
{
    //2.查找不到,则从docRoutesMap中查找  例如
    //uri:       /root/web/page/index.ftl
    //key:       /root/web
    //value:     static/
    for (String key : freemarkerRoutesMap.keySet())
    {
        if (uri.startsWith(key + "/"))
        {
            //uri:       /root/web/page/index.ftl
            //key:       /root/web
            //value:     static/
            
            //key:       /root/web/
            String subPath = StringUtils.removeStart(uri, key + "/");
            //subPath:   page/index.ftl
            //uri解码,即可完美支持中文
            subPath = URIEncoderDecoder.decode(subPath);
            return new ImmutableTriple<String, String, String>(key + "/", freemarkerRoutesMap.get(key), subPath);
        }
    }
    return null;
}
 
开发者ID:lnwazg,项目名称:httpkit,代码行数:25,代码来源:Router.java

示例10: getSuccessorsForSegment

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
private CompletableFuture<List<Segment>> getSuccessorsForSegment(final int number) {
    return getHistoryTable()
            .thenApply(historyTable -> {
                CompletableFuture<Segment> segmentFuture = getSegment(number);
                CompletableFuture<Data<T>> indexTableFuture = getIndexTable();
                return new ImmutableTriple<>(historyTable, segmentFuture, indexTableFuture);
            })
            .thenCompose(triple -> CompletableFuture.allOf(triple.getMiddle(), triple.getRight())
                    .thenCompose(x -> {
                        final Segment segment = triple.getMiddle().join();
                        List<Integer> candidates = TableHelper.findSegmentSuccessorCandidates(segment,
                                triple.getRight().join().getData(),
                                triple.getLeft().getData());
                        return findOverlapping(segment, candidates);
                    }));
}
 
开发者ID:pravega,项目名称:pravega,代码行数:17,代码来源:PersistentStreamBase.java

示例11: unionMergeFilterValues

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
/**
 * For a set of ApiFilters collect by dimension, field and operation, and union their value sets.
 *
 * @param filterStream  Stream of ApiFilters whose values are to be unioned
 *
 * @return A set of filters with the same operations but values unioned
 */
protected static Set<ApiFilter> unionMergeFilterValues(Stream<ApiFilter> filterStream) {

    Function<ApiFilter, Triple<Dimension, DimensionField, FilterOperation>> filterGroupingIdentity = filter ->
        new ImmutableTriple<>(filter.getDimension(), filter.getDimensionField(), filter.getOperation());

    Map<Triple<Dimension, DimensionField, FilterOperation>, Set<String>> filterMap =
            filterStream.collect(Collectors.groupingBy(
                    filterGroupingIdentity::apply,
                    Collectors.mapping(
                            ApiFilter::getValues,
                            Collectors.reducing(Collections.emptySet(), StreamUtils::setMerge)
                    )
            ));

    return filterMap.entrySet().stream()
            .map(it -> new ApiFilter(
                    it.getKey().getLeft(),
                    it.getKey().getMiddle(),
                    it.getKey().getRight(),
                    it.getValue()
            ))
            .collect(Collectors.toSet());
}
 
开发者ID:yahoo,项目名称:fili,代码行数:31,代码来源:RoleDimensionApiFilterRequestMapper.java

示例12: print

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
/**
 * Prints an overview of customers and their orders.
 */
public void print() {
  System.out.println("Customer Overview:");
  System.out.println(StringUtils.rightPad("", 80, "-"));
  System.out.print("| ");
  System.out.print(StringUtils.rightPad("customer", 15));
  System.out.print(" | ");
  System.out.print(StringUtils.rightPad("#orders", 7));
  System.out.print(" | ");
  System.out.println("order ids");
  System.out.println(StringUtils.rightPad("", 80, "-"));

  ordersByCustomer.entrySet().stream().sequential()
      .map(e -> new ImmutableTriple<>(e.getKey(), e.getValue().size(),
          StringUtils.join(e.getValue(), ',')))
      .sorted((lhs, rhs) -> Long.compare(rhs.getMiddle(), lhs.getMiddle()))
      .forEachOrdered(e -> System.out
          .println(String.format("| %s | %s | %s", StringUtils.rightPad(e.getLeft(), 15),
              StringUtils.center(e.getMiddle().toString(), 7), e.getRight())));
  System.out.println();
}
 
开发者ID:sventorben,项目名称:cqrs,代码行数:24,代码来源:CustomerOverview.java

示例13: configureRegexRegions

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
void configureRegexRegions(Configuration conf) throws ConfigurationException {
  List<String> regexRegionGroupList = conf.getList(REGEX_REGION_GROUP).stream().map(o -> o.toString()).collect(Collectors.toList());
  List<String> regexRegionSearchList = conf.getList(REGEX_REGION_SEARCH).stream().map(o -> o.toString()).collect(Collectors.toList());
  List<String> regexRegionReplaceList = conf.getList(REGEX_REGION_REPLACE).stream().map(o -> o.toString()).collect(Collectors.toList());

  int groupListSize = regexRegionGroupList.size();
  int searchListSize = regexRegionSearchList.size();
  int replaceListSize = regexRegionReplaceList.size();
  if (!(groupListSize == searchListSize && searchListSize == replaceListSize)) {
    // all lists must be the same size
    throw new ConfigurationException("Error initializing class. All regexRegion lists must be the same size");
  }

  groupSearchReplaceList = new ArrayList<>(groupListSize);
  for (int index = 0; index < regexRegionGroupList.size(); index++) {
    Pattern pattern = Pattern.compile(regexRegionGroupList.get(index));
    String regex = regexRegionSearchList.get(index);
    String replacement = regexRegionReplaceList.get(index);

    ImmutableTriple<Pattern, String, String> triple = new ImmutableTriple<>(pattern, regex, replacement);
    groupSearchReplaceList.add(triple);
  }
}
 
开发者ID:boozallen,项目名称:cognition,代码行数:24,代码来源:LineRegexReplaceInRegionBolt.java

示例14: connObjectInit

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
private Triple<ExternalResource, AnyType, Provision> connObjectInit(
        final String resourceKey, final String anyTypeKey) {

    ExternalResource resource = resourceDAO.authFind(resourceKey);
    if (resource == null) {
        throw new NotFoundException("Resource '" + resourceKey + "'");
    }
    AnyType anyType = anyTypeDAO.find(anyTypeKey);
    if (anyType == null) {
        throw new NotFoundException("AnyType '" + anyTypeKey + "'");
    }
    Optional<? extends Provision> provision = resource.getProvision(anyType);
    if (!provision.isPresent()) {
        throw new NotFoundException("Provision on resource '" + resourceKey + "' for type '" + anyTypeKey + "'");
    }

    return ImmutableTriple.of(resource, anyType, provision.get());
}
 
开发者ID:apache,项目名称:syncope,代码行数:19,代码来源:ResourceLogic.java

示例15: fetchPartial

import org.apache.commons.lang3.tuple.ImmutableTriple; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef) {
  final ODataPropertyRequest<ClientProperty> req =
          getClient().getRetrieveRequestFactory().getPropertyRequest(uri);
    req.setPrefer(getClient().newPreferences().includeAnnotations("*"));

  final ODataRetrieveResponse<ClientProperty> res = req.execute();

  final List<T> resItems = new ArrayList<T>();

  final ClientProperty property = res.getBody();
  if (property != null && !property.hasNullValue()) {
    for (ClientValue item : property.getCollectionValue()) {
      resItems.add((T) item.asPrimitive().toValue());
    }
  }

  return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(
          resItems, null, Collections.<ClientAnnotation>emptyList());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:PrimitiveCollectionInvocationHandler.java


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