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

21
LINES

< > BotCompany Repo | #1022272 // phraseCache_group

JavaX fragment (include)

1  
static LS phraseCache_group(PhraseCache cache, LS tok) {
2  
  if (cache == null) ret tok;
3  
  tok = cloneList(tok);
4  
  for (int i = 1; i < l(tok); i += 2) {
5  
    L<LS> phrases = cache.byFirstWord.get(tok.get(i));
6  
    new Best<LS> best;
7  
    for (LS phrase : phrases)
8  
      if (codeTokenSubListEqualsIC_skipFirst(tok, phrase, i))
9  
        best.put(phrase, l(phrase));
10  
    if (best.has()) {
11  
      int j = i+l(best!)-3;
12  
      tok_addCurlyBracketsAroundPart(tok, i, j);
13  
      i = j;
14  
    }
15  
  }
16  
  ret tok;
17  
}
18  
19  
static LS phraseCache_group(PhraseCache cache, S s) {
20  
  ret phraseCache_group(cache, javaTokNPunctuation(s));
21  
}

Author comment

Began life as a copy of #1022268

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022272
Snippet name: phraseCache_group
Eternal ID of this version: #1022272/4
Text MD5: 523e5ee8501c6170750f182edc10c410
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-12 15:42:17
Source code size: 625 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 248 / 283
Version history: 3 change(s)
Referenced in: [show references]