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


Java TIntIntIterator.value方法代码示例

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


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

示例1: cleanup

import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
@Override
protected void cleanup(Context context) throws java.io.IOException, InterruptedException {
	final Configuration conf = context.getConfiguration();
	final int minSupport = conf.getInt(TopPIoverHadoop.KEY_MINSUP, 10);
	
	final IntWritable keyW = new IntWritable();
	final IntWritable valueW = new IntWritable();
	final TreeSet<ItemAndBigSupport> heap = new TreeSet<ItemAndBigSupport>();
	
	TIntIntIterator it = this.itemSupports.iterator();
	while(it.hasNext()) {
		it.advance();
		final int support = it.value();
		if (support >= minSupport) {
			heap.add(new ItemAndBigSupport(it.key(), support));
		}
	}
	
	this.itemSupports = null;
	int rebased = 0;
	
	for (ItemAndBigSupport entry : heap) {
		keyW.set(entry.item);
		valueW.set(rebased++);
		context.write(keyW, valueW);
	}
	
	rebased -= 1;
	
	context.getCounter(COUNTERS_GROUP, COUNTER_REBASING_MAX_ID).setValue(rebased);
}
 
开发者ID:slide-lig,项目名称:TopPI,代码行数:32,代码来源:ItemCountingReducer.java

示例2: duplicate

import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
public  void duplicate(ArrayList<String> docs) throws Exception {
	this.docs = docs;
	dsMap = new TreeSet<DocSim>();
	feature();

	similarity();
	System.out.println("去重复");

	boolean[] dup = new boolean[docs.size()];
	for(int id1=0;id1<docs.size();id1++){
		if(dup[id1]||similarityMap[id1]==null)
			continue;


		ArrayList<Integer> ids = new ArrayList<Integer>();
		ids.add(id1);
		TIntIntIterator it = similarityMap[id1].iterator();
		for ( int i = similarityMap[id1].size(); i-- > 0; ) {
			it.advance();
			int id2 = it.key();				
			double sim = ((double)(it.value()* 2)) / (featureLen[id1] + featureLen[id2]);
			if(sim > thres ){
				dup[id2]= true;
				ids.add(id2);
			}
		}
		DocSim docSim = new DocSim(ids);
		dsMap.add(docSim);
	}
}
 
开发者ID:FudanNLP,项目名称:fnlp,代码行数:31,代码来源:Similarity.java

示例3: countFrequency

import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
/**
 * 
 * @param freqmap
 * @return
 */
public static TreeMap<Integer, Integer> countFrequency(TIntIntHashMap freqmap) {
	TreeMap<Integer, Integer> map = new TreeMap<Integer,Integer>();
	TIntIntIterator it = freqmap.iterator();
	while(it.hasNext()){
		it.advance();
		int freq = it.value();
		if(map.containsKey(freq)){
			map.put(freq, map.get(freq)+1);
		}else
			map.put(freq, 1);
	}
	return map;		
}
 
开发者ID:FudanNLP,项目名称:fnlp,代码行数:19,代码来源:MyArrays.java

示例4: compressSortRenaming

import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
/**
 * Will compress an older renaming, by removing infrequent items. Contained
 * arrays (except closure) will refer new item IDs
 * 
 * @param olderReverseRenaming
 *            reverseRenaming from the dataset that fed this Counter
 * @param items
 *            below this parameter will be renamed by decreasing frequency
 * @return the translation from the old renaming to the compressed one
 *         (gives -1 for removed items)
 */
