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

26
LINES

< > BotCompany Repo | #1029223 // testSuffixTreeSystematically

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

Libraryless. Click here for Pure Java version (15105L/102K).

svoid testSuffixTreeSystematically(int max, O... _) {
  optPar bool verbose;
  optPar bool checkOverlongQueries = true;
  
  for (int n = 0; n <= max; n++) {
    print("Testing length " + n);
    int tests = 0;
    for (S text : allABCCombinationsOfLength(n)) {
      //print(+text);
      SuffixTree tree = new(text);
      if (l(text) <= 4) tree.printMe();
      for (int j = 1; j <= n+(checkOverlongQueries ? 1 : 0); j++)
        for (S query : allABCCombinationsOfLength(j)) {
          ++tests;
          L<Int> correct = indicesOf(text, query);
          L<Int> out = sorted(tree.indicesOf(query));
          if (eq(correct, out)) {
            if (verbose) print("OK " + query + " in " + text + ": " + out);
          } else {
            fail(query + " in " + text + ": " + out + " / " + correct);
          }
        }
    }
    print(nTests(tests) + " done");
  }
}

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: #1029223
Snippet name: testSuffixTreeSystematically
Eternal ID of this version: #1029223/4
Text MD5: b8f9d5b7c6c3b214c67f3c6715de6e8b
Transpilation MD5: 9317d129096c970ca8e7322c4f8d1017
Author: stefan
Category: javax / text searching
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-26 02:21:34
Source code size: 900 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 194 / 274
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)