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).

!7

static new L<S> words;

p {
  long time, lastTime = 0;
  L<S> tokens, lastTokens = ll();
  repeat with ms sleep 500 {
    S s = sendSilently("Forwarded Recognizer", "text");
    if (nempty(s)) {
      int i = s.indexOf("/");
      S sTime = substring(s, 0, i);
      if (isInteger(sTime)) {
        time = parseLong(sTime);
        s = substring(s, smartIndexOf(s, ":")+1);
        tokens = javaTokC(s);
        L<S> newTokens = time == lastTime ? dropMatchingPrefixList(tokens, lastTokens) : tokens;
        lastTokens = tokens;
        lastTime = time;
        print("New tokens: " + joinWithSpace(newTokens));
        onWords(newTokens);
      }
    }
  }
}

svoid onWords(L<S> newWords) {
  words.addAll(newWords);
  for (int i = 0; i < l(words); i++) {
    S w = words.get(i);
    if (eqic(w, "no")) {
      removeRange(words, 0, i+1);
      i = -1;
    } else if (eqicOneOf(w, "yes", "thanks")) {
      keep(subList(words, 0, i));
      removeRange(words, 0, i+1);
      i = -1;
    } else if (eqic(get(words, i-1), "thank") && eqic(last(words), "you")) {
      keep(subList(words, 0, i-1));
      removeRange(words, 0, i+1);
      i = -1;
    }
  }
}

svoid keep(L<S> words) {
  print("KEEPING: " + joinWithSpace(words));
}

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: 408 / 478
Version history: 10 change(s)
Referenced in: [show references]