-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestQueryCompiler.cpp
More file actions
41 lines (35 loc) · 1.25 KB
/
Copy pathtestQueryCompiler.cpp
File metadata and controls
41 lines (35 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "compiler.h"
#include <iostream>
#include <cf/searchstring.h>
#include "../isr/isrHandler.h"
int main() {
// Set the query string directly for testing
string query = "\"wikipedia buddhism\"";
// string test = "wiki";
// Construct QueryParser with the custom string class
QueryParser parser(query, 'b');
string path = "../log/chunks/31";
// Parse the query into an ISR object (using OrC as the top-level entry)
parser.SetIndexReadHandler(path);
ISR* isr = parser.compile();
const vector<ISRWord*>& flattenedWords = parser.getFlattenedWords();
const vector<ISRWord*>& flattenedTitles = parser.getFlattenedTitles();
// for (const auto& word : flattenedWords) {
// std::cout << "Flattened word: " << word << std::endl;
// }
if (isr == nullptr)
return 0;
// Seek through results and output matching documents
int i = 0;
size_t target = 0;
while (isr->Seek(target) != nullptr) {
std::cout << "matching doc: " << isr->GetMatchingDoc() << std::endl;
if (i == 10) // Limit output to 10 results
break;
i++;
target = isr->EndDoc->GetStartLocation() + 1;
std::cout << "target: " << target << "\n";
}
delete isr;
return 0;
}