Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

61
LINES

< > BotCompany Repo | #1022170 // Interpretables Test v1 [OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (16595L/96K).

!7

/*sclass Interpretable {
  S text;
  RuleEngine_MatchedRule2 matched;
}*/

sclass Entry {
  long msgID;
  S originalLine;
  S interpretableText;
  S matchedRuleStruct;
  
  sS _fieldOrder = "msgID originalLine interpretableText";
}

set flag DynModule.

cmodule InterpretableTest > DynObjectTable<Entry> {
  start {
    addCountToName();
    thread { scan(); }
  }
  
  visualize {
    ret withCenteredButtons(super.visualize(), "Scan", rThread scan);
  }
  
  void scan enter {
    new L<Entry> list;
    new Flag interrupted;
    temp AutoCloseable action = dm_currentAction("Scanning chat", rRaiseFlag(interrupted));
    F0<GazelleEvalContext> contextMaker = new GazelleContextCache_v2().fill();
    L<GazelleLine> lines = dm_discord_allLines();
    int i = 0;
    for (GazelleLine line : lines) {
      ++i;
      if (!licensed() || interrupted!) break;
      Collection<S> l = getInterpretables(line, +contextMaker);
      for (S interpretableText : l)
        list.add(nu Entry(originalLine := line.text, msgID := line.msgID, +interpretableText));
      call(action, 'setText, "Found " + n2(list, "interpretable") + ", scanned " + i + "/" + n2(lines, "line"));
    }
    setList(list);
  }
  
  Collection<S> getInterpretables(GazelleLine line, O... _) {
    Set<S> interpretables = linkedCISet(); // fancy new ordered case-insensitive set
    RuleEngine2 engine = ((F0<GazelleEvalContext>) optPar contextMaker(_)).get().engine;
    for (RuleEngine2.SimplifyWithRule rule : engine.splitterRules()) pcall {
      _addAll(interpretables, gazelle_executeSplitterRule(engine, rule, line.text));
    }
    
    _addAll(interpretables, collect line(
      dm_gazelle_reasonAboutChatInput_v2(null, line.text, 
        paramsPlus(_, skipSplitters := true, acceptablePurposes := litset('preprocess)))));
        
    interpretables.remove(line.text);
    ret interpretables;
  }
}

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: 325 / 689
Version history: 23 change(s)
Referenced in: #1022179 - Interpretables Test v2 [going backwards through chat, with rule IDs, OK]