當前位置: 首頁>>代碼示例>>Java>>正文


Java TObjectIntHashMap.keySet方法代碼示例

本文整理匯總了Java中gnu.trove.map.hash.TObjectIntHashMap.keySet方法的典型用法代碼示例。如果您正苦於以下問題:Java TObjectIntHashMap.keySet方法的具體用法?Java TObjectIntHashMap.keySet怎麽用?Java TObjectIntHashMap.keySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gnu.trove.map.hash.TObjectIntHashMap的用法示例。


在下文中一共展示了TObjectIntHashMap.keySet方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addDocument

import gnu.trove.map.hash.TObjectIntHashMap; //導入方法依賴的package包/類
@Override
public void addDocument(Document doc) throws IOException {
  // add the document
  lengths.get(document).add(doc.identifier, doc.terms.size());

  // now deal with fields:
  TObjectIntHashMap<Bytes> currentFieldLengths = new TObjectIntHashMap<>(doc.tags.size());
  for (Tag tag : doc.tags) {
    int len = tag.end - tag.begin;
    currentFieldLengths.adjustOrPutValue(new Bytes(ByteUtil.fromString(tag.name)), len, len);
  }

  for (Bytes field : currentFieldLengths.keySet()) {
    if (!lengths.containsKey(field)) {
      lengths.put(field, new FieldLengthList(field));
    }
    lengths.get(field).add(doc.identifier, currentFieldLengths.get(field));
  }
}
 
開發者ID:teanalab,項目名稱:demidovii,代碼行數:20,代碼來源:MemoryDocumentLengths.java

示例2: writeData

import gnu.trove.map.hash.TObjectIntHashMap; //導入方法依賴的package包/類
public static void writeData(String file, TObjectIntHashMap<String> data){
	
	BufferedWriter writer;
	try {
		
		writer = new BufferedWriter(new FileWriter(file));

		for (String s : data.keySet()) {
			writer.append(data.get(s) + "\t" + s);
			writer.newLine();
		}

		writer.flush();
		writer.close();

	} 
	catch (Exception e){
		e.printStackTrace();
	}
	
}
 
開發者ID:sisinflab,項目名稱:lodreclib,代碼行數:22,代碼來源:TextFileUtils.java

示例3: write

import gnu.trove.map.hash.TObjectIntHashMap; //導入方法依賴的package包/類
public static void write(TObjectIntHashMap<String> uri_id, 
		boolean append, String outFile){
	
	BufferedWriter writer;
	try {
		
		writer = new BufferedWriter(new FileWriter(outFile, append));

		for (String s : uri_id.keySet()) {
			writer.append(uri_id.get(s) + "\t" + s);
			writer.newLine();
		}

		writer.flush();
		writer.close();

	} 
	catch (Exception e){
		e.printStackTrace();
	}
	
}
 
開發者ID:sisinflab,項目名稱:lodreclib,代碼行數:23,代碼來源:TextFileUtils.java

示例4: writeChunkCounts

import gnu.trove.map.hash.TObjectIntHashMap; //導入方法依賴的package包/類
private static <T> void writeChunkCounts(JsonWriter writer, String name, final TObjectIntHashMap<T> map, int max) throws IOException
{
    List<T> sortedCoords = new ArrayList<T>(map.keySet());
    Collections.sort(sortedCoords, new Comparator<T>()
    {
        @Override
        public int compare(T s1, T s2)
        {
            return map.get(s2) - map.get(s1);
        }
    });

    int i = 0;
    writer.name(name).beginArray();
    for (T key : sortedCoords)
    {
        if ((max > 0) && (i++ > max))
        {
            break;
        }
        if (map.get(key) < 5)
        {
            continue;
        }
        writer.beginObject();
        writer.name("key").value(key.toString());
        writer.name("count").value(map.get(key));
        writer.endObject();
    }
    writer.endArray();
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:32,代碼來源:CauldronHooks.java

示例5: process

import gnu.trove.map.hash.TObjectIntHashMap; //導入方法依賴的package包/類
@Override
public void process(Document doc) throws IOException {
  processor.process(new FieldLengthData(ByteUtil.fromString("document"), doc.identifier, doc.terms.size()));

  TObjectIntHashMap<String> fieldLengths = new TObjectIntHashMap<>();
  for (Tag tag : doc.tags) {
    int len = tag.end - tag.begin;
    fieldLengths.adjustOrPutValue(tag.name, len, len);
  }

  for (String field : fieldLengths.keySet()) {
    processor.process(new FieldLengthData(ByteUtil.fromString(field), doc.identifier, fieldLengths.get(field)));
  }
}
 
開發者ID:teanalab,項目名稱:demidovii,代碼行數:15,代碼來源:FieldLengthExtractor.java

示例6: calculate

import gnu.trove.map.hash.TObjectIntHashMap; //導入方法依賴的package包/類
/**
 * The input should be a {@link Map} for each rater where the keys represent
 * all the subjects that were rated by the raters and the values represent
 * the annotations given by the raters. Agreement between the raters is
 * determined by {@link #equals(Object)} for the INSTANCE type. Annotations
 * for subjects which are not in both sets are ignored.
 * 
 * @see "http://en.wikipedia.org/wiki/Cohen's_kappa"
 * 
 * @param rater1
 *            The annotations from rater 1
 * @param rater2
 *            The annotations from rater 2
 * @return Cohen's Kappa [0,1]
 */
public static <K, A> double calculate(
		final Map<K, A> rater1,
		final Map<K, A> rater2)
{
	int totalCount = 0;
	int agreementCount = 0;
	final TObjectIntHashMap<A> answerCountsR1 = new TObjectIntHashMap<A>();
	final TObjectIntHashMap<A> answerCountsR2 = new TObjectIntHashMap<A>();

	for (final K subjectKey : rater1.keySet())
	{
		// We can only form an agreement if both raters rated this
		// specific subject, so let's check
		if (rater2.keySet().contains(subjectKey))
		{
			final A r1a = rater1.get(subjectKey);
			final A r2a = rater2.get(subjectKey);

			// It's possible that the key exists but is mapped to
			// a null value (for example, if majority voting was used
			// to generate the set and there was no majority).
			if (r1a == null || r2a == null)
				continue;

			// Get the answers from the raters
			final A annotation1 = r1a;
			final A annotation2 = r2a;

			// Count the agreements
			if (annotation1.equals(annotation2))
				agreementCount++;

			// Count each of the answers for each of the raters
			answerCountsR1.putIfAbsent(annotation1, 0);
			answerCountsR2.putIfAbsent(annotation2, 0);
			answerCountsR1.increment(annotation1);
			answerCountsR2.increment(annotation2);

			// Keep a running total
			totalCount++;
		}
	}

	System.out.println(answerCountsR1);

	final double PrA = agreementCount / (double) totalCount;
	System.out.println(PrA);

	double PrE = 0;
	for (final A ann : answerCountsR1.keySet())
	{
		final Integer i = answerCountsR2.get(ann);
		final double PrAnnR1 = answerCountsR1.get(ann) / (double) totalCount;
		final double PrAnnR2 = (i == null ? 0 : i) / (double) totalCount;
		PrE += PrAnnR1 * PrAnnR2;
	}
	System.out.println(PrE);

	final double kappa = (PrA - PrE) / (1d - PrE);

	return kappa;
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:78,代碼來源:CohensKappaInterraterAgreement.java


注:本文中的gnu.trove.map.hash.TObjectIntHashMap.keySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。