final String NONE = "NONE";
SRLReader reader = new SRLReader(0, 1, 2, 3, 4, 5, 6, 8);
reader.open(UTInput.createBufferedFileReader(inputFile));
PrintStream fout = UTOutput.createPrintBufferedFileStream(outputFile);
Prob2DMap map = new Prob2DMap();
DEPNode node, head;
String deprel, label, ftags;
DEPTree tree;
int i, size;
while ((tree = reader.next()) != null)
{
size = tree.size();
for (i=1; i<size; i++)
{
node = tree.get(i);
head = node.getHead();
deprel = node.getLabel();
if ((ftags = node.getFeat(DEPLib.FEAT_SEM)) != null)
deprel = ftags;
for (DEPArc arc : node.getSHeads())
{
label = arc.getLabel();
// if (label.startsWith("R-AM"))
// label = label.substring(2);
if (arc.getNode() == head)
map.add(label, deprel);
else
map.add(label, NONE);
}
}
}
List<String> keys = new ArrayList<String>(map.keySet());
DecimalFormat format = new DecimalFormat("##.##");
Collections.sort(keys);
StringDoublePair[] ps;
StringBuilder build;
double none;
String tmp;
for (String key : keys)
{
build = new StringBuilder();
ps = map.getProb1D(key);
Arrays.sort(ps);
none = 0;
for (StringDoublePair p : ps)
{
if (p.s.equals(NONE))
none = p.d;
else if (p.d >= 0.2)
{
build.append("\\d"+p.s.toUpperCase());
build.append(":");
build.append(format.format(100d*p.d));
build.append(", ");
}
}
tmp = build.length() == 0 ? "" : build.substring(0, build.length()-2);
fout.printf("%s\t%s\t%f\t%d\t%d\n", key, tmp, 100d*none, map.get(key).get(NONE), map.getTotal1D(key));
}
fout.close();
}