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

35
LINES

< > BotCompany Repo | #1012219 // ai_tripelize_howLongEtc

JavaX fragment (include)

static T3<S> ai_tripelize_howLongEtc(S s) {
  ret ai_tripelize_howLongEtc(s, ai_tripelize_prepare(s));
}

static T3<S> ai_tripelize_howLongEtc(S s, L<S> tok) {
  //printStruct(tok);
  if (eqicGetOneOf(tok, 1, "how", "what")) {
    // e.g. how long is the string "bla"?
    int verb = indexOfFirstVerb(tok);
    S v = get(tok, verb);
    
    if (eqicOneOf(v, "does", "do", "have")) {
      // e.g. How many characters does the string "abcd" contain?
      int verb2 = indexOfFirstVerbOrPastParticiple(tok, verb+2);
      if (verb2 >= 0) {
        S a = v; // helper verb
        v = get(tok, verb2);
        print("verb: " + v);
        S middle = trimJoinSubList(tok, verb+2, verb2);
        S rest = trimJoinSubList(tok, verb2+1);
        v = ai_tripelize_helperVerb(a, v);
        ret t3(
          middle,
          dropSuffix("?", v),
          trim(trimJoinSubList(tok, 0, verb) + " " + rest) + "?");
      }
    }
    
    ret t3(
      trimJoinSubList(tok, verb+1),
      v,
      trimJoinSubList(tok, 0, verb) + "?");
  }
  null;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012219
Snippet name: ai_tripelize_howLongEtc
Eternal ID of this version: #1012219/15
Text MD5: a0ebb6503534d6d3e0c4a9827c141892
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-30 18:36:35
Source code size: 1074 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 422 / 445
Version history: 14 change(s)
Referenced in: [show references]