@Deprecated
public static Example fromLispTree(LispTree tree, String defaultId) {
Builder b = new Builder().setId(defaultId);
for (int i = 1; i < tree.children.size(); i++) {
LispTree arg = tree.child(i);
String label = arg.child(0).value;
if ("id".equals(label)) {
b.setId(arg.child(1).value);
} else if ("utterance".equals(label)) {
b.setUtterance(arg.child(1).value);
} else if ("targetFormula".equals(label)) {
b.setTargetFormula(Formulas.fromLispTree(arg.child(1)));
} else if ("targetValue".equals(label) || "targetValues".equals(label)) {
if (arg.children.size() != 2)
throw new RuntimeException("Expect one target value");
b.setTargetValue(Values.fromLispTree(arg.child(1)));
}
}
Example ex = b.createExample();
for (int i = 1; i < tree.children.size(); i++) {
LispTree arg = tree.child(i);
String label = arg.child(0).value;
if ("posTags".equals(label) || "nerTags".equals(label) || "url".equals(label)) {
// Do nothing
} else if ("tokens".equals(label)) {
int n = arg.child(1).children.size();
ex.backupTokens = new ArrayList<String>(n);
for (int j = 0; j < n; j++)
ex.backupTokens.add(arg.child(1).child(j).value);
} else if ("evaluation".equals(label)) {
ex.evaluation = Evaluation.fromLispTree(arg.child(1));
} else if ("parseEvaluation".equals(label)) {
ex.parseEvaluation = Evaluation.fromLispTree(arg.child(1));
} else if ("predDerivations".equals(label)) {
ex.predDerivations = new ArrayList<Derivation>();
for (int j = 1; j < arg.children.size(); j++)
ex.predDerivations.add(derivationFromLispTree(arg.child(j)));
} else if (!Sets.newHashSet("id", "utterance", "targetFormula", "targetValue", "targetValues").contains(label)) {
throw new RuntimeException("Invalid example argument: " + arg);
}
}