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


Java TreeBasedTable类代码示例

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


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

示例1: assignmentsToTable

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
public static Table<String, String, String> assignmentsToTable(
        SortedMap<String, SortedSet<SingleWorkerAssignment<Step2bGoldReasonAnnotator.SentenceLabel>>> assignments)
{
    TreeBasedTable<String, String, String> result = TreeBasedTable.create();

    assignments.forEach((unitID, singleWorkerAssignments) -> {
        singleWorkerAssignments.forEach(sentenceLabelSingleWorkerAssignment -> {
            String workerID = sentenceLabelSingleWorkerAssignment.getWorkerID();
            String label = sentenceLabelSingleWorkerAssignment.getLabel().toString();

            // update the table
            result.put(unitID, workerID, label);
        });
    });

    return result;
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:18,代码来源:Step2dExportReasonSpanAnnotationPilot.java

示例2: printTable2

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
static void printTable2(TreeBasedTable<Integer, Integer, CorrelationVectors> table)
{
    System.out.printf("\t%s%n", StringUtils.join(table.columnKeySet(), "\t\t\t"));
    for (Map.Entry<Integer, Map<Integer, CorrelationVectors>> entry : table.rowMap()
            .entrySet()) {
        System.out.printf("%s\t", entry.getKey());
        List<Double> allX = new ArrayList<>();
        List<Double> allY = new ArrayList<>();

        for (CorrelationVectors ds : entry.getValue().values()) {
            allX.addAll(ds.x);
            allY.addAll(ds.y);
            double[] correlation = computeCorrelation(allX, allY);
            System.out.printf("%.2f\t%.2f\t\t", correlation[0], correlation[1]);
        }
        System.out.println();
    }
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:19,代码来源:Step10bUpperBoundStatistics.java

示例3: main

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
public static void main(String[] args) {
    TreeBasedTable<Integer, Integer, Integer> table = TreeBasedTable.create();

    table.put(2, 0, 6);
    table.put(3, 2, 4);
    table.put(0, 0, 5);
    table.put(0, 3, 2);
    table.put(4, 1, 2);
    table.put(4, 4, 9);


    CSRSparseMatrix csr = new CSRSparseMatrix(table, 5);

    for (Table.Cell<Integer, Integer, Integer> cell : table.cellSet()) {
        if (csr.get(cell.getRowKey(), cell.getColumnKey()) == cell.getValue()) {
            System.out.println(String.format("%d->%d = %d", cell.getRowKey(), cell.getColumnKey(), cell.getValue()));
        } else {
            System.out.println("ERROR");
        }
    }


}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:24,代码来源:CSRSparseMatrix.java

示例4: main

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
public static void main(String[] args)
{
   Table<String, String, String> table = TreeBasedTable.create();

   table.put("Row1", "Column1", "Data1");
   table.put("Row1", "Column2", "Data2");

   table.put("Row2", "Column1", "Data3");
   table.put("Row2", "Column2", "Data4");

   table.put("Row3", "Column1", "Data5");
   table.put("Row3", "Column2", "Data6");
   table.put("Row3", "Column3", "Data7");

   Joiner.MapJoiner mapJoiner = Joiner.on(',').withKeyValueSeparator("="); //Let's a Guava Joiner to illustrate that

   table.rowKeySet().forEach(r -> {
      System.out.println(r + "->" + mapJoiner.join(table.row(r)));
   });
}
 
开发者ID:developerSid,项目名称:AwesomeJavaLibraryExamples,代码行数:21,代码来源:ExampleTable.java

示例5: TargetSet

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
public TargetSet(Collection<T> targets) {
	targetPositions = TreeBasedTable.create();
	
	for(T target : targets) {
		ArrayList<T> positionTargets = targetPositions.get(target.getX(), target.getY());
		if(positionTargets == null) {
			targetPositions.put(target.getY(), target.getX(), new ArrayList<>());
			targetPositions.get(target.getY(), target.getX()).add(target);
		}
	}
	
	targetList = new CircularArrayList<>(this.targetPositions.values().stream().flatMap(t -> t.stream()).collect(Collectors.toList()));
	
	Collections.sort(targetList, new Comparator<T>() {

		@Override
		public int compare(T o1, T o2) {
			return o1.getPosition().squareDistance(new Point(0, 0)) - o2.getPosition().squareDistance(new Point(0, 0));
		}
	});
}
 
开发者ID:carlminden,项目名称:anathema-roguelike,代码行数:22,代码来源:TargetSet.java

示例6: loadTable

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
public static Table<String, String, Long> loadTable(InputStream stream)
        throws IOException
{
    Table<String, String, Long> result = TreeBasedTable.create();

    LineIterator lineIterator = IOUtils.lineIterator(stream, "utf-8");
    while (lineIterator.hasNext()) {
        String line = lineIterator.next();

        System.out.println(line);

        String[] split = line.split("\t");
        String language = split[0];
        String license = split[1];
        Long documents = Long.valueOf(split[2]);
        Long tokens = Long.valueOf(split[3]);

        result.put(language, "docs " + license, documents);
        result.put(language, "tokens " + license, tokens);
    }

    return result;
}
 
开发者ID:dkpro,项目名称:dkpro-c4corpus,代码行数:24,代码来源:StatisticsTableCreator.java

示例7: get

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
@Override
public Options get() {
    final Colors color = this.context.side();
    final Board board = this.context.board();
    final Iterable<IPosition> lights = board.getLights(color);
    final Pieces remainingPieces = this.context.getPlayer().remainingPieces();
    final Table<IPosition, Polyomino, List<Set<IPosition>>> table = TreeBasedTable.create();
    for (int radius = MIN_RADIUS; radius <= MAX_RADIUS; ++radius) {
        final Map<IPosition, Set<IPosition>> potentialPositions = this.getPotentialPositionsByLight(board, color, lights, radius);
        final Set<Polyomino> polyominos = POLYOMINOS_BY_RADIUS.get(radius);
        for (final Polyomino polyomino : polyominos) {
            if (remainingPieces.contains(polyomino)) {
                final Iterable<PolyominoInstance> instances = polyomino.get();
                for (final Entry<IPosition, Set<IPosition>> entry : potentialPositions.entrySet()) {
                    final IPosition position = entry.getKey();
                    final List<Set<IPosition>> options = Lists.newArrayList();
                    for (final IPosition potentialPosition : entry.getValue())
                        options.addAll(this.getLegalPositions(color, board, position, potentialPosition, instances));
                    if (!options.isEmpty()) table.put(position, polyomino, options);
                }
            }
        }
    }
    return new Options(table);
}
 
开发者ID:arie-benichou,项目名称:blockplus,代码行数:26,代码来源:OptionsSupplier.java

示例8: getPropbankSection

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
private static Collection<SRLParse> getPropbankSection(final String section) throws IOException {
	final Table<String, Integer, TreebankParse> PTB = new PennTreebank().readCorpus(WSJ);
	final Table<String, Integer, SRLParse> srlParses = SRLParse.parseCorpus(PTB,
			Util.readFileLineByLine(new File(PROPBANK, "prop.txt")),
			USING_NOMBANK ? Util.readFileLineByLine(NOMBANK) : null);

	final Table<String, Integer, SRLParse> goldParses = TreeBasedTable.create();
	for (final Cell<String, Integer, TreebankParse> cell : PTB.cellSet()) {

		// Propbank files skip sentences with no SRL deps. Add a default
		// empty parse for all sentences.
		goldParses.put(cell.getRowKey(), cell.getColumnKey(), new SRLParse(cell.getValue().getWords()));
	}
	goldParses.putAll(srlParses);

	final Collection<SRLParse> result = new ArrayList<>();
	for (final Cell<String, Integer, SRLParse> entry : goldParses.cellSet()) {
		if (entry.getRowKey().startsWith("wsj_" + section)) {
			result.add(entry.getValue());
		}
	}
	return result;
}
 
开发者ID:uwnlp,项目名称:EasySRL,代码行数:24,代码来源:ParallelCorpusReader.java

示例9: put

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
void put(double dyn, long urg, double scl, T value) {
  synchronized (data) {
    checkArgument(!valuesSet.contains(value), "Value %s already exists.",
      value);
    if (!data.containsKey(dyn)) {
      data.put(dyn, TreeBasedTable.<Long, Double, SortedSet<T>>create());
    }
    if (!data.get(dyn).contains(urg, scl)) {
      data.get(dyn).put(urg, scl, new TreeSet<>(comparator));
    }

    checkArgument(!data.get(dyn).get(urg, scl).contains(value),
      "At (%s,%s,%s) value %s already exists.", dyn, urg, scl, value);
    data.get(dyn).get(urg, scl).add(value);
    valuesSet.add(value);
  }
}
 
开发者ID:rinde,项目名称:pdptw-dataset-generator,代码行数:18,代码来源:Dataset.java

示例10: getRequiredSourcesFromLib

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
private Set<SourceSpecificContext> getRequiredSourcesFromLib() {
    checkState(currentPhase == ModelProcessingPhase.SOURCE_PRE_LINKAGE,
            "Required library sources can be collected only in ModelProcessingPhase.SOURCE_PRE_LINKAGE phase,"
                    + " but current phase was %s", currentPhase);
    final TreeBasedTable<String, Optional<Revision>, SourceSpecificContext> libSourcesTable = TreeBasedTable.create(
        String::compareTo, Revision::compare);
    for (final SourceSpecificContext libSource : libSources) {
        final SourceIdentifier libSourceIdentifier = requireNonNull(libSource.getRootIdentifier());
        libSourcesTable.put(libSourceIdentifier.getName(), libSourceIdentifier.getRevision(), libSource);
    }

    final Set<SourceSpecificContext> requiredLibs = new HashSet<>();
    for (final SourceSpecificContext source : sources) {
        collectRequiredSourcesFromLib(libSourcesTable, requiredLibs, source);
        removeConflictingLibSources(source, requiredLibs);
    }
    return requiredLibs;
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:19,代码来源:BuildGlobalContext.java

示例11: generateMapping

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
public static Table<Integer, Integer, DownloadURL> generateMapping() throws IOException, ParseException {
    Table<Integer, Integer, DownloadURL> hits = TreeBasedTable.create();
    for (DownloadURL url : DownloadURL.values()) {
        File index = url.getIndexLocal();
        System.out.println("reading " + index.toString());
        // Document doc =
        // Jsoup.connect(index).userAgent("Mozilla").timeout(8000).get();
        Document doc = Jsoup.parse(index, null);
        Elements links = doc.select("ul > li > a[href]");
        for (Element link : links) {
            String hit = link.attr("href");
            if (hit.endsWith("hgt.zip")) {
                String name = hit.substring(hit.lastIndexOf('/'));
                CoordinateInt coord = TileDownload.parseCoordinate(name);
                hits.put(coord.lat, coord.lon, url);
            }
        }
    }
    return hits;
}
 
开发者ID:klamann,项目名称:maps4cim,代码行数:21,代码来源:TileDownloadUSGSTest.java

示例12: generateTreeBasedTable

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
@SuppressWarnings("rawtypes") // TreeBasedTable.create() is defined as such
@Generates private static <R extends Comparable, C extends Comparable, V> TreeBasedTable<R, C, V>
    generateTreeBasedTable(R row, C column, V value) {
  TreeBasedTable<R, C, V> table = TreeBasedTable.create();
  table.put(row, column, value);
  return table;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:FreshValueGenerator.java

示例13: main

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
public static void main(String[] args)
        throws Exception
{
    final File csvFile = new File(
            "mturk/annotation-task/21-pilot-stance-task.output.csv");
    final File argumentsFile = new File(
            "mturk/annotation-task/data/arguments-with-full-segmentation-rfd.xml.gz");

    TreeBasedTable<Integer, Double, DescriptiveStatistics> table = TreeBasedTable.create();

    for (int crowdSize = 1; crowdSize <= 9; crowdSize++) {
        for (Double maceThreshold : Arrays.asList(0.85, 0.9, 0.95, 1.0)) {
            // ten random repeats
            for (int i = 0; i < 20; i++) {
                Random random = new Random(i);

                File crowdExpert1 = File.createTempFile("crowd1", ".xml.gz");
                File crowdExpert2 = File.createTempFile("crowd2", ".xml.gz");

                annotateWithGoldLabels(csvFile, argumentsFile, crowdExpert1, maceThreshold,
                        new WorkerAssignmentFilterRandomized(18, 1, crowdSize, random));

                annotateWithGoldLabels(csvFile, argumentsFile, crowdExpert2, maceThreshold,
                        new WorkerAssignmentFilterRandomized(18, 2, crowdSize, random));

                double kappa = computeKappa(crowdExpert1, crowdExpert2);

                if (!table.contains(crowdSize, maceThreshold)) {
                    table.put(crowdSize, maceThreshold, new DescriptiveStatistics());
                }
                table.get(crowdSize, maceThreshold).addValue(kappa);

                FileUtils.forceDelete(crowdExpert1);
                FileUtils.forceDelete(crowdExpert2);
            }
        }
    }
    printTable(table);

}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:41,代码来源:Step1cStanceAgreementExperiments.java

示例14: printTable

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
public static void printTable(TreeBasedTable<Integer, Double, DescriptiveStatistics> table)
{
    System.out.printf("\t%s%n", StringUtils.join(table.columnKeySet(), "\t\t"));
    for (Map.Entry<Integer, Map<Double, DescriptiveStatistics>> entry : table.rowMap()
            .entrySet()) {
        System.out.printf("%s\t", entry.getKey());
        for (DescriptiveStatistics ds : entry.getValue().values()) {
            System.out.printf("%.2f\t%2f\t", ds.getMean(), ds.getStandardDeviation());
        }
        System.out.println();
    }
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:13,代码来源:Step1cStanceAgreementExperiments.java

示例15: printTable

import com.google.common.collect.TreeBasedTable; //导入依赖的package包/类
static void printTable(TreeBasedTable<Integer, Integer, DescriptiveStatistics> table)
{
    System.out.printf("\t%s%n", StringUtils.join(table.columnKeySet(), "\t\t\t"));
    for (Map.Entry<Integer, Map<Integer, DescriptiveStatistics>> entry : table.rowMap()
            .entrySet()) {
        System.out.printf("%s\t", entry.getKey());
        for (DescriptiveStatistics ds : entry.getValue().values()) {
            System.out.printf("%.2f\t%2f\t%d\t", ds.getMean(), ds.getStandardDeviation(),
                    ds.getN());
        }
        System.out.println();
    }
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:14,代码来源:Step10bUpperBoundStatistics.java


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