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

23
LINES

< > BotCompany Repo | #1002870 // Word remover

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1269L/8K/27K).

!752

static S wordToRemove = "the";

p {
  S input = "[this is [the] sentence] [we are talking about [all [the time]]]";
  Lisp in = nlParse(input);
  print(input);
  print("s/" + wordToRemove + "//");
  print(nlUnparse(removeWord(wordToRemove, in)));
}

static Lisp removeWord(S word, Lisp in) {
  if (in.isLeaf() && eqic(in.head, word))
    ret lisp("[]");
  Lisp lisp = new Lisp(in.head);
  for (int i = 0; i < in.size(); i++) {
    Lisp translated = removeWord(word, in.get(i));
    if (!translated.is("[]", 0))
      lisp.add(translated);
  }
  ret lisp;
}

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: #1002870
Snippet name: Word remover
Eternal ID of this version: #1002870/1
Text MD5: 9c89a50df1dab44bf2c08a59af71923a
Transpilation MD5: 51de51782b8fb5b58eefc23cd7811e39
Author: stefan
Category: eleu / nl / prolog
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-03-10 18:38:34
Source code size: 584 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 527 / 592
Referenced in: #3000382 - Answer for ferdie (>> t = 1, f = 0)