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


Java Int2IntOpenHashMap.get方法代码示例

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


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

示例1: addCounts

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
private void addCounts(Int2IntOpenHashMap phraseToClusterMap, Int2IntOpenHashMap phraseContextCounts, Map<Integer, Int2IntOpenHashMap> prevClusterCounts, Map<Integer, Int2IntOpenHashMap> nextClusterCounts, int phrase, boolean includeIdentityCounts, int newCluster) {
    Int2IntOpenHashMap phrasePrevClusterCounts = prevClusterCounts.get(newCluster);
    if (phrasePrevClusterCounts == null) {
        phrasePrevClusterCounts = ContextCountsUtils.createNewInt2IntMap();
        prevClusterCounts.put(newCluster, phrasePrevClusterCounts);
    }
    for (Int2IntOpenHashMap.Entry otherPhraseEntry : phraseContextCounts.int2IntEntrySet()) {
        int otherPhrase = otherPhraseEntry.getIntKey();
        if (phrase != otherPhrase || includeIdentityCounts) {
            int clusterOtherPhrase = otherPhrase == phrase ? newCluster : phraseToClusterMap.get(otherPhrase);
            phrasePrevClusterCounts.addTo(clusterOtherPhrase, otherPhraseEntry.getIntValue());
            Int2IntOpenHashMap otherPhraseNextCounts = nextClusterCounts.get(clusterOtherPhrase);
            if (otherPhraseNextCounts == null) {
                otherPhraseNextCounts = ContextCountsUtils.createNewInt2IntMap();
                nextClusterCounts.put(clusterOtherPhrase, otherPhraseNextCounts);
            }
            otherPhraseNextCounts.addTo(newCluster, otherPhraseEntry.getValue());
        }
    }
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:21,代码来源:BrownClustering.java

示例2: buildMap

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
protected void buildMap(PositionListIndex otherPLI, Int2IntOpenHashMap hashedPLI,
        Map<IntPair, IntArrayList> map) {
    int uniqueValueCount = 0;
    for (IntArrayList sameValues : otherPLI.clusters) {
        for (int rowCount : sameValues) {
            if (hashedPLI.containsKey(rowCount)) {
                IntPair pair = new IntPair(uniqueValueCount, hashedPLI.get(rowCount));
                updateMap(map, rowCount, pair);
            }
        }
        uniqueValueCount++;
    }
}
 
开发者ID:mpoiitis,项目名称:DUCCspark,代码行数:14,代码来源:PositionListIndex.java

示例3: addTo

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
public double addTo(IntOpenHashSet another,Int2IntOpenHashMap id2Count){
	int totalno=0;
	
	for (int k : occSet) {
		if (!another.contains(k)){
			totalno+=id2Count.get(k);
			another.add(k);
		}
	}
	
	return (totalno/((totalOccs)*1.0f));
}
 
开发者ID:drivenbyentropy,项目名称:aptasuite,代码行数:13,代码来源:MotifProfile.java

示例4: getOverlapPercentage

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
public double getOverlapPercentage(IntOpenHashSet another,Int2IntOpenHashMap id2Count){
	int totalO=0;
			
	for (int k : occSet) {
		if (another.contains(k)){
			totalO+=id2Count.get(k);
		}
	}		
	
	return (totalO/((totalOccs)*1.0f));
}
 
开发者ID:drivenbyentropy,项目名称:aptasuite,代码行数:12,代码来源:MotifProfile.java

示例5: swapPhrases

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
/**
 * see paragraph "We know of ..." on page 472 of [Brown et al.].
 */

private void swapPhrases(int phraseStart, int phraseEnd, Int2IntOpenHashMap phraseToClusterMap, ContextCountsImpl clusterContextCounts, ContextCountsImpl phraseContextCounts) {
    int numOfPhrases = phraseEnd - phraseStart;
    int numOfPhrasesChangedInLastIteration = numOfPhrases;
    int iteration = 0;
    //continue swapping phrases until less then 1% of the phrases has changed in the last iteration
    while (numOfPhrasesChangedInLastIteration * 100 > numOfPhrases) {
        numOfPhrasesChangedInLastIteration = 0;
        for (int phrase = phraseStart; phrase < phraseEnd; phrase++) {
            int currCluster = phraseToClusterMap.get(phrase);
            ContextCountsImpl contextCountsForPhrase = mapPhraseCountsToClusterCounts(phrase, phraseToClusterMap, phraseContextCounts, SwapWordContextCounts.DUMMY_CLUSTER);
            SwapWordContextCounts swapWordContextCounts = new SwapWordContextCounts(clusterContextCounts, contextCountsForPhrase, currCluster);
            Pair<Integer, Double> bestClusterScore = findBestClusterToMerge(SwapWordContextCounts.DUMMY_CLUSTER, 0, maxNumberOfClusters, swapWordContextCounts);
            double oldScore = computeMergeScore(SwapWordContextCounts.DUMMY_CLUSTER, 0.0, currCluster, swapWordContextCounts);
            if (bestClusterScore.getFirst() != currCluster && bestClusterScore.getSecond() > oldScore + 1e-10) {
                int newCluster = bestClusterScore.getFirst();
                UI.write("Iteration " + iteration + " assigning phrase " + phrase + " to cluster " + newCluster + " (was cluster " + currCluster + ")");
                phraseToClusterMap.put(phrase, newCluster);
                clusterContextCounts.removeCounts(contextCountsForPhrase.mapCluster(SwapWordContextCounts.DUMMY_CLUSTER, currCluster));
                clusterContextCounts.addCounts(contextCountsForPhrase.mapCluster(SwapWordContextCounts.DUMMY_CLUSTER, newCluster));
                if (DO_TESTS) {
                    ContextCountsUtils.checkCounts(clusterContextCounts, phraseToClusterMap, phraseContextCounts);
                    checkSwapScores(phraseToClusterMap, clusterContextCounts, phraseContextCounts, phrase, currCluster, bestClusterScore, oldScore, newCluster);
                }
                numOfPhrasesChangedInLastIteration++;
            }
        }
        iteration++;
    }
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:34,代码来源:BrownClustering.java

示例6: replace

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
private Int2IntOpenHashMap replace(Int2IntOpenHashMap result, int smallCluster, int largeCluster) {
    int countsSmallCluster = result.get(smallCluster);
    if (countsSmallCluster > 0) {
        result = result.clone();
        result.remove(smallCluster);
        result.addTo(largeCluster, countsSmallCluster);
    }
    return result;
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:10,代码来源:MergedContextCounts.java

示例7: swapCounts

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
private Int2IntOpenHashMap swapCounts(Int2IntOpenHashMap origCounts, Int2IntOpenHashMap countsToSwap) {
    if (countsToSwap != null) {
        if (countsToSwap.size() > 1) {
            throw new RuntimeException("Unexpected counts!");
        }
        int countToSwap = countsToSwap.get(DUMMY_CLUSTER);
        if (countToSwap > 0) {
            origCounts = origCounts.clone();
            origCounts.addTo(DUMMY_CLUSTER, countToSwap);
            reduceValue(origCounts, currClusterOfPhrase, countToSwap);
        }
    }
    return origCounts;
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:15,代码来源:SwapWordContextCounts.java

示例8: computeContextCounts

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
public static ContextCountsImpl computeContextCounts(ContextCountsImpl phraseContextCounts, Int2IntOpenHashMap phraseToClusterMap) {
    Map<Integer, Int2IntOpenHashMap> prevCounts = new HashMap<>();
    Map<Integer, Int2IntOpenHashMap> nextCounts = new HashMap<>();
    for (Integer phrase : phraseContextCounts.getAllPhrases()) {
        Integer cluster = phraseToClusterMap.get(phrase);
        Int2IntOpenHashMap prevCountsForPhrase = phraseContextCounts.getPrevCounts(phrase);
        addCounts(phraseToClusterMap, prevCounts, cluster, prevCountsForPhrase);
        Int2IntOpenHashMap nextCountsForPhrase = phraseContextCounts.getNextCounts(phrase);
        addCounts(phraseToClusterMap, nextCounts, cluster, nextCountsForPhrase);
    }
    return new ContextCountsImpl(prevCounts, nextCounts);
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:13,代码来源:ContextCountsUtils.java

示例9: addCounts

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
private static void addCounts(Int2IntOpenHashMap phraseToClusterMap, Map<Integer, Int2IntOpenHashMap> clusterCounts, Integer cluster, Int2IntOpenHashMap phraseCounts) {
    Int2IntOpenHashMap clusterCountsForCluster = clusterCounts.get(cluster);
    if (clusterCountsForCluster == null) {
        clusterCountsForCluster = ContextCountsUtils.createNewInt2IntMap();
        clusterCounts.put(cluster, clusterCountsForCluster);
    }
    for (Map.Entry<Integer, Integer> entry : phraseCounts.entrySet()) {
        Integer cluster2 = phraseToClusterMap.get(entry.getKey());
        clusterCountsForCluster.addTo(cluster2, entry.getValue());
    }
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:12,代码来源:ContextCountsUtils.java


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