1 | static int ai_tok_combinePhrases_maxPhraseLength = 3; // 3 words, see #1011207 |
2 | |
3 | static L<S> ai_tok_combinePhrases(L<S> tok) { |
4 | ret ai_tok_combinePhrases(tok, f isKnownPhrase); |
5 | } |
6 | |
7 | static L<S> ai_tok_combinePhrases(L<S> tok, O isKnownPhrase) { |
8 | new L<S> l; |
9 | int n = l(tok); |
10 | bigloop: for i over tok: { |
11 | S t = tok.get(i); |
12 | if (odd(i)) { |
13 | S phrase = t; |
14 | int j = i+2; |
15 | while (j < n && j < i+ai_tok_combinePhrases_maxPhraseLength*2) { |
16 | phrase += " " + tok.get(j); |
17 | if (isTrue(callF(isKnownPhrase, phrase))) { |
18 | l.add(joinSubList(tok, i, j+1)); |
19 | i = j; |
20 | continue bigloop; |
21 | } |
22 | j += 2; |
23 | } |
24 | } |
25 | l.add(t); |
26 | } |
27 | ret l; |
28 | } |
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: | 464 / 510 |
Version history: | 3 change(s) |
Referenced in: | [show references] |