forked from HIT-SCIR/ltp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyTree.h
74 lines (62 loc) · 2 KB
/
MyTree.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
65
66
67
68
69
70
71
72
73
/*
* File Name : MyTree.h
* Author : Frumes, hjliu
*
* Create Time : 2006Äê12ÔÂ31ÈÕ
* Project Name £ºNewSRLBaseLine
*
*/
#ifndef _MY_TREE_
#define _MY_TREE_
#pragma warning(disable:4786)
#include <stdlib.h>
#include "MyStruct.h"
#include "ConstVar.h"
class MyTree
{
public:
MyTree(const LTPData* ltpData);
~MyTree();
int GetRootID() const;
void GetNodeValue(DepNode& depNode, int nodeID) const;
int GetLeftChild(int nodeID) const;
int GetRightChild(int nodeID) const;
int GetLeftSib(int nodeID) const;
int GetRightSib(int nodeID) const;
void GetAllSibs(int nodeID, deque<int>& dequeSibs) const;
void GetAllNodePath(int intCurPdID, vector<string>& vecPath) const;
void GetFamilyShip(string& strFSship, int nodeID1, int nodeID2) const;
int GetRCParent(int nodeID1, int nodeID2) const;
bool IsRoot(int nodeID) const;
bool IsLeaf(int nodeID) const;
private:
// build and destroy the the tree
bool BuildDepTree(const LTPData* ltpData);
void InitTree(const LTPData* ltpData);
bool UpdateTree();
void ClearTree();
// the family members relationship
bool IsParent(int parentID, int childID) const;
bool IsChild(int childID, int parentID) const;
bool IsSibling(int nodeID1, int nodeID2) const;
bool IsAncestor(int anceID, int postID) const;
bool IsPosterity(int postID, int anceID) const;
// other operation
void GetNodeValue(
DepNode& depNode,
const DepTree& depTree,
int nodeID) const;
bool IsLeaf(
const DepTree& depTree,
int rootID) const;
void UpdateNodePS(
DepTree& depTree,
int nodeID,
int childNodeID);
void CopyAllNodePS(const DepTree& depTree);
public:
DepTree m_depTree;
private:
int m_rootID;
};
#endif