public int[] compressSortRenaming(int[] olderReverseRenaming) {
	if (olderReverseRenaming == null) {
		olderReverseRenaming = this.reverseRenaming;
	}
	this.rebasedDistinctTransactionsCounts = new int[this.nbFrequents];
	this.rebasedSupportCounts = new int[this.nbFrequents];
	this.reverseRenaming = new int[this.nbFrequents];
	// first, compact
	// we will always have newItemID <= item
	int newItemIDBelowCandidate = 0;
	int newItemIDAboveCandidate = this.nbFrequents - 1;
	TIntIntIterator supportIterator = this.supportCounts.iterator();
	// after this loop we have
	// reverseRenaming: NewBase (index) -> PreviousDatasetBase (value)
	// supportCounts: NewBase (index) -> Support (value)
	// distinctTransactionCount: NewBase (index) -> Count (value)
	while (supportIterator.hasNext()) {
		supportIterator.advance();
		if (supportIterator.key() < this.maxCandidate) {
			this.reverseRenaming[newItemIDBelowCandidate] = supportIterator.key();
			this.rebasedSupportCounts[newItemIDBelowCandidate] = supportIterator.value();
			this.rebasedDistinctTransactionsCounts[newItemIDBelowCandidate] = this.distinctTransactionsCounts
					.get(supportIterator.key());
			newItemIDBelowCandidate++;
		} else {
			this.reverseRenaming[newItemIDAboveCandidate] = supportIterator.key();
			this.rebasedSupportCounts[newItemIDAboveCandidate] = supportIterator.value();
			this.rebasedDistinctTransactionsCounts[newItemIDAboveCandidate] = this.distinctTransactionsCounts
					.get(supportIterator.key());
			newItemIDAboveCandidate--;
		}
	}
	this.supportCounts = null;
	this.distinctTransactionsCounts = null;
	this.maxCandidate = newItemIDBelowCandidate;
	this.maxFrequent = this.nbFrequents - 1;

	// now, sort up to the pivot
	this.quickSortOnSup(0, this.maxCandidate);

	int[] renaming = new int[Math.max(olderReverseRenaming.length, this.rebasingSize)];
	Arrays.fill(renaming, -1);

	// after this loop we have
	// reverseRenaming: NewBase (index) -> OriginalBase (value)
	// renaming: PreviousDatasetBase (index) -> NewBase (value)

	for (int i = 0; i <= this.maxFrequent; i++) {
		renaming[this.reverseRenaming[i]] = i;
		this.reverseRenaming[i] = olderReverseRenaming[this.reverseRenaming[i]];
	}

	this.compactedArrays = true;
	return renaming;
}
 
开发者ID:slide-lig,项目名称:TopPI,代码行数:67,代码来源:SparseCounters.java

示例5: start

import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
/**
 * start path extraction considering all the pairs main_item-items
 */
private void start(){
	
	TIntIntHashMap paths = null;
	String item_pair_paths = "";
	
	for(int j = 0; j < items.size(); j++){
		
		ItemTree b = items.get(j);
		int b_id = b.getItemId();
		
		paths = computePaths(main_item, b);
			
		if(paths.size() > 0){
				
			item_pair_paths = main_item_id + "-" + b_id + "\t";
			TIntIntIterator it = paths.iterator();
			while(it.hasNext()){
				it.advance();
				item_pair_paths += it.key() + "=" + it.value() + ",";
			}
			item_pair_paths = item_pair_paths.substring(0, item_pair_paths.length()-1);
				
			// text file writing
			if(textWriter != null)
				textWriter.write(item_pair_paths);
			
			// binary file writing
			if(pathWriter != null)
				pathWriter.write(item_pair_paths);
				
			if(computeInversePaths){
				
				item_pair_paths = b_id + "-" + main_item_id + "\t";
				it = paths.iterator();
				while(it.hasNext()){
					it.advance();
					item_pair_paths += reverse(it.key()) + "=" + it.value() + ",";
				}
				
				item_pair_paths = item_pair_paths.substring(0, item_pair_paths.length()-1);
				
				// text file writing
				if(textWriter != null)
					textWriter.write(item_pair_paths);
					
				// binary file writing
				if(pathWriter != null){
					pathWriter.write(item_pair_paths);
				}
			}
			
		}
		
	}
	 
}
 
开发者ID:sisinflab,项目名称:lodreclib,代码行数:60,代码来源:ItemPathExtractorWorker.java


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