!7 !include once #1017394 // Parse Tree Classes sclass BottomUpParser > DynSCPWithInput { start { dm_useLocallyCopiedMechLists(); set flag NoFancyMechParsing. } void update(S s) { temp enter(); if (!isShowing()) { inputChooser.forgetInput(); ret; } final new AI_BottomUpParser1 parser; parser.parse(s); AI_BottomUpParser1.Word w = parser.fullGroup(); print("Full group: " + w); if (w == null) ret; final L productions = ai_buParser_parseWeightedProductions(); print("Have " + n2(productions, "production")); ChooseCategory root = new(w, asList(w.classes), 1.0); setComponent(jDynamicTree(root, func(fO e) -> L { if (e instanceof ChooseCategory) ret map(((ChooseCategory) e).word.classes, func(S cat) { new HaveCategory(((ChooseCategory) e).word, cat) }); if (e instanceof HaveCategory) { HaveCategory h = cast e; L l = ai_buParser1_reconstructedProductions(parser, productions, h.word, h.category); ret map(l, func(ai_Reconstructed r) -> O { r.production.b == null ? new HaveCategory(r.a, r.production.a) : new ChoosePart(r) }); } if (e instanceof ChoosePart) { ai_Reconstructed r = ((ChoosePart) e).reconstruction; ret (L) ll(new HaveCategory(r.a, r.production.a), new HaveCategory(r.b, r.production.b)); } null; })); print("Made tree"); } }