本文整理汇总了Java中com.google.common.collect.TreeBasedTable.put方法的典型用法代码示例。如果您正苦于以下问题:Java TreeBasedTable.put方法的具体用法?Java TreeBasedTable.put怎么用?Java TreeBasedTable.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.TreeBasedTable
的用法示例。
在下文中一共展示了TreeBasedTable.put方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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
示例5: 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;
}
示例6: 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;
}
示例7: main
import com.google.common.collect.TreeBasedTable; //导入方法依赖的package包/类
public static void main(String[] args)
throws Exception
{
final File csvFile = new File(
"mturk/annotation-task/60-pilot-reason-disambiguation-task.output.csv");
TreeBasedTable<Integer, Double, DescriptiveStatistics> table = TreeBasedTable.create();
for (int crowdSize = 5; crowdSize <= 5; 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);
SortedMap<String, String> gold1 = Step4bReasonDisambiguationGoldAnnotator
.annotateWithGoldLabels(csvFile, null, null,
maceThreshold,
// new WorkerAssignmentsFilterSubsetByTime(0, crowdSize, true));
new WorkerAssignmentFilterRandomized(18, 1, crowdSize, random));
SortedMap<String, String> gold2 = Step4bReasonDisambiguationGoldAnnotator
.annotateWithGoldLabels(csvFile, null, null,
maceThreshold,
// new WorkerAssignmentsFilterSubsetByTime(crowdSize, crowdSize * 2,
// false));
new WorkerAssignmentFilterRandomized(18, 2, crowdSize, random));
gold1 = filterOutNullValueEntries(gold1);
gold2 = filterOutNullValueEntries(gold2);
double kappa = computeKappa(gold1, gold2);
if (!table.contains(crowdSize, maceThreshold)) {
table.put(crowdSize, maceThreshold, new DescriptiveStatistics());
}
table.get(crowdSize, maceThreshold).addValue(kappa);
}
}
}
printTable(table);
}
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:43,代码来源:Step4cReasonDisambiguationAgreementExperiments.java
示例8: summarize
import com.google.common.collect.TreeBasedTable; //导入方法依赖的package包/类
public TreeBasedTable<LocalDateTime, String, Double> summarize() {
TreeBasedTable<LocalDateTime, String, Double> summary = TreeBasedTable.create();
for(HashMap.Entry<String, InstrumentData> ee : instrumentMap.entrySet()) {
for(PositionPnl pp : ee.getValue().positionPnls) {
// Update Gross.Value
Double grossValue = summary.get(pp.ts, "Gross.Value");
if(grossValue == null) {
summary.put(pp.ts, "Gross.Value", Math.abs(pp.positionValue));
} else {
summary.put(pp.ts, "Gross.Value", grossValue + Math.abs(pp.positionValue));
}
// Update Net.Value
Double netValue = summary.get(pp.ts, "Net.Value");
if(netValue == null) {
summary.put(pp.ts, "Net.Value", pp.positionValue);
} else {
summary.put(pp.ts, "Net.Value", netValue + pp.positionValue);
}
// Update Long.Value
if(pp.positionValue > 0.0) {
Double longValue = summary.get(pp.ts, "Long.Value");
if(longValue == null) {
summary.put(pp.ts, "Long.Value", pp.positionValue);
} else {
summary.put(pp.ts, "Long.Value", longValue + pp.positionValue);
}
}
// Update Short.Value
if(pp.positionValue < 0.0) {
Double shortValue = summary.get(pp.ts, "Short.Value");
if(shortValue == null) {
summary.put(pp.ts, "Short.Value", pp.positionValue);
} else {
summary.put(pp.ts, "Short.Value", shortValue + pp.positionValue);
}
}
// 'Long.Value', 'Short.Value', 'Net.Value', 'Gross.Value', 'Period.Realized.PL', 'Period.Unrealized.PL', 'Gross.Trading.PL', 'Txn.Fees', 'Net.Trading.PL'
for(String column : Arrays.asList("Period.Realized.PL", "Period.Unrealized.PL", "Gross.Trading.PL", "Txn.Fees", "Net.Trading.PL")) {
double value = 0.0;
switch(column) {
case "Period.Realized.PL":
value = pp.realizedPnl;
break;
case "Period.Unrealized.PL":
value = pp.unrealizedPnl;
break;
case "Gross.Trading.PL":
value = pp.grossPnl;
break;
case "Txn.Fees":
value = pp.fees;
break;
case "Net.Trading.PL":
value = pp.netPnl;
break;
}
Double summaryValue = summary.get(pp.ts, column);
if(summaryValue == null) {
summary.put(pp.ts, column, value);
} else {
summary.put(pp.ts, column, summaryValue + value);
}
}
}
}
return summary;
}