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

39
LINES

< > BotCompany Repo | #1011108 // ai_fixTriple - move adverbs to relation, other stuff

JavaX fragment (include)

// changes original
static T3<S> ai_fixTriple(T3<S> t) {
  if (t == null) ret t;
  t.a = ai_fix(t.a);
  t.b = ai_fix(t.b);
  t.c = ai_fix(t.c);
  
  // adverbs at end of A part
  L<S> tok = javaTokC(t.a); S s = last(tok);
  while (l(tok) > 1 && (isAdverb(s) || eqicOneOf(s, "can", "should", "rather", "will"))) {
    tok = javaTokC(t.a = trim(dropLastJavaToken(t.a)));
    t.b = s + " " + t.b;
    s = last(tok);
  }
  
  // adverbs at beginning of A part
  s = first(tok);
  while (l(tok) > 1 && isAdverb(s)) {
    tok = javaTokC(t.a = trim(dropFirstJavaToken(t.a)));
    t.b = s + " " + t.b;
    s = first(tok);
  }
  
  if (l(tok) > 1 && eqicOneOf(first(tok), "why", "today")) {
    t.a = trim(dropFirstJavaToken(t.a));
    t.b = first(tok) + " " + t.b;
  }

  // adverbs at end of C part
  tok = javaTokC(t.c); s = last(tok);
  while (l(tok) > 1 && (isAdverb(s) || eqicOneOf(s, "today"))) {
    t.c = trim(dropLastJavaToken(t.c));
    t.b = s + " " + t.b;
    tok = javaTokC(t.c); s = last(tok);
  }
  if (empty(t.c)) t.c = ".";
  
  ret t;
}

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: #1011108
Snippet name: ai_fixTriple - move adverbs to relation, other stuff
Eternal ID of this version: #1011108/29
Text MD5: b45470e5c90dc4fb7c4df84dc51e59ce
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-31 19:28:09
Source code size: 1084 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 419 / 502
Version history: 28 change(s)
Referenced in: [show references]