sclass PTElement { double weight = 1, totalWeight; L children; S plusWeight(S s) { if (weight == 1 && totalWeight == 1) ret s; S a = formatDouble(weight, 2), b = formatDouble(totalWeight, 2); ret s + " [" + a + (eq(a, b) ? "" : ", total " + b) + "]"; } } sclass ChooseCategory extends PTElement { AI_BottomUpParser1.Word word; L categories; *(AI_BottomUpParser1.Word *word, L *categories) {} toString { ret plusWeight(word.text() + " (" + n2(categories, "category", "categories") + ")"); } } sclass HaveCategory extends PTElement { AI_BottomUpParser1.Word word; S category; ai_Reconstructed reconstruction; // optional *(AI_BottomUpParser1.Word *word, S *category) {} *(AI_BottomUpParser1.Word *word, S *category, ai_Reconstructed *reconstruction) {} toString { ret plusWeight(quote(word.text()) + " as " + category); } } sclass ChoosePart extends PTElement { ai_Reconstructed reconstruction; *(ai_Reconstructed *reconstruction) {} toString { ret plusWeight(reconstruction.a.text() + " + " + reconstruction.b.text()); } }