Uses 911K of libraries. Click here for Pure Java version (5586L/28K).
1 | !7 |
2 | |
3 | sS phrases = [[ |
4 | United States of America |
5 | God save the queen |
6 | Bed and Breakfast |
7 | ]]; |
8 | |
9 | sS inputs = [[ |
10 | United States of Incarceration |
11 | God shave the queen |
12 | Bed and Butter |
13 | ]]; |
14 | |
15 | /* Gazelle-style program (just for illustration): |
16 | |
17 | $x is said |
18 | + $y is a phrase |
19 | + $old, $new = gazelle_singleChangedWord($y, $x) |
20 | + $capitalized = capitalizeWord($y, $old) |
21 | => No no no. $capitalized! |
22 | |
23 | */ |
24 | |
25 | cmodule PhraseCorrector > DynPrintLogAndEnabled { |
26 | class Engine implements Runnable { |
27 | S input; |
28 | LS phrases = tlft(main.phrases); |
29 | |
30 | Collection<S> iterate__$x_is_said() { ret singletonUnlessNull(input); } |
31 | Collection<S> iterate__$y_is_a_phrase() { ret phrases; } |
32 | |
33 | // Gazelle-style program translated to JavaX: |
34 | |
35 | run { |
36 | for ping (S $x : iterate__$x_is_said()) { |
37 | for ping (S $y : iterate__$y_is_a_phrase()) { |
38 | for single (unpair S $old, $new : gazelle_singleChangedWord($y, $x)) { |
39 | for single (S $capitalized : capitalizeWord($y, $old)) { |
40 | emit("No no no. \*$capitalized*/!"); |
41 | } |
42 | } |
43 | } |
44 | } |
45 | } |
46 | } |
47 | |
48 | void process(S input, bool speak) { |
49 | temp tempSetTL(emit_print_prefix, "[Bot] "); |
50 | temp speak ? tempSetTL(emit_onEmit, ll(vf<S> dm_say)) : null; |
51 | pcallF(setAll(new Engine, input := nlPrint("[User] ", input))); |
52 | } |
53 | |
54 | start-thread { |
55 | for (S input : tlft(inputs)) process(input, false); |
56 | dm_onTopInput_q(voidfunc(S s) { if (enabled) process(s, true) }); |
57 | } |
58 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023066 |
Snippet name: | Phrase Corrector Demo |
Eternal ID of this version: | #1023066/36 |
Text MD5: | 270fc2d3ddee04184d1116ba305c7fa5 |
Transpilation MD5: | 67f241fb3433dad8fad226ad179fbec9 |
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: | 2019-05-03 03:56:40 |
Source code size: | 1538 bytes / 58 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 350 / 997 |
Version history: | 35 change(s) |
Referenced in: | [show references] |