-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindexer.h
43 lines (39 loc) · 1.17 KB
/
indexer.h
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
#ifndef INDEXER_H
#define INDEXER_H
#include "inode.h"
#include <unordered_set>
#include <set>
#include <stack>
#include <vector>
class Indexer
{
public:
Indexer();
~Indexer();
enum Status {SYNTAX_ERROR, STOPWORD_WARNING, SUCCESS};
// Functional methods
void insertKey(const string & keyword, Document &docname);
static INode * insertKey(INode * node, const string & keyword, Document &docname);
static INode * reBalance(INode * node);
void setQuery(string &query);
void execute();
bool addDocument(const string &docname);
static bool isGarbage(char c);
bool filter(string &keyword, bool isQuery);
void indexStopWords(const string &wordfile);
static vector<Document> match(INode * node, string regex);
static vector<Document> match(INode * node, vector<string> q_regex);
// Access methods
INode * at(const string & keyword);
vector<Document> result();
vector<Document> operator[](const string &keyword);
INode * indexer();
Status status();
protected:
INode * indexer_;
unordered_set<string> stopwords_;
vector<string> query_;
vector<Document> result_;
Status status_;
};
#endif // INDEXER_H