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

27
LINES

< > BotCompany Repo | #1016013 // Word Type [Dyn Module]

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

Libraryless. Click here for Pure Java version (15378L/108K).

!7

set flag NoFancyMechParsing.

sclass WordType extends DynModule {
  S word;         // input
  L<S> wordTypes; // output
  
  JComponent visualize() {
    ret jSection("WORD TYPE",
      jCenteredMultiLineLiveValueLabel(dm_calculatedLiveValue(this, S, func -> S {
        word + " -> " + or2(joinWithComma(wordTypes), "?")
      })));
  }
  
  void update {
    S s = trim(dm_getInterestingString());
    if (nempty(s) && setField(word := s)) {
      Set<S> types = treeSet();
      SS map = mechMapCI("Singular => Plural");
      if (nempty(map.get(word))) types.add("noun (singular)");
      if (nempty(reverseLookupCI(map, word))) types.add("noun (plural)");
      if (contains(mechSetCI("Adjectives"), word)) types.add("adjective");
      setField(wordTypes := asList(types));
    }
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016013
Snippet name: Word Type [Dyn Module]
Eternal ID of this version: #1016013/11
Text MD5: 9d67e827fb7ff6cc9a54689e49853bcc
Transpilation MD5: dbb6c8447ac969fd888d5a6d1703749b
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-08 18:38:31
Source code size: 822 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 323 / 578
Version history: 10 change(s)
Referenced in: [show references]