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


Java Object2IntOpenHashMap类代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap的典型用法代码示例。如果您正苦于以下问题:Java Object2IntOpenHashMap类的具体用法?Java Object2IntOpenHashMap怎么用?Java Object2IntOpenHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: isUniqueWith

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
public boolean isUniqueWith(int[][] compressedRecords, OpenBitSet otherAttrs, List<IntegerPair> comparisonSuggestions) {
	int attrsSize = (int) otherAttrs.cardinality();
	
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<ClusterIdentifier> value2record = new Object2IntOpenHashMap<>(cluster.size());
		for (int recordId : cluster) {
			ClusterIdentifier value = this.buildClusterIdentifier(otherAttrs, attrsSize, compressedRecords[recordId]);
			if (value == null)
				continue;
			if (value2record.containsKey(value)) {
				comparisonSuggestions.add(new IntegerPair(recordId, value2record.getInt(value)));
				return false;
			}
			value2record.put(value, recordId);
		}
	}
	return true;
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:19,代码来源:PositionListIndex.java

示例2: refines

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
public boolean refines(int[][] lhsInvertedPlis, int[] rhs) {
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<IntArrayList> clustersMap = new Object2IntOpenHashMap<>(cluster.size());
		
		// Check if all subclusters of this cluster point into the same other clusters
		for (int recordId : cluster) {
			IntArrayList additionalLhsCluster = this.buildClusterIdentifier(recordId, lhsInvertedPlis);
			if (additionalLhsCluster == null)
				continue;
			
			if (clustersMap.containsKey(additionalLhsCluster)) {
				if ((rhs[recordId] == -1) || (clustersMap.getInt(additionalLhsCluster) != rhs[recordId]))
					return false;
			}
			else {
				clustersMap.put(additionalLhsCluster, rhs[recordId]);
			}
		}
	}
	return true;
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:22,代码来源:PositionListIndex.java

示例3: getEntityIdsMapping

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
/**
 * @deprecated use {@link #readEntityIdsMapping(JavaRDD)} instead, to get the entity mappings used in blocking
 * Maps an entity url to its entity id, that is also used by blocking.
 * @param rawTriples
 * @param SEPARATOR
 * @return a map from an entity url to its entity id, that is also used by blocking.
 */
public static Object2IntOpenHashMap<String> getEntityIdsMapping(JavaRDD<String> rawTriples, String SEPARATOR) {        
    LinkedHashSet<String> subjectsSet =                  
        new LinkedHashSet<>(rawTriples
        .map(line -> line.split(SEPARATOR)[0])
        .collect()                
        ); //convert list to set (to remove duplicates)
    
    Object2IntOpenHashMap<String> result = new Object2IntOpenHashMap<>(subjectsSet.size());
    result.defaultReturnValue(-1);
    int index = 0;
    for (String subject : subjectsSet) {
        result.put(subject, index++);
    }
    return result;
}
 
开发者ID:vefthym,项目名称:MinoanER,代码行数:23,代码来源:Utils.java

示例4: getGroundTruthIdsFromEntityIds

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
/**
 * Return the ground truth in an RDD format, each entity represented with an integer entity id. 
 * @param entityIds1RDD
 * @param entityIds2RDD
 * @param gt
 * @param GT_SEPARATOR
 * @return 
 */
public static JavaPairRDD<Integer,Integer> getGroundTruthIdsFromEntityIds (JavaRDD<String> entityIds1RDD, JavaRDD<String> entityIds2RDD, JavaRDD<String> gt, String GT_SEPARATOR) {
    Object2IntOpenHashMap<String> entityIds1 = readEntityIdsMapping(entityIds1RDD, true);
    Object2IntOpenHashMap<String> entityIds2 = readEntityIdsMapping(entityIds2RDD, false); 
    
    return gt.mapToPair(line -> {
                line = line.toLowerCase();
                String [] parts = line.split(GT_SEPARATOR);                    
                parts[1] = encodeURIinUTF8(parts[1]);
                return new Tuple2<>(-entityIds2.getOrDefault(parts[1], -1), //negative id first (keep default -1, since -(-1) == 1)
                                    entityIds1.getOrDefault(parts[0], -1)); //positive id second
            })
            .filter(x-> x._1() != 1 && x._2() != -1) //throw away pairs whose elements (one or both) do not appear in the dataset
            //remove pairs violating the clean-clean constraint
            .aggregateByKey(new IntOpenHashSet(), 
                    (x,y) -> {x.add(y); return x;}, 
                    (x,y) -> {x.addAll(y); return x;})
            .filter(x -> x._2().size() == 1) //not more than one match allowed per (negative) entity
            .mapValues(x -> x.iterator().next());
            
}
 
