package edu.neu.ccs.pyramid.experiment;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.util.Arrays;
import java.util.List;

/**
 * produce dataset table
 * Created by chengli on 1/25/16.
 */
public class Exp143 {
    public static void main(String[] args) throws Exception{
        String[][] table = load();
        System.out.println(Arrays.deepToString(table));

        int numData=5;
        String[] dataNames = {"scene","emotions","mediamill","NUSWIDE","TMC2007"};
        int[] dataRows = {1,5,7,13,17};
        int domainC = 35;
        int labelC = 22;
        int combinatonC = 28;
        int featureC = 21;
        int instanceC= 23;

        StringBuilder sb = new StringBuilder();
        sb.append("\\hline").append("\n");

        for (int i=0;i<numData;i++){
            sb.append("&").append(" ").append(dataNames[i]).append(" ");
        }
        sb.append("\\\\").append("\n").append("\\hline").append("\n");

        sb.append("domain").append(" ");
        for (int i=0;i<numData;i++){
            sb.append("&").append(" ").append(table[dataRows[i]][domainC]).append(" ");
        }
        sb.append("\\\\").append("\n").append("\\hline").append("\n");


        sb.append("\\#labels").append(" ");
        for (int i=0;i<numData;i++){
            sb.append("&").append(" ").append(table[dataRows[i]][labelC]).append(" ");
        }
        sb.append("\\\\").append("\n").append("\\hline").append("\n");

        sb.append("\\#combinations").append(" ");
        for (int i=0;i<numData;i++){
            sb.append("&").append(" ").append(table[dataRows[i]][combinatonC]).append(" ");
        }
        sb.append("\\\\").append("\n").append("\\hline").append("\n");

        sb.append("\\#features").append(" ");
        for (int i=0;i<numData;i++){
            sb.append("&").append(" ").append(table[dataRows[i]][featureC]).append(" ");
        }
        sb.append("\\\\").append("\n").append("\\hline").append("\n");

        sb.append("\\#instances").append(" ");
        for (int i=0;i<numData;i++){
            sb.append("&").append(" ").append(table[dataRows[i]][instanceC]).append(" ");
        }
        sb.append("\\\\").append("\n").append("\\hline").append("\n");

        System.out.println(sb.toString());
    }

    static String[][] load() throws Exception{
        File file = new File("/Users/chengli/Downloads/table.tsv");
        List<String> lines = FileUtils.readLines(file);
        int numColumns = lines.get(0).split("\t").length;
        int numRows = lines.size();
        String[][] table = new String[numRows][numColumns];
        for (int i=0;i<numRows;i++){
            for (int j=0;j<numColumns;j++){
                table[i][j]="";
            }
        }
        for (int i=0;i<numRows;i++){
            String line = lines.get(i);
            String[] split = line.split("\t");
            for (int j=0;j<split.length;j++){
                table[i][j] = split[j];
            }
        }
        return table;
    }
}

@@ -361,37 +361,1139 @@
 tln(
-Arrays.deepToString(table));%0A
+table.length);%0A        System.out.println(table%5B0%5D.length);%0A//        dataTable(table);%0A        performance(table);%0A%0A    %7D%0A%0A    static void performance(String%5B%5D%5B%5D table)%7B%0A        int numData=5;%0A        int numAlgorithms=8;%0A        String%5B%5D dataNames = %7B%22scene%22,%22emotions%22,%22mediamill%22,%22NUSWIDE%22,%22TMC2007%22%7D;%0A        int%5B%5D dataRows = %7B1,5,7,13,17%7D;%0A        String%5B%5D algorithms = %7B%22CBM+LR%22,%22CBM+Boost%22,%22CRF%22,%22BR+LR%22,%22BR+Boost%22,%22PS+LR%22,%22PS+Boost%22,%22CC+LR%22%7D;%0A        int%5B%5D algoC = %7B9,3,11,13,15,16,17,18%7D;%0A        StringBuilder sb = new StringBuilder();%0A        for (int i=0;i%3CnumAlgorithms;i++)%7B%0A            sb.append(algorithms%5Bi%5D).append(%22 %22);%0A            for (int j=0;j%3CnumData;j++)%7B%0A                System.out.println(%22i=%22+i+%22j=%22+j);%0A                System.out.println(%22%22+dataRows%5Bj%5D+%22,%22+algoC%5Bi%5D);%0A                sb.append(%22&%22).append(table%5BdataRows%5Bj%5D%5D%5BalgoC%5Bi%5D%5D);%0A                sb.append(%22&%22).append(table%5BdataRows%5Bj%5D+1%5D%5BalgoC%5Bi%5D%5D);%0A            %7D%0A            sb.append(%22%5C%5C%5C%5C%22).append(%22%5Cn%22).append(%22%5C%5Chline%22).append(%22%5Cn%22);%0A        %7D%0A        System.out.println(sb.toString());%0A%0A    %7D%0A%0A    static void dataTable(String%5B%5D%5B%5D table)%7B
 %0A   

update exp143