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


Java TreeBasedTable.create方法代码示例

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


在下文中一共展示了TreeBasedTable.create方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: loadFromRealData

import com.google.common.collect.TreeBasedTable; //导入方法依赖的package包/类
@Override
public void loadFromRealData() throws Exception {
    MynlpResource source = environment.loadResource(coreDictNgramSetting);

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

    Pattern pattern = Pattern.compile("^(.+)@(.+)\\s+(\\d+)$");
    try (CharSourceLineReader reader = source.openLineReader()) {
        while (reader.hasNext()) {
            String line = reader.next();

            Matcher matcher = pattern.matcher(line);
            if (matcher.find()) {
                String wordA = matcher.group(1);
                String wordB = matcher.group(2);
                String num = matcher.group(3);
                int idA = coreDictionary.indexOf(wordA);
                if (idA >= 0) {
                    int idB = coreDictionary.indexOf(wordB);
                    if (idB >= 0) {
                        table.put(idA, idB, Ints.tryParse(num));
                    }
                }
            }
        }
    }

    CSRSparseMatrix matrix = new CSRSparseMatrix(table, coreDictionary.size());

    this.matrix = matrix;
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:32,代码来源:CoreBiGramTableDictionary.java

示例13: deserialize

import com.google.common.collect.TreeBasedTable; //导入方法依赖的package包/类
@Override
public Table deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {

    Table<Date, String, Double> table = TreeBasedTable.create();

    try {

        JsonObject parent = (JsonObject) json;
        JsonArray colArray = parent.get("columns").getAsJsonArray();

        JsonArray rowArray = parent.get("data").getAsJsonArray();
        for (int i = 0; i < rowArray.size(); i++) {
            JsonArray row = rowArray.get(i).getAsJsonArray();
            Date rowDate = null;
            for (int j = 0; j < row.size(); j++) {
                if (j == 0) {
                    //table.put("","",row.get(j));
                    rowDate = DateUtils.DRONZE_DATE.parse(row.get(j).toString().replace("\"", ""));

                } else if (row.get(j) != null && !row.get(j).toString().equals("null"))  {
                    table.put(rowDate, colArray.get(j).toString().replace("\"", ""),
                            Double.parseDouble(row.get(j).toString()));
                }

            }

        }
    } catch (ParseException e) {
        throw new JsonParseException(e);
    }

    return table;
}
 
开发者ID:claytantor,项目名称:blueweave,代码行数:34,代码来源:GuavaTableDeserializer.java

示例14: createTable

import com.google.common.collect.TreeBasedTable; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static <R extends Comparable, C extends Comparable, V> GTable<R, C, V, RowSortedTable<R, C, V>>
		createSorted(QTriplet<R, C, V> expr) {
	return new GTable<R, C, V, RowSortedTable<R, C, V>>(expr) {
		private static final long serialVersionUID = 1L;
		@Override
		protected RowSortedTable<R, C, V> createTable() {
			return TreeBasedTable.<R, C, V>create();
		}
	};
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:12,代码来源:GTable.java

示例15: decode

import com.google.common.collect.TreeBasedTable; //导入方法依赖的package包/类
public Options decode(final JsonObject data) {
    final Table<IPosition, Polyomino, List<Set<IPosition>>> table = TreeBasedTable.create();
    final Set<Entry<String, JsonElement>> entrySet = data.entrySet();
    for (final Entry<String, JsonElement> entry : entrySet) {
        final int id = Integer.parseInt(entry.getKey());
        final IPosition light = Position(id / 20, id % 20); // TODO !!!
        final JsonObject polyominos = entry.getValue().getAsJsonObject();
        for (final Entry<String, JsonElement> positionsByPolyominos : polyominos.entrySet()) {
            final String ordinal = positionsByPolyominos.getKey();
            final Polyomino polyomino = Polyomino.values()[Integer.parseInt(ordinal)];
            final JsonArray positions = positionsByPolyominos.getValue().getAsJsonArray();
            final List<Set<IPosition>> list = Lists.newArrayList();
            for (final JsonElement jsonElement : positions) {
                final Set<IPosition> set = Sets.newHashSet();
                final JsonArray asJsonArray = jsonElement.getAsJsonArray();
                for (final JsonElement jsonElement2 : asJsonArray) {
                    final int asInt = jsonElement2.getAsInt();
                    final IPosition p = Position(asInt / 20, asInt % 20); // TODO !!!
                    set.add(p);
                }
                list.add(set);
            }
            table.put(light, polyomino, list);
        }
    }
    return new Options(table);
}
 
开发者ID:arie-benichou,项目名称:blockplus,代码行数:28,代码来源:OptionsEncoding.java


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