开发者ID:vefthym,项目名称:MinoanER,代码行数:29,代码来源:Utils.java

示例5: getLabelBlocks

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
/**
 * Return an RDD with keys: label objects, and values: entity ids from a single collection, having this label
 * @param inputTriples
 * @param labelAtts
 * @param entityIds
 * @param SEPARATOR
 * @param positiveIds
 * @return 
 */
private JavaPairRDD<String,Integer> getLabelBlocks(JavaRDD<String> inputTriples, Set<String> labelAtts, JavaRDD<String> entityIds, String SEPARATOR, boolean positiveIds) {
    Object2IntOpenHashMap<String> urls1 = Utils.readEntityIdsMapping(entityIds, positiveIds);
    return inputTriples.mapToPair(line -> {
    String[] spo = line.toLowerCase().replaceAll(" \\.$", "").split(SEPARATOR); //lose the ending " ." from valid .nt files
      if (spo.length < 3) {
          return null;
      }          
      if (labelAtts.contains(spo[1])) {
        String labelValue = line.substring(line.indexOf(spo[1])+spo[1].length()+SEPARATOR.length())
                .toLowerCase().replaceAll("[^a-z0-9 ]", "").trim();
        int subjectId = urls1.getInt(Utils.encodeURIinUTF8(spo[0])); //replace subject url with entity id
        if (!positiveIds) {
            subjectId = -subjectId;
        }
        return new Tuple2<String,Integer>(labelValue,subjectId);
      } else {
          return null;
      }          
    })
    .filter(x-> x!= null)
    .distinct();
}
 
开发者ID:vefthym,项目名称:MinoanER,代码行数:32,代码来源:LabelMatchingHeuristic.java

示例6: IndexedSet

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
/**
 * Creates a new sample list from a existing collection of elements.
 *
 * <p>
 *     Elements will be indexed as they appear in the input array. Repeats will be ignored.
 * </p>
 *
 * @param values the original sample list.
 *
 * @throws IllegalArgumentException
 * if {@code values} array is {@code null} itself, or it contains {@code null}.
 */
