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

28
LINES

< > BotCompany Repo | #1028137 // test_GeneralizedSuffixTree (OK)

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

Uses 14K of libraries. Click here for Pure Java version (3609L/23K).

lib 1400378

import com.abahgat.suffixtree.*;

svoid test_GeneralizedSuffixTree() {
  new GeneralizedSuffixTree in;
  
  String word = "cacao";
  in.put(word, 0);

  /* test that every substring is contained within the tree */
  for (String s : allSubstringsWithoutEmpty(word)) {
      assertTrue(in.search(s).contains(0));
  }
  assertEmpty(in.search("caco"));
  assertEmpty(in.search("cacaoo"));
  assertEmpty(in.search("ccacao"));

  in = new GeneralizedSuffixTree();
  word = "bookkeeper";
  in.put(word, 0);
  for (String s : allSubstringsWithoutEmpty(word)) {
      assertTrue(in.search(s).contains(0));
  }
  assertEmpty(in.search("books"));
  assertEmpty(in.search("boke"));
  assertEmpty(in.search("ookepr"));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028137
Snippet name: test_GeneralizedSuffixTree (OK)
Eternal ID of this version: #1028137/2
Text MD5: 4e3fe0c23a7691bf3cf4de85fe628280
Transpilation MD5: e9d2fc60efc0a3a512d849cee3d2f0f4
Author: stefan
Category: javax / text searching
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-23 13:05:26
Source code size: 747 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 122 / 207
Version history: 1 change(s)
Referenced in: [show references]