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

28
LINES

< > BotCompany Repo | #1011209 // ai_tok_combinePhrases

JavaX fragment (include)

static int ai_tok_combinePhrases_maxPhraseLength = 3; // 3 words, see #1011207

static L<S> ai_tok_combinePhrases(L<S> tok) {
  ret ai_tok_combinePhrases(tok, f isKnownPhrase);
}

static L<S> ai_tok_combinePhrases(L<S> tok, O isKnownPhrase) {
  new L<S> l;
  int n = l(tok);
  bigloop: for i over tok: {
    S t = tok.get(i);
    if (odd(i)) {
      S phrase = t;
      int j = i+2;
      while (j < n && j < i+ai_tok_combinePhrases_maxPhraseLength*2) {
        phrase += " " + tok.get(j);
        if (isTrue(callF(isKnownPhrase, phrase))) {
          l.add(joinSubList(tok, i, j+1));
          i = j;
          continue bigloop;
        }
        j += 2;
      }
    }
    l.add(t);
  }
  ret l;
}

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: #1011209
Snippet name: ai_tok_combinePhrases
Eternal ID of this version: #1011209/4
Text MD5: 598880ac973c67bfd51213a98a4a6cce
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-19 18:51:21
Source code size: 725 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 462 / 507
Version history: 3 change(s)
Referenced in: [show references]