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

17
LINES

< > BotCompany Repo | #1010927 // dropLeadingPunctuation

JavaX fragment (include)

1  
static L<S> dropLeadingPunctuation_keep = ll("*", "<", ">", "(", "{", "[");
2  
3  
static L<S> dropLeadingPunctuation(L<S> tok) {
4  
  tok = new ArrayList<S>(tok);
5  
  for (int i = 1; i < l(tok); ) {
6  
    S t = tok.get(i);
7  
    if (eq(t, "...") || t.length() == 1 && !Character.isLetterOrDigit(t.charAt(0)) && !dropLeadingPunctuation_keep.contains(t)) {
8  
      tok.remove(i);
9  
      tok.remove(i);
10  
    } else break;
11  
  }
12  
  return tok;
13  
}
14  
15  
static S dropLeadingPunctuation(S s) {
16  
  ret join(dropLeadingPunctuation(nlTok(s)));
17  
}

Author comment

Began life as a copy of #1008344

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1010927
Snippet name: dropLeadingPunctuation
Eternal ID of this version: #1010927/4
Text MD5: 8ed26597f13e67080faa0cb715716ff0
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-06 10:25:44
Source code size: 524 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 432 / 461
Version history: 3 change(s)
Referenced in: [show references]