-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathcorpus.h
More file actions
executable file
·57 lines (49 loc) · 961 Bytes
/
corpus.h
File metadata and controls
executable file
·57 lines (49 loc) · 961 Bytes
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
// class for lda-c format
//
#ifndef CORPUS_H
#define CORPUS_H
#include <vector>
#include <stddef.h>
using namespace std;
class c_document {
public:
/* for document itself */
int * m_words;
int * m_counts;
int m_length;
int m_total;
public:
c_document() {
m_words = NULL;
m_counts = NULL;
m_length = 0;
m_total = 0;
}
c_document(int len) {
m_length = len;
m_words = new int [len];
m_counts = new int [len];
m_total = 0;
}
~c_document() {
if (m_words != NULL) {
delete [] m_words;
delete [] m_counts;
m_length = 0;
m_total = 0;
}
}
};
class c_corpus {
public:
c_corpus();
~c_corpus();
void read_data(const char * data_filename, int OFFSET=0);
int max_corpus_length() const;
public:
int m_num_docs;
int m_size_vocab;
int m_num_total_words;
vector<c_document*> m_docs;
};
#endif // CORPUS_H