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

48
LINES

< > BotCompany Repo | #1008247 // Yes No Erase

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (4419L/29K/97K).

1  
!7
2  
3  
static new L<S> words;
4  
5  
p {
6  
  long time, lastTime = 0;
7  
  L<S> tokens, lastTokens = ll();
8  
  repeat with ms sleep 500 {
9  
    S s = sendSilently("Forwarded Recognizer", "text");
10  
    if (nempty(s)) {
11  
      int i = s.indexOf("/");
12  
      S sTime = substring(s, 0, i);
13  
      if (isInteger(sTime)) {
14  
        time = parseLong(sTime);
15  
        s = substring(s, smartIndexOf(s, ":")+1);
16  
        tokens = javaTokC(s);
17  
        L<S> newTokens = time == lastTime ? dropMatchingPrefixList(tokens, lastTokens) : tokens;
18  
        lastTokens = tokens;
19  
        lastTime = time;
20  
        print("New tokens: " + joinWithSpace(newTokens));
21  
        onWords(newTokens);
22  
      }
23  
    }
24  
  }
25  
}
26  
27  
svoid onWords(L<S> newWords) {
28  
  words.addAll(newWords);
29  
  for (int i = 0; i < l(words); i++) {
30  
    S w = words.get(i);
31  
    if (eqic(w, "no")) {
32  
      removeRange(words, 0, i+1);
33  
      i = -1;
34  
    } else if (eqicOneOf(w, "yes", "thanks")) {
35  
      keep(subList(words, 0, i));
36  
      removeRange(words, 0, i+1);
37  
      i = -1;
38  
    } else if (eqic(get(words, i-1), "thank") && eqic(last(words), "you")) {
39  
      keep(subList(words, 0, i-1));
40  
      removeRange(words, 0, i+1);
41  
      i = -1;
42  
    }
43  
  }
44  
}
45  
46  
svoid keep(L<S> words) {
47  
  print("KEEPING: " + joinWithSpace(words));
48  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008247
Snippet name: Yes No Erase
Eternal ID of this version: #1008247/11
Text MD5: 0436976d8568afa004f182e3fda14c57
Transpilation MD5: 35b003a4681dbfe73942619a5830d939
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-03 14:48:09
Source code size: 1281 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 486 / 586
Version history: 10 change(s)
Referenced in: [show references]