Libraryless. Click here for Pure Java version (2717L/17K).
// dictionary and connectors have to be ciSets static Chain<S> constructWordFromCISet_withConnectors(S word, Set<S> dictionary, Set<S> connectors) { ifdef constructWordFromCISet_withConnectors_debug print("checking: " + word); endifdef 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)) { S rest = substring(word, i); // try connector LS matchingConnectors = reversed(prefixesOfIC(connectors, rest)); for (S conn : matchingConnectors) { Chain<S> chain = constructWordFromCISet_withConnectors(dropPrefixIC(conn, rest), dictionary, connectors); if (chain != null) ret Chain<S>(prefix, Chain<S>(conn, chain)); } // try no connector Chain<S> chain = constructWordFromCISet_withConnectors(rest, dictionary, connectors); if (chain != null) ret Chain<S>(prefix, chain); } } null; }
Began life as a copy of #1027969
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027972 |
Snippet name: | constructWordFromCISet_withConnectors |
Eternal ID of this version: | #1027972/3 |
Text MD5: | abe1dd6d6b479478392fbb972825cee7 |
Transpilation MD5: | 945c475ba665eac774e0458bd8ecc7a8 |
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 11:11:10 |
Source code size: | 1031 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 192 / 277 |
Version history: | 2 change(s) |
Referenced in: | [show references] |