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)

1  
// changes original
2  
static T3<S> ai_fixTriple(T3<S> t) {
3  
  if (t == null) ret t;
4  
  t.a = ai_fix(t.a);
5  
  t.b = ai_fix(t.b);
6  
  t.c = ai_fix(t.c);
7  
  
8  
  // adverbs at end of A part
9  
  L<S> tok = javaTokC(t.a); S s = last(tok);
10  
  while (l(tok) > 1 && (isAdverb(s) || eqicOneOf(s, "can", "should", "rather", "will"))) {
11  
    tok = javaTokC(t.a = trim(dropLastJavaToken(t.a)));
12  
    t.b = s + " " + t.b;
13  
    s = last(tok);
14  
  }
15  
  
16  
  // adverbs at beginning of A part
17  
  s = first(tok);
18  
  while (l(tok) > 1 && isAdverb(s)) {
19  
    tok = javaTokC(t.a = trim(dropFirstJavaToken(t.a)));
20  
    t.b = s + " " + t.b;
21  
    s = first(tok);
22  
  }
23  
  
24  
  if (l(tok) > 1 && eqicOneOf(first(tok), "why", "today")) {
25  
    t.a = trim(dropFirstJavaToken(t.a));
26  
    t.b = first(tok) + " " + t.b;
27  
  }
28  
29  
  // adverbs at end of C part
30  
  tok = javaTokC(t.c); s = last(tok);
31  
  while (l(tok) > 1 && (isAdverb(s) || eqicOneOf(s, "today"))) {
32  
    t.c = trim(dropLastJavaToken(t.c));
33  
    t.b = s + " " + t.b;
34  
    tok = javaTokC(t.c); s = last(tok);
35  
  }
36  
  if (empty(t.c)) t.c = ".";
37  
  
38  
  ret t;
39  
}

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: 363 / 439
Version history: 28 change(s)
Referenced in: [show references]