Uses 911K of libraries. Click here for Pure Java version (16595L/96K).
1 | !7 |
2 | |
3 | /*sclass Interpretable { |
4 | S text; |
5 | RuleEngine_MatchedRule2 matched; |
6 | }*/ |
7 | |
8 | sclass Entry { |
9 | long msgID; |
10 | S originalLine; |
11 | S interpretableText; |
12 | S matchedRuleStruct; |
13 | |
14 | sS _fieldOrder = "msgID originalLine interpretableText"; |
15 | } |
16 | |
17 | set flag DynModule. |
18 | |
19 | cmodule InterpretableTest > DynObjectTable<Entry> { |
20 | start { |
21 | addCountToName(); |
22 | thread { scan(); } |
23 | } |
24 | |
25 | visualize { |
26 | ret withCenteredButtons(super.visualize(), "Scan", rThread scan); |
27 | } |
28 | |
29 | void scan enter { |
30 | new L<Entry> list; |
31 | new Flag interrupted; |
32 | temp AutoCloseable action = dm_currentAction("Scanning chat", rRaiseFlag(interrupted)); |
33 | F0<GazelleEvalContext> contextMaker = new GazelleContextCache_v2().fill(); |
34 | L<GazelleLine> lines = dm_discord_allLines(); |
35 | int i = 0; |
36 | for (GazelleLine line : lines) { |
37 | ++i; |
38 | if (!licensed() || interrupted!) break; |
39 | Collection<S> l = getInterpretables(line, +contextMaker); |
40 | for (S interpretableText : l) |
41 | list.add(nu Entry(originalLine := line.text, msgID := line.msgID, +interpretableText)); |
42 | call(action, 'setText, "Found " + n2(list, "interpretable") + ", scanned " + i + "/" + n2(lines, "line")); |
43 | } |
44 | setList(list); |
45 | } |
46 | |
47 | Collection<S> getInterpretables(GazelleLine line, O... _) { |
48 | Set<S> interpretables = linkedCISet(); // fancy new ordered case-insensitive set |
49 | RuleEngine2 engine = ((F0<GazelleEvalContext>) optPar contextMaker(_)).get().engine; |
50 | for (RuleEngine2.SimplifyWithRule rule : engine.splitterRules()) pcall { |
51 | _addAll(interpretables, gazelle_executeSplitterRule(engine, rule, line.text)); |
52 | } |
53 | |
54 | _addAll(interpretables, collect line( |
55 | dm_gazelle_reasonAboutChatInput_v2(null, line.text, |
56 | paramsPlus(_, skipSplitters := true, acceptablePurposes := litset('preprocess))))); |
57 | |
58 | interpretables.remove(line.text); |
59 | ret interpretables; |
60 | } |
61 | } |
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: | #1022170 |
Snippet name: | Interpretables Test v1 [OK] |
Eternal ID of this version: | #1022170/24 |
Text MD5: | 67197b9b27cae6f96161b6673864e3cd |
Transpilation MD5: | 50d993c41504e1e67b424175f5869da5 |
Author: | stefan |
Category: | javax / concepts |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-10 13:31:33 |
Source code size: | 1941 bytes / 61 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 324 / 688 |
Version history: | 23 change(s) |
Referenced in: | [show references] |