sclass Element { double weight = 1, totalWeight; L children; S plusWeight(S s) { ret weight == 1 && totalWeight == 1 ? s : s + " [" + formatDouble(weight, 2) + "/" + formatDouble(totalWeight, 2) + "]"; } } sclass ChooseCategory extends Element { AI_BottomUpParser1.Word word; L categories; *(AI_BottomUpParser1.Word *word, L *categories) {} toString { ret plusWeight(word.text() + " (" + n2(categories, "category", "categories") + ")"); } } // Probably unused sclass ChooseReconstruction extends Element { AI_BottomUpParser1.Word word; L reconstructions; *(AI_BottomUpParser1.Word *word, L *reconstructions) {} toString { ret plusWeight(word.text() + " as " + category() + " (" + n2(reconstructions, "reconstruction") + ")"); } // Should only be one? S category() { ret joinWithComma(map(func(ai_Reconstructed r) -> S { r.production.c }, reconstructions)); } } sclass HaveCategory extends Element { 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 Element { ai_Reconstructed reconstruction; *(ai_Reconstructed *reconstruction) {} toString { ret plusWeight(reconstruction.a.text() + " + " + reconstruction.b.text()); } }