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

17
LINES

< > BotCompany Repo | #1008344 // dropPunctuationAtEnd

JavaX fragment (include)

static L<S> dropPunctuationAtEnd_keep = litlist("*", "<", ">", "]", ")", "}");

static L<S> dropPunctuationAtEnd(L<S> tok) {
  tok = new ArrayList<S>(tok);
  for (int i = tok.size()-2; i > 0; i -= 2) {
    S t = tok.get(i);
    if (t.length() == 1 && !Character.isLetter(t.charAt(0)) && !Character.isDigit(t.charAt(0)) && !dropPunctuationAtEnd_keep.contains(t)) {
      tok.remove(i);
      tok.remove(i);
    } else break;
  }
  return tok;
}

static S dropPunctuationAtEnd(S s) {
  ret join(dropPunctuationAtEnd(nlTok(s)));
}

Author comment

Began life as a copy of #1000814

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: #1008344
Snippet name: dropPunctuationAtEnd
Eternal ID of this version: #1008344/5
Text MD5: 682bdebe58a7526e2a637439d84c2624
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:51
Source code size: 543 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 440 / 788
Version history: 4 change(s)
Referenced in: [show references]