在我的计算结束时,我打印结果:
System.out.println("\nTree\t\tOdds of being by the sought author");
for (ParseTree pt : testTrees) {
conditionalProbs = reg.classify(pt.features());
System.out.printf("%s\t\t%f", pt.toString(), conditionalProbs[1]);
System.out.println();
}
例如,这会产生:
Tree Odds of being by the sought author
K and Burstner 0.000000
how is babby formed answer 0.005170
Mary is in heat 0.999988
Prelim 1.000000
只是把两个\t
放在那里有点笨拙——这些列并没有真正排成一行。我宁愿有这样的输出:
Tree Odds of being by the sought author
K and Burstner 0.000000
how is babby formed answer 0.005170
Mary is in heat 0.999988
Prelim 1.000000
(注意:我无法让 SO 文本编辑器完美地排列这些列,但希望你能明白。)
有没有一种简单的方法可以做到这一点,或者我必须编写一个方法来尝试根据“树”列中字符串的长度来计算它?