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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
//! 「词项」的结构体
//! * 🚩【2024-06-12 21:11:15】新迁入作为「定义」mod
/// 作为「结构」的词项
/// * 🚩更多通过「复合」而非「抽象特征-具体实现」复用代码
/// * 📍【2024-04-20 21:13:20】目前只需实现OpenNARS 1.5.8的东西
///
/// ! ⚠️【2024-04-20 21:47:08】暂不实现「变量 < 原子 < 复合」的逻辑
/// * 🎯OpenNARS中有关「词项顺序」的概念,目的是保证「无序不重复集合」的唯一性
/// * 🚩然而此实现的需求用「派生[`Ord`]」虽然造成逻辑不同,但可以满足需求
/// * 📌核心逻辑:实现需求就行,没必要(也很难)全盘照搬
/// * ⚠️[`Hash`]特征不能在手动实现的[`PartialEq`]中实现,否则会破坏「散列一致性」
///
/// * 📝OpenNARS在「记忆区构造词项」时,就会进行各种预处理
/// * 📄`<(-, {A, B}, {A}) --> x>` 会产生 `<{B} --> x>`(外延「差」规则)
/// * 📝OpenNARS中的词项基本只能通过`make`系列方法(从外部)构造
/// * 💭这似乎意味着它是一种「记忆区专用」的封闭数据类型
///
/// * 📌【2024-06-16 11:42:25】目前应手动实现[`Ord`]
/// * ⚠️在「重排唯一化」的需求场景下需要「变量之间均相等」
/// * 🚩目前要对「重排唯一化」做单独实现:[`Ord`]需要与[`PartialEq`]对齐
/// * 💭大多情况下不会用到「比大小」逻辑,场景如「排序」
/// * ⚠️不能破坏「比对为等」和「直接判等」的一致性:原先不比对`is_constant`字段,就已经破坏了这点
///
/// # 📄OpenNARS
///
/// Term is the basic component of Narsese, and the object of processing in NARS.
/// A Term may have an associated Concept containing relations with other Terms.
/// It is not linked in the Term, because a Concept may be forgot while the Term exists. Multiple objects may represent the same Term.
///
/// ## 作为特征的「实现」
///
/// ### Cloneable => [`Clone`]
///
/// Make a new Term with the same name.
///
/// ### equals => [`Eq`]
///
/// Equal terms have identical name, though not necessarily the same reference.
///
/// ### hashCode => [`Hash`]
///
/// Produce a hash code for the term
///
/// ### compareTo => [`Ord`]
///
/// Orders among terms: variable < atomic < compound
///
/// ### toString => [`Display`]
///
/// The same as getName by default, used in display only.
///
/// @return The name of the term as a String
/// 复合词项组分
/// * ⚠️
/// 单元测试
/// * 🎯对结构体本身进行测试(仅结构字段、枚举变种)
/// * 🎯提供通用的测试用函数
pub
/// 快捷构造[`Option<Term>`](Option)
/// 用于封装作为`result`的方法
/// * 🚩在解析失败时,打印错误信息并返回`None`
/// * 📌一般这时会有「预期比对」能触发失败
/// 快捷格式化[`Option<Term>`](Option)
}