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

13
LINES

< > BotCompany Repo | #1027969 - constructWordFromCISet

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2567L/16K).

// dictionary has to be a ciSet
static Chain<S> constructWordFromCISet(S word, Set<S> dictionary) {
  if (contains(dictionary, word)) ret Chain<S>(word);
  for ping (int i = l(word)-1; i > 0; i--) {
    S prefix = takeFirst(i, word);
    if (contains(dictionary, prefix)) {
      Chain<S> chain = constructWordFromCISet(substring(word, i), dictionary);
      if (chain != null)
        ret Chain<S>(prefix, chain);
    }
  }
  null;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027969
Snippet name: constructWordFromCISet
Eternal ID of this version: #1027969/6
Text MD5: d6069cb117e5df9309ae1de01fa0a3ac
Transpilation MD5: 98dc665b988e84b9e21cc831d163b323
Author: stefan
Category: javax / nlp
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-21 10:50:13
Source code size: 446 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 57 / 115
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1027969 & http://1027969.tinybrain.de