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

13
LINES

< > BotCompany Repo | #1014304 // ngrams_iterator - get all n-grams from a text

JavaX fragment (include)

static IterableIterator<S> ngrams_iterator(final int n, fS s) {
  final int max = l(s)-n;
  ret iteratorFromFunction(new F0<S> {
    int i;
    
    S get() {
      if (i > max) null;
      S x = substring(s, i, i+n);
      ++i;
      ret x;
    }
  });
}

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: #1014304
Snippet name: ngrams_iterator - get all n-grams from a text
Eternal ID of this version: #1014304/5
Text MD5: 76647b757477e654ddc441684537c89a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-04-20 01:32:55
Source code size: 267 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 452 / 470
Version history: 4 change(s)
Referenced in: [show references]