@SuppressWarnings("unchecked")
public IndexedSet(final Collection<E> values) {
    if (values == null)
        throw new IllegalArgumentException("input values cannot be null");

    final int initialCapacity = values.size();
    elements = new ArrayList<>(initialCapacity);
    indexByElement = new Object2IntOpenHashMap<>(initialCapacity);
    int nextIndex = 0;
    for (final E value : values) {
        if (value == null)
            throw new IllegalArgumentException("null element not allowed: index == " + nextIndex);
        if (indexByElement.containsKey(value))
            continue;
        indexByElement.put(value, nextIndex++);
        elements.add(value);
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:31,代码来源:IndexedSet.java

示例7: getScoreOf

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
/**
 * Computes the score of a given type using the log-likelihood with respect to a previously computed language model
 *
 * @param type identifier of the type you are scoring
 * @return score of the type for the previously set context
 */
public double getScoreOf( short type ) {
    Double score = scoreCache.get( type );
    if( score != null ) return score;
    score = 0D;
    final String t = typeMapping.get( type );
    if( t == null ) return DEFAULT_SCORE; //type not found in mapping - warning?
    final Object2IntOpenHashMap<String> lm = models.languageModels.get( t );
    if( lm == null ) return DEFAULT_SCORE;
    for( String w : ngrams ) {
        Integer f = lm.get( w );
        if( f != null ) { //else add zero, = do nothing
            score += Math.log( ( f + muLM * ( ( double ) models.backgroundModel.get( w ) / models.totalFreq ) ) / ( models.freqs.get( t ) + muLM ) );
        }
    }
    if( score == 0D ) score = DEFAULT_SCORE;
    scoreCache.put( type, score );
    return score;
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:25,代码来源:LMLREntityContext.java

示例8: calculateDocVec

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
public Object2IntMap<String> calculateDocVec(List<String> tokens) {

		Object2IntMap<String> docVec = new Object2IntOpenHashMap<String>();
		// add the word-based vector
		if(this.createWordAtts)
			docVec.putAll(affective.core.Utils.calculateTermFreq(tokens,UNIPREFIX,this.freqWeights));

		if(this.createClustAtts){
			// calcultates the vector of clusters
			List<String> brownClust=affective.core.Utils.clustList(tokens,brownDict);
			docVec.putAll(affective.core.Utils.calculateTermFreq(brownClust,CLUSTPREFIX,this.freqWeights));			
		}	


		return docVec;

	}
 
开发者ID:felipebravom,项目名称:AffectiveTweets,代码行数:18,代码来源:PTCM.java

示例9: calculateDocVec

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
public Object2IntMap<String> calculateDocVec(List<String> tokens) {

		Object2IntMap<String> docVec = new Object2IntOpenHashMap<String>();
		// add the word-based vector
		if(this.createWordAtts)
			docVec.putAll(affective.core.Utils.calculateTermFreq(tokens,UNIPREFIX,this.freqWeights));

		if(this.createClustAtts){
			// calcultates the vector of clusters
			List<String> brownClust=affective.core.Utils.clustList(tokens,brownDict);
			docVec.putAll(affective.core.Utils.calculateTermFreq(brownClust,CLUSTPREFIX,this.freqWeights));			
		}	

		return docVec;

	}
 
开发者ID:felipebravom,项目名称:AffectiveTweets,代码行数:17,代码来源:TweetCentroid.java

示例10: calculateTermFreq

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
/**
 * Calculates a vector of attributes from a list of tokens
 * 
 * @param tokens the input tokens 
 * @param prefix the prefix of each vector attribute
 * @return an Object2IntMap object mapping the attributes to their values
 */		
public static Object2IntMap<String> calculateTermFreq(List<String> tokens, String prefix, boolean freqWeights) {
	Object2IntMap<String> termFreq = new Object2IntOpenHashMap<String>();

	// Traverse the strings and increments the counter when the token was
	// already seen before
	for (String token : tokens) {
		// add frequency weights if the flat is set
		if(freqWeights)
			termFreq.put(prefix+token, termFreq.getInt(prefix+token) + 1);
		// otherwise, just consider boolean weights
		else{
			if(!termFreq.containsKey(token))
				termFreq.put(prefix+token, 1);
		}
	}

	return termFreq;
}
 
开发者ID:felipebravom,项目名称:AffectiveTweets,代码行数:26,代码来源:Utils.java

示例11: initiateFromArrayWithMap

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
private void initiateFromArrayWithMap(InterdependentProblemPart<?, ?>[] allParts, 
		Object2IntOpenHashMap<UUID> uuidIntMap) {
	keyMap = new Object2IntOpenHashMap<UUID>(allParts.length);
	partIdToArrayIdMap = new int[uuidIntMap.size()];
	innerValues = new LimitedCommodityStateMap[allParts.length];
	
	keyMap.defaultReturnValue(-1);
	Arrays.fill(partIdToArrayIdMap, -1);
	
	for (int i = 0; i < allParts.length; i++) {
		if (uuidIntMap.containsKey(allParts[i].getDeviceID())) {
			keyMap.put(allParts[i].getDeviceID(), i);
			partIdToArrayIdMap[allParts[i].getId()] = i;
			innerValues[i] = new LimitedCommodityStateMap();
		} else {
			throw new IllegalArgumentException("no mapping for specified key");
		}
	}
}
 
开发者ID:organicsmarthome,项目名称:OSHv4,代码行数:20,代码来源:UUIDCommodityMap.java

示例12: UUIDCommodityMap

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
public UUIDCommodityMap(InterdependentProblemPart<?, ?>[] allParts, 
		Object2IntOpenHashMap<UUID> uuidIntMap,
		boolean makeNoMap) {
	
	if (!makeNoMap) {
		initiateFromArrayWithMap(allParts, uuidIntMap);
	}
	keyMap = null;
	partIdToArrayIdMap = new int[uuidIntMap.size()];
	innerValues = new LimitedCommodityStateMap[allParts.length];
	
	Arrays.fill(partIdToArrayIdMap, -1);
	
	for (int i = 0; i < allParts.length; i++) {
		if (uuidIntMap.containsKey(allParts[i].getDeviceID())) {
			partIdToArrayIdMap[allParts[i].getId()] = i;
			innerValues[i] = new LimitedCommodityStateMap();
		} else {
			throw new IllegalArgumentException("no mapping for specified key");
		}
	}
}
 
开发者ID:organicsmarthome,项目名称:OSHv4,代码行数:23,代码来源:UUIDCommodityMap.java

示例13: evaluate

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
/**
 * Returns a score for the recommendation list.
 *
 * @param recommendation recommendation list
 * @return score of the metric to the recommendation
 */
@Override
public double evaluate(Recommendation<U, I> recommendation) {
    RelevanceModel.UserRelevanceModel<U, I> userRelModel = relModel.getModel(recommendation.getUser());
    BinomialModel<U, I, F>.UserBinomialModel prob = binomialModel.getModel(recommendation.getUser());

    Object2IntOpenHashMap<F> count = new Object2IntOpenHashMap<>();
    count.defaultReturnValue(0);

    int rank = 0;
    int nrel = 0;
    for (Tuple2od<I> iv : recommendation.getItems()) {
        if (userRelModel.isRelevant(iv.v1)) {
            featureData.getItemFeatures(iv.v1)
                    .forEach(fv -> count.addTo(fv.v1, 1));
            nrel++;
        }

        rank++;
        if (rank >= cutoff) {
            break;
        }
    }

    return getResultFromCount(prob, count, nrel, rank);
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:32,代码来源:BinomialMetric.java

示例14: BinomialNonRedundancyUserReranker

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param recommendation input recommendation to be re-ranked
 * @param maxLength number of items to be greedily selected
 */
public BinomialNonRedundancyUserReranker(Recommendation<U, I> recommendation, int maxLength) {
    super(recommendation, maxLength);

    ubm = binomialModel.getModel(recommendation.getUser());

    featureCount = new Object2IntOpenHashMap<>();
    featureCount.defaultReturnValue(0);

    patienceNow = new Object2DoubleOpenHashMap<>();
    patienceLater = new Object2DoubleOpenHashMap<>();
    ubm.getFeatures().forEach(f -> {
        patienceNow.put(f, ubm.patience(0, f, cutoff));
        patienceLater.put(f, ubm.patience(1, f, cutoff));
    });
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:22,代码来源:BinomialNonRedundancyReranker.java

示例15: TypeMapEncoder

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; //导入依赖的package包/类
/**
 *
 * @param referenceWindowSize size of the maximum size of the list index between current list and its encoded value
 *                            list index.
 * @param outputBitStream output stream where a new encoded element will be written.
 * @param offsetsStore stores the current offset after each element is written.
 * @param encodingInfo encodingInfo used to keep track of relevant encoding information.
 */
@SuppressWarnings({"unchecked"})
public TypeMapEncoder(
    final int referenceWindowSize,
    final OutputBitStream outputBitStream,
    final PebbleOffsetsStoreWriter offsetsStore,
    final EncodingInfo encodingInfo
) {
    this.referenceWindowSize = referenceWindowSize;
    this.outputBitStream = outputBitStream;
    this.offsetsStore = offsetsStore;
    this.encodingInfo = encodingInfo;
    this.buffer = (T[]) new Object[referenceWindowSize];
    this.bufferIndex = 0;
    this.map = new Object2IntOpenHashMap<T>();
    this.map.defaultReturnValue(MISSING_MAP_VALUE);
}
 
开发者ID:groupon,项目名称:pebble,代码行数:25,代码来源:TypeMapEncoder.java


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