本文整理汇总了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());
}
}
}
示例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++;
}
}
示例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));
}
示例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));
}
示例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++;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
}