Uses 911K of libraries. Click here for Pure Java version (16603L/97K).
1 | !7 |
2 | |
3 | sclass Interpretable { |
4 | S text; |
5 | S ruleID; |
6 | |
7 | *() {} |
8 | *(S *text, S *ruleID) {} |
9 | } |
10 | |
11 | sclass Entry { |
12 | long msgID; |
13 | S originalLine; |
14 | S interpretableText; |
15 | S ruleID; |
16 | //S matchedRuleStruct; |
17 | |
18 | sS _fieldOrder = "msgID originalLine interpretableText"; |
19 | } |
20 | |
21 | set flag DynModule. |
22 | |
23 | cmodule InterpretableTest > DynObjectTable<Entry> { |
24 | start { |
25 | addCountToName(); |
26 | thread { scan(); } |
27 | } |
28 | |
29 | visualize { |
30 | ret withCenteredButtons(super.visualize(), "Scan", rThread scan); |
31 | } |
32 | |
33 | void scan enter { |
34 | new L<Entry> list; |
35 | new Flag interrupted; |
36 | temp AutoCloseable action = dm_currentAction("Scanning chat", rRaiseFlag(interrupted)); |
37 | F0<GazelleEvalContext> contextMaker = new GazelleContextCache_v2().fill(); |
38 | L<GazelleLine> lines = dm_discord_allLines(); |
39 | int i = 0; |
40 | for (GazelleLine line : reversed(lines)) { |
41 | ++i; |
42 | if (!licensed() || interrupted!) break; |
43 | Collection<Interpretable> l = getInterpretables(line, +contextMaker); |
44 | for (Interpretable intp : l) |
45 | list.add(nu Entry(originalLine := line.text, msgID := line.msgID, interpretableText := intp.text, ruleID := intp.ruleID)); |
46 | call(action, 'setText, "Found " + n2(list, "interpretable") + ", scanned " + i + "/" + n2(lines, "line")); |
47 | } |
48 | setList(list); |
49 | } |
50 | |
51 | Collection<Interpretable> getInterpretables(GazelleLine line, O... _) { |
52 | Set<S> texts = litCISet(line.text); |
53 | new L<Interpretable> interpretables; |
54 | RuleEngine2 engine = ((F0<GazelleEvalContext>) optPar contextMaker(_)).get().engine; |
55 | |
56 | for (RuleEngine2.SimplifyWithRule rule : engine.splitterRules()) pcall { |
57 | for (S out : gazelle_executeSplitterRule(engine, rule, line.text)) |
58 | if (texts.add(out)) |
59 | interpretables.add(new Interpretable(out, rule.globalID)); |
60 | } |
61 | |
62 | for (GazelleTree t : dm_gazelle_reasonAboutChatInput_v2(null, line.text, |
63 | paramsPlus(_, skipSplitters := true, acceptablePurposes := litset('preprocess)))) |
64 | if (texts.add(t.line)) |
65 | interpretables.add(new Interpretable(t.line, t.ruleID())); |
66 | |
67 | ret interpretables; |
68 | } |
69 | } |
Began life as a copy of #1022170
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022179 |
Snippet name: | Interpretables Test v2 [going backwards through chat, with rule IDs, OK] |
Eternal ID of this version: | #1022179/5 |
Text MD5: | 3f20fc10544c768ef898e1eaea1b1edf |
Transpilation MD5: | e926efd238906433e1f1bef9155e1013 |
Author: | stefan |
Category: | javax / gazelle |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-10 13:55:01 |
Source code size: | 2162 bytes / 69 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 330 / 419 |
Version history: | 4 change(s) |
Referenced in: | [show references] |