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).

1  
!752
2  
3  
static S wordToRemove = "the";
4  
5  
p {
6  
  S input = "[this is [the] sentence] [we are talking about [all [the time]]]";
7  
  Lisp in = nlParse(input);
8  
  print(input);
9  
  print("s/" + wordToRemove + "//");
10  
  print(nlUnparse(removeWord(wordToRemove, in)));
11  
}
12  
13  
static Lisp removeWord(S word, Lisp in) {
14  
  if (in.isLeaf() && eqic(in.head, word))
15  
    ret lisp("[]");
16  
  Lisp lisp = new Lisp(in.head);
17  
  for (int i = 0; i < in.size(); i++) {
18  
    Lisp translated = removeWord(word, in.get(i));
19  
    if (!translated.is("[]", 0))
20  
      lisp.add(translated);
21  
  }
22  
  ret lisp;
23  
}

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: 472 / 517
Referenced in: [show references]