-
Notifications
You must be signed in to change notification settings - Fork 4
/
corpus.h
64 lines (58 loc) · 1.08 KB
/
corpus.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _CORPUS_H
#define _CORPUS_H
#include <vector>
using namespace std;
class document
{
public:
int * words;
int * counts;
int length;
int total;
int id;
public:
document()
{
words = NULL;
counts = NULL;
length = 0;
total = 0;
id = -1;
}
document(int len)
{
length = len;
words = new int [length];
counts = new int [length];
total = 0;
id = -1;
}
~ document()
{
if (words != NULL)
{
delete [] words;
delete [] counts;
length = 0;
total = 0;
id = -1;
}
}
void read_data(FILE * fileptr, bool& eof, int id = 0);
int get_max_word_id() const;
void free_document();
};
class corpus
{
public:
corpus();
~corpus();
void read_data(const char * filename);
public:
int size_vocab;
int total_words;
int num_docs;
vector<document*> docs;
void free_corpus();
};
#endif /* _CORPUS_H */