项目:argument-reasoning-comprehension-task
文件:Step2dExportReasonSpanAnnotationPilot.java
public static Table<String,String,String> assignmentsToTable(
SortedMap<String,SortedSet<SingleWorkerAssignment<Step2bGoldReasonAnnotator.SentenceLabel>>> assignments)
{
TreeBasedTable<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;
}
项目:argument-reasoning-comprehension-task
文件:Step10bUpperBoundStatistics.java
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();
}
}
项目:mynlp
文件:CSRSparseMatrix.java
public static void main(String[] args) {
TreeBasedTable<Integer,Integer> table = TreeBasedTable.create();
table.put(2,6);
table.put(3,2,4);
table.put(0,5);
table.put(0,3,2);
table.put(4,1,4,9);
CSRSparseMatrix csr = new CSRSparseMatrix(table,5);
for (Table.Cell<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");
}
}
}
项目:AwesomeJavaLibraryExamples
文件:ExampleTable.java
public static void main(String[] args)
{
Table<String,String> table = TreeBasedTable.create();
table.put("Row1","Column1","Data1");
table.put("Row1","Column2","Data2");
table.put("Row2","Data3");
table.put("Row2","Data4");
table.put("Row3","Data5");
table.put("Row3","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)));
});
}
项目:anathema-roguelike
文件:TargetSet.java
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));
}
});
}
项目:dkpro-c4corpus
文件:StatisticsTableCreator.java
public static Table<String,Long> loadTable(InputStream stream)
throws IOException
{
Table<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;
}
@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);
}
private static Collection<SRLParse> getPropbankSection(final String section) throws IOException {
final Table<String,TreebankParse> PTB = new PennTreebank().readCorpus(WSJ);
final Table<String,SRLParse> srlParses = SRLParse.parseCorpus(PTB,Util.readFileLineByLine(new File(PROPBANK,"prop.txt")),USING_NOMBANK ? Util.readFileLineByLine(NOMBANK) : null);
final Table<String,SRLParse> goldParses = TreeBasedTable.create();
for (final Cell<String,TreebankParse> cell : PTB.cellSet()) {
// Propbank files skip sentences with no SRL deps. Add a default
// empty parse for all sentences.
goldParses.put(cell.getRowKey(),new SRLParse(cell.getValue().getWords()));
}
goldParses.putAll(srlParses);
final Collection<SRLParse> result = new ArrayList<>();
for (final Cell<String,SRLParse> entry : goldParses.cellSet()) {
if (entry.getRowKey().startsWith("wsj_" + section)) {
result.add(entry.getValue());
}
}
return result;
}
项目:pdptw-dataset-generator
文件:Dataset.java
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,value);
data.get(dyn).get(urg,scl).add(value);
valuesSet.add(value);
}
}
项目:yangtools
文件:BuildGlobalContext.java
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;
}
项目:maps4cim
文件:TileDownloadUSGSTest.java
public static Table<Integer,DownloadURL> generateMapping() throws IOException,ParseException {
Table<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;
}
项目:guava-mock
文件:FreshValueGenerator.java
@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,V> table = TreeBasedTable.create();
table.put(row,column,value);
return table;
}
项目:argument-reasoning-comprehension-task
文件:Step1cStanceAgreementExperiments.java
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,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,crowdSize,random));
annotateWithGoldLabels(csvFile,crowdExpert2,random));
double kappa = computeKappa(crowdExpert1,crowdExpert2);
if (!table.contains(crowdSize,maceThreshold)) {
table.put(crowdSize,new DescriptiveStatistics());
}
table.get(crowdSize,maceThreshold).addValue(kappa);
FileUtils.forceDelete(crowdExpert1);
FileUtils.forceDelete(crowdExpert2);
}
}
}
printTable(table);
}
项目:argument-reasoning-comprehension-task
文件:Step1cStanceAgreementExperiments.java
public static void printTable(TreeBasedTable<Integer,DescriptiveStatistics> table)
{
System.out.printf("\t%s%n","\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();
}
}
项目:argument-reasoning-comprehension-task
文件:Step10bUpperBoundStatistics.java
@SuppressWarnings("rawtypes") // TreeBasedTable.create() is defined as such
@Generates private static <R extends Comparable,value);
return table;
}
项目:mynlp
文件:CSRSparseMatrix.java
public CSRSparseMatrix(TreeBasedTable<Integer,Integer> table,int totalRow) {
int size = table.size();
values = new int[size];
columnIndices = new int[size];
this.rowOffset = new int[totalRow + 1];
//rowOffset[0]=0;
int point = -1;
int inSize = 0;
for (Integer rowNum : table.rowKeySet()) {
Map<Integer,Integer> row = table.row(rowNum);
inSize += row.size();
rowOffset[rowNum + 1] = inSize;
for (Map.Entry<Integer,Integer> entry : row.entrySet()) {
point++;
columnIndices[point] = entry.getKey();
values[point] = entry.getValue();
}
}
int x = 0;
for (int i = 0; i < this.rowOffset.length; i++) {
int p = this.rowOffset[i];
if (p > 0) {
x = p;
} else {
this.rowOffset[i] = x;
}
}
}
项目:mynlp
文件:CoreBiGramTableDictionary.java
@Override
public void loadFromrealData() throws Exception {
MynlpResource source = environment.loadResource(coreDictNgramSetting);
TreeBasedTable<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;
}
protected static Gson makeSerializerGson(Type type,Boolean pretty){
GsonBuilder gsonBuilder = new GsonBuilder();
if(pretty)
gsonBuilder.setPrettyPrinting();
switch (type){
case DEFAULT:
default:
gsonBuilder.setDateFormat("yyyy-MM-dd");
gsonBuilder.registerTypeAdapter(HashBasedTable.class,new GuavaTableSerializer());
gsonBuilder.registerTypeAdapter(TreeBasedTable.class,new GuavaTableSerializer());
break;
}
return gsonBuilder.create();
}
protected static Gson makeDeserializerGson(Type type){
GsonBuilder gsonBuilder = new GsonBuilder();
switch (type){
case DEFAULT:
default:
gsonBuilder.setDateFormat("yyyy-MM-dd");
gsonBuilder.registerTypeAdapter(HashBasedTable.class,new GuavaTableDeserializer());
gsonBuilder.registerTypeAdapter(TreeBasedTable.class,new GuavaTableDeserializer());
break;
}
return gsonBuilder.create();
}
@Override
public Table deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
Table<Date,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;
}
项目:owsi-core-parent
文件:GTable.java
@SuppressWarnings("rawtypes")
public static <R extends Comparable,V> GTable<R,V,RowSortedTable<R,V>>
createSorted(QTriplet<R,V> expr) {
return new GTable<R,V>>(expr) {
private static final long serialVersionUID = 1L;
@Override
protected RowSortedTable<R,V> createTable() {
return TreeBasedTable.<R,V>create();
}
};
}
项目:owsi-core-parent
文件:GTable.java
项目:blockplus
文件:OptionsEncoding.java
public Options decode(final JsonObject data) {
final Table<IPosition,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,list);
}
}
return new Options(table);
}
项目:guava-libraries
文件:FreshValueGenerator.java
@SuppressWarnings("rawtypes") // TreeBasedTable.create() is defined as such
@Generates private static <R extends Comparable,value);
return table;
}
项目:guava
文件:FreshValueGenerator.java
@SuppressWarnings("rawtypes") // TreeBasedTable.create() is defined as such
@Generates
private static <R extends Comparable,V>
TreeBasedTable<R,V> generateTreeBasedTable(R row,value);
return table;
}
项目:miru
文件:MiruRepairRegion.java
private Table<String,String> getTenantPartitions(MiruTenantId tenantId) throws Exception {
final Table<String,String> tenantPartitions = TreeBasedTable.create(); // tree for order
MiruPartitionId latestPartitionId = miruWALClient.getLargestPartitionId(tenantId);
if (latestPartitionId != null) {
for (MiruPartitionId latest = latestPartitionId; latest != null; latest = latest.prev()) {
tenantPartitions.put(tenantId.toString(),latest.toString(),"");
}
}
return tenantPartitions;
}
项目:yangtools
文件:BuildGlobalContext.java
private void collectrequiredSourcesFromLib(
final TreeBasedTable<String,SourceSpecificContext> libSourcesTable,final Set<SourceSpecificContext> requiredLibs,final SourceSpecificContext source) {
for (final SourceIdentifier requiredSource : source.getrequiredSources()) {
final SourceSpecificContext libSource = getrequiredLibSource(requiredSource,libSourcesTable);
if (libSource != null && requiredLibs.add(libSource)) {
collectrequiredSourcesFromLib(libSourcesTable,libSource);
}
}
}
项目:gmparser
文件:CYKMatrix.java
/**
* Generates the Cocke-Younger-Kasami recognition matrix.
*/
private void generate() {
int size = (this.getWord().length() == 0) ? 1 : this.getWord().length();
this.matrix = TreeBasedTable.create();
for (int r = 1; r <= size; r ++) {
for (int c = 1; c <= size; c ++) {
this.matrix.put(r,c,new Alphabet());
}
}
}
项目:jBloomberg
文件:HistoricalData.java
/**
* Adds a value to the HistoricalData structure for that security / field / date combination.
*/
@Override
synchronized void add(LocalDate date,String security,String field,Object value) {
Table<LocalDate,Typedobject> securityTable = data.get(security);
if (securityTable == null) {
securityTable = TreeBasedTable.create(); //to have the dates in order
data.put(security,securityTable);
}
securityTable.put(date,field,Typedobject.of(value));
}
项目:pentaho-kettle
文件:MemoryGroupByAggregationTest.java
项目:guava-mock
文件:FreshValueGeneratorTest.java
public void testTreeBasedTable() {
assertFreshInstance(new Typetoken<TreeBasedTable<String,?,?>>() {});
}
项目:argument-reasoning-comprehension-task
文件:Step8cTaskValidationAgreementExperiments.java
public static void main(String[] args)
throws Exception
{
final File csvFile = new File(
"mturk/annotation-task/95-validation-task-pilot-task.output.csv");
final File argumentsFile = new File(
"mturk/annotation-task/data/92-original-warrant-batch-0001-5000-2447-good-reason-claim-pairs.xml.gz");
TreeBasedTable<Integer,DescriptiveStatistics> table = TreeBasedTable.create();
final int requiredAssignmentsSize = 18;
IntStream.range(7,8).parallel().forEach(crowdSize -> {
Arrays.asList(0.95).parallelStream()
.forEach(maceThreshold -> {
// ten random repeats
for (int i = 0; i < 1; i++) {
Random random = new Random(i);
try {
File crowdExpert1 = File.createTempFile("crowd1",".xml.gz");
File crowdExpert2 = File.createTempFile("crowd2",".xml.gz");
SortedMap<String,String> goldEstimationResult1 = Step8bTaskValidationGoldAnnotator
.annotateWithGoldLabels(Collections.singletonList(csvFile),new WorkerAssignmentFilterRandomized(
requiredAssignmentsSize,random));
SortedMap<String,String> goldEstimationResult2 = Step8bTaskValidationGoldAnnotator
.annotateWithGoldLabels(Collections.singletonList(csvFile),random));
double score = computescore(goldEstimationResult1,goldEstimationResult2);
synchronized (table) {
if (!table.contains(crowdSize,maceThreshold)) {
table.put(crowdSize,new DescriptiveStatistics());
}
table.get(crowdSize,maceThreshold).addValue(score);
}
FileUtils.forceDelete(crowdExpert1);
FileUtils.forceDelete(crowdExpert2);
synchronized (table) {
System.out.println("===================================");
printTable(table);
System.out.println("===================================");
}
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
printTable(table);
});
});
}
项目:argument-reasoning-comprehension-task
文件:Step6cAlternativeWarrantValidationAgreementExperiments.java
public static void main(String[] args)
throws Exception
{
final File csvFile = new File(
"mturk/annotation-task/80-aw-validation-pilot-task.output.csv");
final File argumentsFile = new File(
"mturk/annotation-task/data/71-alternative-warrants-batch-0001-5000-001-600aw-batch-2390reason-claim-pairs-with-distracting-reasons.xml.gz");
TreeBasedTable<Integer,DescriptiveStatistics> table = TreeBasedTable.create();
final int requiredAssignmentsSize = 14;
IntStream.range(1,8).parallel().forEach(crowdSize -> {
Arrays.asList(0.75,0.80,0.85,1.0).parallelStream().forEach(maceThreshold -> {
// ten random repeats
for (int i = 0; i < 20; i++) {
Random random = new Random(i);
try {
File crowdExpert1 = File.createTempFile("crowd1",".xml.gz");
File crowdExpert2 = File.createTempFile("crowd2",".xml.gz");
SortedMap<String,String> goldEstimationResult1 = Step6bAlternativeWarrantValidationHITGoldAnnotator
.annotateWithGoldLabels(Collections.singletonList(csvFile),Arrays.asList(argumentsFile),null,new WorkerAssignmentFilterRandomized(
requiredAssignmentsSize,random));
SortedMap<String,String> goldEstimationResult2 = Step6bAlternativeWarrantValidationHITGoldAnnotator
.annotateWithGoldLabels(Collections.singletonList(csvFile),random));
double kappa = computeKappa(goldEstimationResult1,goldEstimationResult2);
synchronized (table) {
if (!table.contains(crowdSize,maceThreshold)) {
table.put(crowdSize,new DescriptiveStatistics());
}
table.get(crowdSize,maceThreshold).addValue(kappa);
}
FileUtils.forceDelete(crowdExpert1);
FileUtils.forceDelete(crowdExpert2);
synchronized (table) {
System.out.println("===================================");
printTable(table);
System.out.println("===================================");
}
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
// System.out.println("Kappas:");
// for (Map.Entry<Integer,Double> entry : kappas.entrySet()) {
// System.out.printf("%d\t%.2f%n",entry.getKey(),entry.getValue());
// }
printTable(table);
});
});
}
项目:argument-reasoning-comprehension-task
文件:Step4cReasondisambiguationAgreementExperiments.java
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,DescriptiveStatistics> table = TreeBasedTable.create();
for (int crowdSize = 5; crowdSize <= 5; crowdSize++) {
for (Double maceThreshold : Arrays.asList(0.85,1.0)) {
// ten random repeats
for (int i = 0; i < 20; i++) {
Random random = new Random(i);
SortedMap<String,String> gold1 = Step4bReasondisambiguationGoldAnnotator
.annotateWithGoldLabels(csvFile,// new WorkerAssignmentsFilterSubsetByTime(0,true));
new WorkerAssignmentFilterRandomized(18,random));
SortedMap<String,String> gold2 = Step4bReasondisambiguationGoldAnnotator
.annotateWithGoldLabels(csvFile,// new WorkerAssignmentsFilterSubsetByTime(crowdSize,crowdSize * 2,// false));
new WorkerAssignmentFilterRandomized(18,random));
gold1 = filterOutNullValueEntries(gold1);
gold2 = filterOutNullValueEntries(gold2);
double kappa = computeKappa(gold1,gold2);
if (!table.contains(crowdSize,maceThreshold).addValue(kappa);
}
}
}
printTable(table);
}
public void testTreeBasedTable() {
assertFreshInstance(new Typetoken<TreeBasedTable<String,?>>() {});
}
@Test
public void testTimeseriesClassifierBasic(){
try {
Table<Date,Double> trainingTable = GsonFactory.fromJson(
IoUtils.toString(
getClass().getResourceAsstream("/data/01/train/trainTable01.json"),"UTF-8"),TreeBasedTable.class,GsonFactory.Type.DEFAULT);
//make the training model
SequenceNetworkModel trainingModel = GsonFactory.fromJson(
IoUtils.toString(
getClass().getResourceAsstream("/data/01/train/trainModel01.json"),SequenceNetworkModel.class,GsonFactory.Type.DEFAULT);
//get the training model
Table<Date,Double> testingTable = GsonFactory.fromJson(
IoUtils.toString(
getClass().getResourceAsstream("/data/01/test/testTable01.json"),GsonFactory.Type.DEFAULT);
//get the config from the classpath
Config conf = ConfigFactory.load();
ClassifierNetwork network = new TimeseriesClassifierNetwork.TimeseriesClassifierNetworkBuilder()
.setNetworkClasses(trainingModel.getNetworkClasses())
.setTrainClassifications(trainingModel.getNetworkClassifications())
.setTrainTable(trainingTable)
.setTestTable(testingTable)
.setConfig(conf,"TimeseriesClassifierNetwork")
.build();
Map<String,Object> model = new HashedMap();
model.put("startDate",DateUtils.min(testingTable.rowKeySet()));
model.put("endDate",DateUtils.max(testingTable.rowKeySet()));
Table<Integer,Object> result = network.evaluate();
log.info(MustacheUtils.merge("start:{{startDate}},end:{{endDate}}",model));
result.rowKeySet().forEach(rowId->{
log.info(MustacheUtils.merge("{{seriesNumber}},{{seriesName}},{{classificationName}}",result.row(rowId)));
});
} catch (Exception e){
log.error(e.getMessage(),e);
Assert.fail(e.getMessage());
}
}
项目:Rapture
文件:ReflexSparseMatrixValue.java
public ReflexSparseMatrixValue(int dimension) {
table = TreeBasedTable.create();
rowOrder = new ArrayList<ReflexValue>();
colOrder = new ArrayList<ReflexValue>();
}
项目:beam
文件:PipelineOptionsFactory.java
/**
* Outputs the set of options available to be set for the passed in {@link PipelineOptions}
* interface. The output is in a human readable format. The format is:
* <pre>
* OptionGroup:
* ... option group description ...
*
* --option1={@code <type>} or list of valid enum choices
* Default: value (if available,see {@link Default})
* ... option description ... (if available,see {@link Description})
* required groups (if available,see {@link required})
* --option2={@code <type>} or list of valid enum choices
* Default: value (if available,see {@link required})
* </pre>
* This method will attempt to format its output to be compatible with a terminal window.
*/
public static void printHelp(PrintStream out,Class<? extends PipelineOptions> iface) {
checkNotNull(out);
checkNotNull(iface);
validateWellFormed(iface,REGISTERED_OPTIONS);
Set<PipelineOptionSpec> properties =
PipelineOptionsReflector.getoptionSpecs(iface);
RowSortedTable<Class<?>,Method> ifacePropGetterTable = TreeBasedTable.create(
ClassNameComparator.INSTANCE,Ordering.natural());
for (PipelineOptionSpec prop : properties) {
ifacePropGetterTable.put(prop.getDefiningInterface(),prop.getName(),prop.getGetterMethod());
}
for (Map.Entry<Class<?>,Map<String,Method>> ifacetoPropertyMap :
ifacePropGetterTable.rowMap().entrySet()) {
Class<?> currentIface = ifacetoPropertyMap.getKey();
Map<String,Method> propertyNamesToGetters = ifacetoPropertyMap.getValue();
SortedSetMultimap<String,String> requiredGroupNametoProperties =
getrequiredGroupNamesToProperties(propertyNamesToGetters);
out.format("%s:%n",currentIface.getName());
prettyPrintDescription(out,currentIface.getAnnotation(Description.class));
out.println();
List<String> lists = Lists.newArrayList(propertyNamesToGetters.keySet());
Collections.sort(lists,String.CASE_INSENSITIVE_ORDER);
for (String propertyName : lists) {
Method method = propertyNamesToGetters.get(propertyName);
String printableType = method.getReturnType().getSimpleName();
if (method.getReturnType().isEnum()) {
printableType = Joiner.on(" | ").join(method.getReturnType().getEnumConstants());
}
out.format(" --%s=<%s>%n",propertyName,printableType);
Optional<String> defaultValue = getDefaultValueFromAnnotation(method);
if (defaultValue.isPresent()) {
out.format(" Default: %s%n",defaultValue.get());
}
prettyPrintDescription(out,method.getAnnotation(Description.class));
prettyPrintrequiredGroups(out,method.getAnnotation(Validation.required.class),requiredGroupNametoProperties);
}
out.println();
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。