-
Notifications
You must be signed in to change notification settings - Fork 2
/
documentwriter.h
49 lines (47 loc) · 1.35 KB
/
documentwriter.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
44
45
46
47
48
49
#ifndef DOCUMENTWRITER_H
#define DOCUMENTWRITER_H
#include <QMap>
#include <QVector>
#include <QString>
#include "fieldinfos.h"
#include "term.h"
class Directory;
class Analyzer;
class IndexWriter;
class Document;
class Posting;
class Similarity;
class DocumentWriter
{
public:
DocumentWriter();
~DocumentWriter();
DocumentWriter(Directory* directory, Analyzer* analyzer, IndexWriter* writer);
void addDocument(QString segment, Document* doc);
void invertDocument(Document* doc);
void clearPostingTable();
int getNumFields() {return this->fieldInfos->size();}
static QVector<QString>* STOPWORDS;
private:
Directory* directory;
Analyzer* analyzer;
Similarity* similarity;
int maxFieldLength;
IndexWriter* writer;
int termIndexInterval;
FieldInfos* fieldInfos;
QMap<Term*,Posting*> postingTable;
//QVector openTokenStreams;
Term* termBuffer; // avoid consing
int* fieldLengths;
int* fieldPositions;
int* fieldOffsets;
float* fieldBoosts;
//
void addPosition(QString field, QString text, int position);
Posting** sortPostingTable();
static void quickSort(Posting** postings, int lo, int hi);
void writePostings(Posting** postings, QString segment);
void writeNorms(QString segment);
};
#endif // DOCUMENTWRITER_H