Libraryless. Click here for Pure Java version (15378L/108K).
1 | !7 |
2 | |
3 | set flag NoFancyMechParsing. |
4 | |
5 | sclass WordType extends DynModule { |
6 | S word; // input |
7 | L<S> wordTypes; // output |
8 | |
9 | JComponent visualize() { |
10 | ret jSection("WORD TYPE", |
11 | jCenteredMultiLineLiveValueLabel(dm_calculatedLiveValue(this, S, func -> S { |
12 | word + " -> " + or2(joinWithComma(wordTypes), "?") |
13 | }))); |
14 | } |
15 | |
16 | void update { |
17 | S s = trim(dm_getInterestingString()); |
18 | if (nempty(s) && setField(word := s)) { |
19 | Set<S> types = treeSet(); |
20 | SS map = mechMapCI("Singular => Plural"); |
21 | if (nempty(map.get(word))) types.add("noun (singular)"); |
22 | if (nempty(reverseLookupCI(map, word))) types.add("noun (plural)"); |
23 | if (contains(mechSetCI("Adjectives"), word)) types.add("adjective"); |
24 | setField(wordTypes := asList(types)); |
25 | } |
26 | } |
27 | } |
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: | 396 / 677 |
Version history: | 10 change(s) |
Referenced in: | [show references] |