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

25
LINES

< > BotCompany Repo | #1024521 - dropPunctuation3 [experimental]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (1780L/12K).

scope dropPunctuation3.

static LS #keep = ll("*", "<", ">");
static SS #cache = defaultSizeMRUCache();

static LS dropPunctuation3(LS tok) {
  tok = new ArrayList<S>(tok);
  for (int i = 1; i < tok.size(); i += 2) {
    S t = tok.get(i);
    if (t.length() == 1 && !Character.isLetter(t.charAt(0)) && !Character.isDigit(t.charAt(0)) && !dropPunctuation3_keep.contains(t)) {
      tok.set(i-1, tok.get(i-1) + tok.get(i+1));
      tok.remove(i);
      tok.remove(i);
      i -= 2;
    }
  }
  return tok;
}

sS dropPunctuation3(S s) {
  ret getOrCreate_f0(cache, s,
    () -> join(dropPunctuation3(javaTokNoQuotes(s)));
}

end scope

Author comment

Began life as a copy of #1000814

download  show line numbers  debug dex   

Travelled to 2 computer(s): mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1024521
Snippet name: dropPunctuation3 [experimental]
Eternal ID of this version: #1024521/5
Text MD5: 7b3ed51c10aa4496cb3bf6c5dcfe398a
Transpilation MD5: 3b4235733009eaf0b101b755511a418e
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-17 16:06:37
Source code size: 655 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 13 / 34
Version history: 4 change(s)
Referenced in: [show references]