}
public static String emptyIfNull(String s) { return s == null ? "" : s; }
public static LispTree entryToLispTree(LexicalEntry rawEntry) {
LispTree result = LispTree.proto.newList();
if (rawEntry instanceof LexicalEntry.EntityLexicalEntry) {
LexicalEntry.EntityLexicalEntry entry = (LexicalEntry.EntityLexicalEntry) rawEntry;
result.addChild("entity");
result.addChild(entry.textDescription);
result.addChild(entry.normalizedTextDesc);
result.addChild(setToLispTree(entry.fbDescriptions));
result.addChild(entry.formula.toString());
result.addChild(entry.source.toString());
result.addChild("" + entry.popularity);
result.addChild("" + entry.distance);
result.addChild(setToLispTree(entry.types));
result.addChild(counterToLispTree(entry.tokenEditDistanceFeatures));
} else if (rawEntry instanceof LexicalEntry.UnaryLexicalEntry) {
LexicalEntry.UnaryLexicalEntry entry = (LexicalEntry.UnaryLexicalEntry) rawEntry;
result.addChild("unary");
result.addChild(entry.textDescription);
result.addChild(entry.normalizedTextDesc);
result.addChild(setToLispTree(entry.fbDescriptions));
result.addChild(entry.formula.toString());
result.addChild(entry.source.toString());
result.addChild("" + entry.popularity);
result.addChild("" + entry.distance);
result.addChild(featureMapToLispTree(entry.alignmentScores));
result.addChild(setToLispTree(entry.types));
} else if (rawEntry instanceof LexicalEntry.BinaryLexicalEntry) {
LexicalEntry.BinaryLexicalEntry entry = (LexicalEntry.BinaryLexicalEntry) rawEntry;
result.addChild("binary");
result.addChild(entry.textDescription);
result.addChild(entry.normalizedTextDesc);
result.addChild(setToLispTree(entry.fbDescriptions));
result.addChild(entry.formula.toString());
result.addChild(entry.source.toString());
result.addChild("" + entry.popularity);
result.addChild("" + entry.distance);
result.addChild(entry.expectedType1);
result.addChild(entry.expectedType2);
result.addChild(emptyIfNull(entry.unitId));
result.addChild(emptyIfNull(entry.unitDescription));
result.addChild(featureMapToLispTree(entry.alignmentScores));
result.addChild(entry.fullLexeme);
}
return result;
}