-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree.h
45 lines (36 loc) · 1.2 KB
/
tree.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
#ifndef TREE_H
#define TREE_H
#include <string>
#include <vector>
#include <set>
#include <map>
class Tree {
public:
std::string mLabel;
bool mIsLeaf;
int mGoldClass;
int mPredictedClass;
float* mPredictedClassDist_d;
int mWordId;
float* mNodeVector_d; // this is stored in device memory
Tree* mLeftChild;
Tree* mRightChild;
Tree() {
mLeftChild = NULL;
mRightChild = NULL;
mPredictedClassDist_d = NULL;
mNodeVector_d = NULL;
mWordId = -1;
}
Tree(const std::string& treeStr);
void getLeafWords(std::set<std::string>& words);
void assignNodeVectorsAndId(const std::map<std::string, int>& wordToIds, int unseenWordId,
unsigned int wordDim, unsigned int numClasses);
void cleanUp();
static void readTrees(std::vector<Tree*>& trees, const std::string& path);
static void getAllLeafWords(std::vector<Tree*>& trees, std::set<std::string>& words);
static void assignAllNodeVectorsAndId(std::vector<Tree*>& trees, const std::map<std::string, int>& wordToIds,
int unseenWordId, unsigned int wordDim, unsigned int numClasses);
static void cleanupTrees(std::vector<Tree*>& trees);
};
#endif // TREE_H