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

1  
svoid testSuffixTreeSystematically(int max, O... _) {
2  
  optPar bool verbose;
3  
  optPar bool checkOverlongQueries = true;
4  
  
5  
  for (int n = 0; n <= max; n++) {
6  
    print("Testing length " + n);
7  
    int tests = 0;
8  
    for (S text : allABCCombinationsOfLength(n)) {
9  
      //print(+text);
10  
      SuffixTree tree = new(text);
11  
      if (l(text) <= 4) tree.printMe();
12  
      for (int j = 1; j <= n+(checkOverlongQueries ? 1 : 0); j++)
13  
        for (S query : allABCCombinationsOfLength(j)) {
14  
          ++tests;
15  
          L<Int> correct = indicesOf(text, query);
16  
          L<Int> out = sorted(tree.indicesOf(query));
17  
          if (eq(correct, out)) {
18  
            if (verbose) print("OK " + query + " in " + text + ": " + out);
19  
          } else {
20  
            fail(query + " in " + text + ": " + out + " / " + correct);
21  
          }
22  
        }
23  
    }
24  
    print(nTests(tests) + " done");
25  
  }
26  
}

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: 126 / 193
Version history: 3 change(s)
Referenced in: [show references]