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

19
LINES

< > BotCompany Repo | #1000814 // dropPunctuation

JavaX fragment (include)

1  
static L<S> dropPunctuation_keep = ll("*", "<", ">");
2  
3  
static L<S> dropPunctuation(L<S> tok) {
4  
  tok = new ArrayList<S>(tok);
5  
  for (int i = 1; i < tok.size(); i += 2) {
6  
    S t = tok.get(i);
7  
    if (t.length() == 1 && !Character.isLetter(t.charAt(0)) && !Character.isDigit(t.charAt(0)) && !dropPunctuation_keep.contains(t)) {
8  
      tok.set(i-1, tok.get(i-1) + tok.get(i+1));
9  
      tok.remove(i);
10  
      tok.remove(i);
11  
      i -= 2;
12  
    }
13  
  }
14  
  return tok;
15  
}
16  
17  
static S dropPunctuation(S s) {
18  
  ret join(dropPunctuation(nlTok(s)));
19  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1000814
Snippet name: dropPunctuation
Eternal ID of this version: #1000814/2
Text MD5: 3a7b382cc003e763b3b4aa108e2cc03a
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-15 20:33:11
Source code size: 549 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 796 / 7661
Version history: 1 change(s)
Referenced in: [show references]