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

29
LINES

< > BotCompany Repo | #1001898 // dropWords - drop words out of an NL sentence

JavaX fragment (include)

static S dropWords(S s, L<S> words) {
  ret dropWords_impl(s, asSet(toLowerCase(words)));
}

static S dropWords(S s, S words) {
  ret dropWords(s, splitWords(words));
}

static S dropWords(S s, S... words) {
  ret dropWords_impl(s, asSet(toLowerCase(words)));
}

static Set<S> dropWords_preprocess(S words) {
  ret asSet(splitWords(toLowerCase(words)));
}

static S dropWords(S s, Set<S> set) {
  ret dropWords_impl(s, asCISet(set));
}

static S dropWords_impl(S s, Set<S> set) {
  L<S> tok = nlTok(s);
  for (int i = 1; i < l(tok); )
    if (set.contains(tok.get(i).toLowerCase()))
      removeToken(tok, i);
    else
      i += 2;
  ret join(tok);
}

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: #1001898
Snippet name: dropWords - drop words out of an NL sentence
Eternal ID of this version: #1001898/3
Text MD5: 61f83c59054fb83f3c410dd440530abb
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-06 08:56:05
Source code size: 679 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 726 / 1356
Version history: 2 change(s)
Referenced in: #1001921 - replaceWords - replace certain words in an NL sentence
#1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1022059 - dropWord - drop word out of an NL sentence
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)