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

36
LINES

< > BotCompany Repo | #1017160 // Grouper [Dyn Module, dev.]

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

Libraryless. Click here for Pure Java version (9286L/65K).

!7

sclass InputGrouper > DynPrintLog {
  InputChooser inputChooser = new(this);
  transient Set<S> phrases;
  transient LS groupings;
  
  start {
    dm_onTopInput(r update);
  }
  
  visualize {
    ret northAndCenter(wrap(inputChooser), super.visualize());
  }

  void update {
    if (inputChooser.update()) {
      S s = inputChooser.input();
      phrases = getPhrases();
      S grouped = join(mapCodeTokens curlyBraceIfMoreThanOneToken(ai_tok_combinePhrases(javaTok(s), func(S s) { contains(phrases, s) })));
      setField(groupings := eq(grouped, s) ? emptyList() : ll(grouped));
      if (nempty(groupings)) {
        print("Sending groupings");
        vmBus_send('newInputGroupings, module(), s, groupings);
      }
      print("< " + s);
      print("> " + grouped);
    }
  }
  
  Set<S> getPhrases() {
    Set<S> set = ciSet();
    set.addAll(collect input((L) dm_requireAndCallModule("#1020901/NounList", 'data)));
    ret set;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017160
Snippet name: Grouper [Dyn Module, dev.]
Eternal ID of this version: #1017160/11
Text MD5: bff6fc006d388c44b44d61d7c72a6331
Transpilation MD5: 0f2ddc2a73616202b1695b14fe7b8d46
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-19 19:03:49
Source code size: 986 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 320 / 662
Version history: 10 change(s)
Referenced in: #1017191 - DynPrintLogWithInput