-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
84 lines (64 loc) · 1.96 KB
/
Copy pathtest.cpp
File metadata and controls
84 lines (64 loc) · 1.96 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "heuristics.h"
#include "../isr/isr.h"
#include "../index/index.h"
#include "../isr/isrHandler.h"
#include <cstddef>
int main() {
// read index chunk
IndexReadHandler readHandler = IndexReadHandler();
readHandler.ReadIndex("../log/chunks/new");
// initialize ISRHandler
ISRHandler isrHandler;
isrHandler.SetIndexReadHandler(&readHandler);
char word1[] = "wiki";
ISRWord *isrWord1 = isrHandler.OpenISRWord(word1);
if (isrWord1 == nullptr) {
std::cout << "no word1\n";
isrHandler.CloseISR(isrWord1);
return 0;
}
// char word2[] = "rain";
// ISRWord *isrWord2 = isrHandler.OpenISRWord(word2);
// if (isrWord2 == nullptr) {
// std::cout << "no word2\n";
// isrHandler.CloseISR(isrWord2);
// return 0;
// }
// char word3[] = "hot";
// ISRWord *isrWord3 = isrHandler.OpenISRWord(word3);
// if (isrWord3 == nullptr) {
// std::cout << "no word3\n";
// isrHandler.CloseISR(isrWord3);
// return 0;
// }
// ISR **terms = new ISR*[3];
// terms[0] = isrWord1;
// terms[1] = isrWord2;
// terms[2] = isrWord3;
// ISRAnd *isrAnd = isrHandler.OpenISRAnd(terms, 3);
// if ( isrAnd == nullptr ) {
// isrHandler.CloseISR(isrAnd);
// return 0;
// }
int i = 0;
size_t target = 0;
while (isrWord1->Seek(target) != nullptr)
{
std::cout << "matching doc: " << isrWord1 ->GetMatchingDoc() << std::endl;
if (i == 10)
break;
i++;
target = isrWord1->EndDoc->GetStartLocation() + 1;
std::cout << "target: " << target << "\n";
Ranker ranker((ISRWord **) &isrWord1, isrWord1->EndDoc, 1);
std::cout << "1\n";
ReaderWriterLock writerLock;
ranker.rankingScore(writerLock);
std::cout << readHandler.getDocument(isrWord1 ->GetMatchingDoc())->c_str() << std::endl;
}
// Close
isrHandler.CloseISR(isrWord1);
// ISRWord **words;
// ISREndDoc *endDoc;
// int numWords = 2;
}