private void dumpMetadata(String group, List<Example> examples) { LispTree tree = LispTree.proto.newList(); tree.addChild("metadata"); tree.addChild(LispTree.proto.newList("group", group)); tree.addChild(LispTree.proto.newList("size", "" + examples.size())); tree.print(out); out.println(); }
private LispTree exampleToLispTree(ParserState state) { LispTree tree = LispTree.proto.newList(); tree.addChild("example"); // Basic information Example ex = state.ex; if (ex.id != null) tree.addChild(LispTree.proto.newList("id", ex.id)); if (ex.utterance != null) tree.addChild(LispTree.proto.newList("utterance", ex.utterance)); if (ex.targetFormula != null) tree.addChild(LispTree.proto.newList("targetFormula", ex.targetFormula.toLispTree())); if (ex.targetValue != null) tree.addChild(LispTree.proto.newList("targetValue", ex.targetValue.toLispTree())); if (ex.context != null) tree.addChild(ex.context.toLispTree()); // Language info if (ex.languageInfo != null) { if (ex.languageInfo.tokens != null) tree.addChild( LispTree.proto.newList("tokens", LispTree.proto.newList(ex.languageInfo.tokens))); if (ex.languageInfo.lemmaTokens != null) tree.addChild( LispTree.proto.newList( "lemmaTokens", LispTree.proto.newList(ex.languageInfo.lemmaTokens))); if (ex.languageInfo.posTags != null) tree.addChild( LispTree.proto.newList("posTags", LispTree.proto.newList(ex.languageInfo.posTags))); if (ex.languageInfo.nerTags != null) tree.addChild( LispTree.proto.newList("nerTags", LispTree.proto.newList(ex.languageInfo.nerTags))); if (ex.languageInfo.nerValues != null) tree.addChild( LispTree.proto.newList("nerValues", LispTree.proto.newList(ex.languageInfo.nerValues))); } // Derivations LispTree derivations = LispTree.proto.newList(); derivations.addChild("derivations"); List<Derivation> preds = state.predDerivations; for (int i = 0; i < preds.size(); i++) { Derivation deriv = preds.get(i); if (!isPruned(deriv)) { derivations.addChild(deriv.toLispTree()); } } tree.addChild(derivations); return tree; }