Libraryless. Click here for Pure Java version (5086L/33K/112K).
1 | !752 |
2 | |
3 | concepts. |
4 | |
5 | concept Language { |
6 | S name; |
7 | } |
8 | |
9 | concept Word { |
10 | S text; |
11 | } |
12 | |
13 | concept ProbablyInLanguage { |
14 | new Ref<Word> word; |
15 | new Ref<Language> language; |
16 | } |
17 | |
18 | p { |
19 | loadAndAutoSaveConcepts(); |
20 | print("Have " + n(countConcepts(Language), "languages") |
21 | + ", " + n(countConcepts(Word), "words")); |
22 | makeBot(); |
23 | } |
24 | |
25 | synchronized answer { |
26 | if "add to * *" { |
27 | S langName = toLowerCase($1), text = $2; |
28 | if (!hasConcept(Language, langName)) |
29 | print("New language: " + langName); |
30 | Language language = uniq(Language, langName); |
31 | int newWords = countConcepts(ProbablyInLanguage); |
32 | for (S word : codeTokens(javaTok(text))) |
33 | uniq(ProbablyInLanguage, +language, |
34 | word := uniq(Word, toLowerCase(word))); |
35 | newWords = countConcepts(ProbablyInLanguage)-newWords; |
36 | ret "Thanks. " + (newWords == 0 ? "I knew all these words already :)" |
37 | : n(newWords, "new words") + " learned!"); |
38 | } |
39 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005260 |
Snippet name: | Collect Words [works] |
Eternal ID of this version: | #1005260/1 |
Text MD5: | b81d67bc3f1146cff4fa4398c1454168 |
Transpilation MD5: | 1efec228e86e624eee609939d8bb1ea3 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-11-16 00:24:54 |
Source code size: | 949 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 601 / 857 |
Referenced in: | [show references] |