sclass PTElement { AI_BottomUpParser1.Word word; double weight = 1, totalWeight; L children; PTElement parent; 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) + "]"; } S text() { ret word == null ? null : word.text(); } S category() { null; } } sclass ChooseCategory extends PTElement { L categories; *(AI_BottomUpParser1.Word *word, L *categories) {} toString { ret plusWeight(word.text() + " (" + n2(categories, "category", "categories") + ")"); } } sclass HaveCategory extends PTElement { 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); } S category() { ret category; } } sclass ChoosePart extends PTElement { ai_Reconstructed reconstruction; *(AI_BottomUpParser1.Word *word, ai_Reconstructed *reconstruction) {} toString { S hint = reconstruction.production.simplificationHint; ret plusWeight( reconstruction.a.text() + " + " + reconstruction.b.text() + " [" + reconstruction.production + "]"); } S category() { ret reconstruction.production.c; } }