-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cc
More file actions
97 lines (72 loc) · 1.88 KB
/
node.cc
File metadata and controls
97 lines (72 loc) · 1.88 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "node.h"
AlignedNode::AlignedNode() :
tag(-1), word(-1), word_index(-1), start(-1), end(-1), split_node(false) {}
bool AlignedNode::IsSetTag() const {
return tag != -1;
}
int AlignedNode::GetTag() const {
return tag;
}
void AlignedNode::SetTag(int value) {
tag = value;
}
bool AlignedNode::IsSetWord() const {
return word != -1;
}
int AlignedNode::GetWord() const {
return word;
}
void AlignedNode::SetWord(int value) {
word = value;
}
void AlignedNode::UnsetWord() {
word = word_index = -1;
}
int AlignedNode::GetWordIndex() const {
return word_index;
}
void AlignedNode::SetWordIndex(int value) {
word_index = value;
}
bool AlignedNode::IsSplitNode() const {
return split_node;
}
void AlignedNode::SetSplitNode(bool value) {
split_node = value;
}
pair<int, int> AlignedNode::GetSpan() const {
return make_pair(start, end);
}
void AlignedNode::SetSpan(const pair<int, int>& span) {
start = span.first;
end = span.second;
}
bool AlignedNode::operator<(const AlignedNode& node) const {
return tag < node.tag || (tag == node.tag && word < node.word);
}
bool AlignedNode::operator!=(const AlignedNode& node) const {
return tag != node.tag || word != node.word;
}
StringNode::StringNode(int word, int word_index, int var_index) :
word(word), word_index(word_index), var_index(var_index) {}
bool StringNode::IsSetWord() const {
return word != -1;
}
int StringNode::GetWord() const {
return word;
}
int StringNode::GetWordIndex() const {
return word_index;
}
void StringNode::SetWordIndex(int value) {
word_index = value;
}
int StringNode::GetVarIndex() const {
return var_index;
}
bool StringNode::operator<(const StringNode& node) const {
return word < node.word || (word == node.word && var_index < node.var_index);
}
bool StringNode::operator==(const StringNode& node) const {
return word == node.word && var_index == node.var_index;
}