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

35
LINES

< > TinyBrain | #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")) {
      // e.g. How many characters does the string "abcd" contain?
      int verb2 = indexOfFirstVerb(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   

Travelled to 10 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1012219
Snippet name: ai_tripelize_howLongEtc
Eternal ID of this version: #1012219/13
Text MD5: af0147747e63c129df886cff3ee558de
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-12 10:20:48
Source code size: 1050 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 139 / 140
Version history: 12 change(s)
Referenced in: [show]