Uses 911K of libraries. Click here for Pure Java version (5029L/26K).
!7 srecord Guesser(S regexp, S annotation) {} cmodule CLAG > DynPrintLogAndEnabled { new Map<S, LS> entries; // text -> annotations L<Guesser> guessers = litsynclist(Guesser("eval", "eval command")); sclass ByCategory { Guesser bestGuesser; } start { doEveryAndNow(5.0, r step); } void step enter { if (!enabled) ret; temp tempPrintTime(); dm_clearModulePrintLog(); // find annotator module S mod = annotator(); if (empty(mod)) ret; // get visible rows IntRange vis = cast quickImport(dm_rcall visibleRows(mod)); if (vis == null) ret; L<virtual Entry> allData = (L) dm_rcall data(mod); L visibleData = subList(allData, vis); // get all annotations (without "!") Set<S> allClasses = asCISet(dropPrefixAll("!", (Collection<S>) dm_rcall allAnnotations(mod))); print(+allClasses); // update entry map fOr (virtual Entry e : allData) { S text = getString text(e); LS annotations = cast rcall annotations(e); entries.put(text, annotations); } // go through classes for (S c : allClasses) { LS plusExamples = keysWhereValueContains(c, entries); LS minusExamples = keysWhereValueContains("!" + c, entries); print(c + ": " + l(plusExamples) + "/" + l(minusExamples)); } // guess visible rows bool change; fOr (virtual Entry e : visibleData) { S text = getString text(e); LS annotations = cast rcall annotations(e); Set<S> guesses = ciSet(); for (Guesser guesser : guessers) if (regexpFindIC(guesser.regexp, text)) guesses.add(guesser.annotation); S guess = joinWithComma(guesses); if (set_trueIfChanged(e, +guess)) set change; } if (change) dm_rcall fireDataChanged(mod); } S annotator() { ret dm_moduleWithSnippetID(#1024172); } }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1024174 |
Snippet name: | Chat Line Annotation Guesser [dev.] |
Eternal ID of this version: | #1024174/20 |
Text MD5: | 046fe6296c06567176ec6cf740cc8f69 |
Transpilation MD5: | 789b8dc42beea758717978ed3bb0c5cc |
Author: | stefan |
Category: | javax / stefan's os / a.i |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-07-24 19:29:34 |
Source code size: | 1979 bytes / 72 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 261 / 654 |
Version history: | 19 change(s) |
Referenced in: | [show references] |