!7 sclass Line { S text, interpretation; sS _fieldOrder = "text interpretation"; } cmodule SimpleWikipediaSentences > DynTableWithInput { S topic; start { set fieldsInOrder; dm_vmBus_onMessage_q('gazelleRulesChanged, r forceUpdate); } afterVisualize { tablePopupMenuItemsThreaded(table(), "Ignore", r ignoreLine, "Make rule...", r makeRule); } void update(S topic) { topic = trim(topic); setField(+topic); setModuleName(topic + " - Simple Wikipedia"); final L data = cloneList_putInField Line('text, simpleWikipedia_sentencesForTopic(topic)); fS _topic = topic; time "Interpret Lines" { //showText("Profile", poorMansProfileToString(r { LPair ignore = dm_gazelle_linesToIgnoreForSimpleWikipediaTopic(_topic); GazelleEvalContext ctx = dm_gazelle_stdEvalContext(); for i over data: { Line l = data.get(i); if (contains(ignore, pair(l.text, i))) continue with l.interpretation = 'ignore; GazelleTree tree = new(l.text); tree.ctx = ctx; dm_gazelle_getChildren(tree); if (nempty(tree.children)) l.interpretation = first(tree.children).line; } setData(data); //})); } } void ignoreLine { int i = selectedIndex(); Line line = selected(); if (line == null) ret; LS context = collect text(subList(data(), 0, i)); LS comments = ll( "out = action", "from simple wikipedia topic " + optQuote(topic), "previous lines = " + quote(lines_rtrim(context))); dm_gazelle_addRuleWithComment(line.text + "\n=> ignore", lines_rtrim(comments)); } void makeRule { Line line = selected(); if (line == null) ret; dm_gazelle_newRuleDialog_3(line.text); } }