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: 721 / 1350
Version history: 2 change(s)
Referenced in: [show references]