-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSynTreePT.h
More file actions
executable file
·51 lines (41 loc) · 1.2 KB
/
SynTreePT.h
File metadata and controls
executable file
·51 lines (41 loc) · 1.2 KB
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
#ifndef SYNTREEPT_H_INCLUDED
#define SYNTREEPT_H_INCLUDED
#include "Common.h"
using namespace std;
struct TreeNode
{
string value;
TreeNode *parent;
TreeNode *rightSibling;
TreeNode *leftSibling;
int id;
int level;
int Begin;
int Back;
vector<TreeNode*> children;
TreeNode(const string&s, TreeNode* m_parent):value(s),parent(m_parent),id(0),rightSibling(NULL),leftSibling(NULL),level(0){};
};
class SynTree
{
public:
TreeNode root;
SynTree(const string&ori_s):root("",NULL){
root.Begin=0;
stringstream ss(ori_s);
copy(istream_iterator<string,char>(ss),istream_iterator<string,char>(),back_insert_iterator<vector<string> >(sentenceVec));
ss.str("");
}
int ParseTree(const string& s, int mode=-1);
int ClearTree();
string GetSpanWithNode(TreeNode* node);
void PrintTree(TreeNode *node);
TreeNode* GetNodeWithId(int id);
int GetSpanStartWithNode(TreeNode *node);
int GetSpanEndWithNode(TreeNode *node);
void GetStrVec(int begin, int back,vector<string>&result);
int GetSize(){return nodeIdMap.size();}
vector<string> sentenceVec;
map<int, TreeNode*> nodeIdMap;
private:
};
#endif // SYNTREEPT_H_INCLUDED