use of edu.neu.ccs.pyramid.configuration.Config in project pyramid by cheng-li.
the class Trec2Meka method main.
public static void main(String[] args) throws IOException, ClassNotFoundException {
if (args.length != 1) {
throw new IllegalArgumentException("Please specify a properties file.");
}
Config config = new Config(args[0]);
System.out.println(config);
List<String> trecs = config.getStrings("trec");
List<String> mekas = config.getStrings("meka");
// for label xml information
String xmlFile = config.getString("xml");
for (int i = 0; i < trecs.size(); i++) {
MultiLabelClfDataSet dataSet = TRECFormat.loadMultiLabelClfDataSet(new File(trecs.get(i)), DataSetType.ML_CLF_SPARSE, true);
System.out.println(i + " -- Translating on trecs: " + trecs.get(i));
MekaFormat.save(dataSet, mekas.get(i), config.getString("data.name"));
if (i == 0) {
MekaFormat.saveXML(dataSet, xmlFile);
}
}
}
use of edu.neu.ccs.pyramid.configuration.Config in project pyramid by cheng-li.
the class Welcome method main.
public static void main(String[] args) {
if (args.length != 1) {
throw new IllegalArgumentException("Please specify a properties file.");
}
Config config = new Config(args[0]);
String name = config.getString("yourName");
System.out.println("Hello " + name + ". Welcome to the world of pyramid!");
}
use of edu.neu.ccs.pyramid.configuration.Config in project pyramid by cheng-li.
the class Merger method main.
public static void main(String[] args) throws Exception {
Config config = new Config(args[0]);
System.out.println(config);
String dataType = config.getString("dataSetType");
switch(dataType) {
case "clf":
mergeClfData(config);
break;
case "reg":
//todo
break;
}
}
use of edu.neu.ccs.pyramid.configuration.Config in project pyramid by cheng-li.
the class Trec2LibSvm method main.
public static void main(String[] args) throws Exception {
Config config = new Config(args[0]);
System.out.println(config);
List<String> trecs = config.getStrings("trec");
List<String> libSVMs = config.getStrings("libSVM");
for (int i = 0; i < trecs.size(); i++) {
ClfDataSet trecDataset = TRECFormat.loadClfDataSet(new File(trecs.get(i)), DataSetType.CLF_SPARSE, false);
System.out.println(i + " -- Translating on trecs: " + trecs.get(i));
LibSvmFormat.save(trecDataset, libSVMs.get(i));
}
}
use of edu.neu.ccs.pyramid.configuration.Config in project pyramid by cheng-li.
the class Trec2Matlab method main.
public static void main(String[] args) throws Exception {
Config config = new Config(args[0]);
File trecFile = new File(config.getString("input.trecFile"));
ClfDataSet dataSet = TRECFormat.loadClfDataSet(trecFile, DataSetType.CLF_SPARSE, false);
File matlabFile = new File(config.getString("output.matlabFile"));
matlabFile.getParentFile().mkdirs();
try (BufferedWriter bw = new BufferedWriter(new FileWriter(matlabFile))) {
for (int i = 0; i < dataSet.getNumDataPoints(); i++) {
Vector vector = dataSet.getRow(i);
for (Vector.Element element : vector.nonZeroes()) {
int j = element.index();
double value = element.get();
bw.write("" + (i + 1));
bw.write("\t");
bw.write("" + (j + 1));
bw.write("\t");
bw.write("" + value);
bw.newLine();
}
}
}
}
Aggregations