activefacts-cql 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +19 -0
- data/Rakefile +6 -0
- data/activefacts-cql.gemspec +29 -0
- data/bin/setup +7 -0
- data/lib/activefacts/cql.rb +7 -0
- data/lib/activefacts/cql/.gitignore +0 -0
- data/lib/activefacts/cql/Rakefile +14 -0
- data/lib/activefacts/cql/compiler.rb +156 -0
- data/lib/activefacts/cql/compiler/clause.rb +1137 -0
- data/lib/activefacts/cql/compiler/constraint.rb +581 -0
- data/lib/activefacts/cql/compiler/entity_type.rb +457 -0
- data/lib/activefacts/cql/compiler/expression.rb +443 -0
- data/lib/activefacts/cql/compiler/fact.rb +390 -0
- data/lib/activefacts/cql/compiler/fact_type.rb +421 -0
- data/lib/activefacts/cql/compiler/query.rb +106 -0
- data/lib/activefacts/cql/compiler/shared.rb +161 -0
- data/lib/activefacts/cql/compiler/value_type.rb +174 -0
- data/lib/activefacts/cql/parser.rb +234 -0
- data/lib/activefacts/cql/parser/CQLParser.treetop +167 -0
- data/lib/activefacts/cql/parser/Context.treetop +48 -0
- data/lib/activefacts/cql/parser/Expressions.treetop +67 -0
- data/lib/activefacts/cql/parser/FactTypes.treetop +358 -0
- data/lib/activefacts/cql/parser/Language/English.treetop +315 -0
- data/lib/activefacts/cql/parser/Language/French.treetop +315 -0
- data/lib/activefacts/cql/parser/Language/Mandarin.treetop +304 -0
- data/lib/activefacts/cql/parser/LexicalRules.treetop +253 -0
- data/lib/activefacts/cql/parser/ObjectTypes.treetop +210 -0
- data/lib/activefacts/cql/parser/Terms.treetop +183 -0
- data/lib/activefacts/cql/parser/ValueTypes.treetop +202 -0
- data/lib/activefacts/cql/parser/nodes.rb +49 -0
- data/lib/activefacts/cql/require.rb +36 -0
- data/lib/activefacts/cql/verbaliser.rb +804 -0
- data/lib/activefacts/cql/version.rb +5 -0
- data/lib/activefacts/input/cql.rb +43 -0
- data/lib/rubygems_plugin.rb +12 -0
- metadata +167 -0
@@ -0,0 +1,315 @@
|
|
1
|
+
#
|
2
|
+
# ActiveFacts CQL Parser.
|
3
|
+
# Parse rules the English syntax of CQL.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
|
6
|
+
#
|
7
|
+
module ActiveFacts
|
8
|
+
module CQL
|
9
|
+
grammar English
|
10
|
+
|
11
|
+
# >>>>>>>>>>>>>>>>>>>> Object Types <<<<<<<<<<<<<<<<<<<<
|
12
|
+
# The pattern to introduce a Value Type
|
13
|
+
rule written_as
|
14
|
+
s 'is' s 'written' S as s
|
15
|
+
end
|
16
|
+
|
17
|
+
rule auto_assignment
|
18
|
+
'auto-assigned' S at s time:('assert' / 'commit') !alphanumeric s
|
19
|
+
{
|
20
|
+
def auto_assigned_at
|
21
|
+
time.text_value
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# The pattern to introduce an Entity Type
|
27
|
+
rule identified_by
|
28
|
+
identified s by s
|
29
|
+
end
|
30
|
+
|
31
|
+
rule basetype_expression
|
32
|
+
is s i:( independent s )? identification
|
33
|
+
end
|
34
|
+
|
35
|
+
# The pattern to introduce an Entity Subtype
|
36
|
+
rule subtype_prefix
|
37
|
+
'is' s 'a' s ('kind'/'subtype') s 'of' S
|
38
|
+
end
|
39
|
+
|
40
|
+
rule subtype_expression
|
41
|
+
subtype_prefix i:( independent s )? supertype_list ident:identification?
|
42
|
+
end
|
43
|
+
|
44
|
+
# The pattern to introduce an objectified fact type with implicit identification
|
45
|
+
rule is_where
|
46
|
+
is s i:(independent s)? where
|
47
|
+
{ def independent; !i.empty?; end }
|
48
|
+
end
|
49
|
+
|
50
|
+
rule in_which # Introduce an objectification step
|
51
|
+
where / # Old syntax
|
52
|
+
in s which # preferred syntax
|
53
|
+
end
|
54
|
+
|
55
|
+
# Units conversion keyword
|
56
|
+
rule conversion
|
57
|
+
converts s a:(approximately s)? to s
|
58
|
+
{
|
59
|
+
def approximate?
|
60
|
+
!a.empty?
|
61
|
+
end
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# >>>>>>>>>>>>>>>>>>>> Constraints <<<<<<<<<<<<<<<<<<<<
|
66
|
+
# External presence constraint syntax:
|
67
|
+
rule each_occurs_in_clauses
|
68
|
+
s 'each' s ('combination' S)? role_list s occurs s quantifier s 'time' 's'? s enforcement 'in' s
|
69
|
+
clauses_list s c:context_note? ';'
|
70
|
+
{
|
71
|
+
def role_list_ast
|
72
|
+
role_list.ast
|
73
|
+
end
|
74
|
+
def quantifier_ast
|
75
|
+
quantifier.ast
|
76
|
+
end
|
77
|
+
def clauses_ast
|
78
|
+
clauses_list.ast
|
79
|
+
end
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
# Alternate external presence constraint syntax:
|
84
|
+
rule either_or
|
85
|
+
s either? s r1:clauses s or s r2:clauses c:context_note? enforcement ';'
|
86
|
+
{
|
87
|
+
def role_list_ast
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
def quantifier_ast
|
91
|
+
Compiler::Quantifier.new(1, nil)
|
92
|
+
end
|
93
|
+
def clauses_ast
|
94
|
+
[r1.ast, r2.ast]
|
95
|
+
end
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
# Exclusion (at most one) and mandatory exclusion (exactly one) constraint syntax:
|
100
|
+
rule for_each_how_many
|
101
|
+
s 'for' s 'each' s role_list s quantifier s 'of' s 'these' s 'holds' s enforcement ':' s
|
102
|
+
clauses_list s c:context_note? ';'
|
103
|
+
{
|
104
|
+
def role_list_ast
|
105
|
+
role_list.ast
|
106
|
+
end
|
107
|
+
def quantifier_ast
|
108
|
+
quantifier.ast
|
109
|
+
end
|
110
|
+
def clauses_ast
|
111
|
+
clauses_list.ast
|
112
|
+
end
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
# Alternate mandatory exclusion constraint syntax:
|
117
|
+
rule either_or_not_both
|
118
|
+
s either? s r1:clauses s or s r2:clauses but s not s both s c:context_note? enforcement ';'
|
119
|
+
{
|
120
|
+
def role_list_ast
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
def quantifier_ast
|
124
|
+
Compiler::Quantifier.new(1, 1)
|
125
|
+
end
|
126
|
+
def clauses_ast
|
127
|
+
[r1.ast, r2.ast]
|
128
|
+
end
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
132
|
+
# Subset constraint using "A only if B" syntax
|
133
|
+
rule a_only_if_b
|
134
|
+
s clauses:query_clauses s only s if s r2:query_clauses s c:context_note? enforcement ';'
|
135
|
+
end
|
136
|
+
|
137
|
+
rule only_if
|
138
|
+
only s if s
|
139
|
+
end
|
140
|
+
|
141
|
+
# Subset constraint using "if A then B" syntax
|
142
|
+
rule if_b_then_a
|
143
|
+
s if s clauses s then s r2:clauses s c:context_note? enforcement ';'
|
144
|
+
end
|
145
|
+
|
146
|
+
# Equality constraint syntax:
|
147
|
+
rule if_and_only_if
|
148
|
+
s clauses s tail:( if s and s only s if s clauses s)+
|
149
|
+
c:context_note? enforcement ';'
|
150
|
+
end
|
151
|
+
|
152
|
+
# During the prescan we need to know where terms in a role list finish.
|
153
|
+
# This rule matches any non-term expressions that may follow a role list.
|
154
|
+
rule role_list_constraint_followers
|
155
|
+
occurs s quantifier s 'time'
|
156
|
+
end
|
157
|
+
|
158
|
+
# >>>>>>>>>>>>>>>>>>>> Quantifiers <<<<<<<<<<<<<<<<<<<<
|
159
|
+
rule quantifier
|
160
|
+
(
|
161
|
+
each s { def value; [1, nil]; end }
|
162
|
+
/ some s { def value; nil; end }
|
163
|
+
# REVISIT: "Some" means that any prior occurrence of this role player is to be ignored; this is a new occurrence
|
164
|
+
# "that" on the other hand means that this role player was *previously* designated using "some".
|
165
|
+
# These distinctions are lost here
|
166
|
+
/ that s { def value; nil; end }
|
167
|
+
/ which s { def value; nil; end }
|
168
|
+
/ one s { def value; [1, 1]; end }
|
169
|
+
/ no s { def value; [0, 0]; end }
|
170
|
+
/ exactly s quantity { def value; q = quantity.value; [q, q]; end }
|
171
|
+
/ at s least s quantity most:( and s at s most s q:quantity )?
|
172
|
+
{ def value;
|
173
|
+
[ quantity.value,
|
174
|
+
most.empty? ? nil : most.q.value
|
175
|
+
]
|
176
|
+
end
|
177
|
+
}
|
178
|
+
/ at s most s quantity { def value; [ nil, quantity.value ]; end }
|
179
|
+
/ from s numeric_range s { def value; numeric_range.value; end }
|
180
|
+
# / either_all_or_none s { def value; [ -1, 1 ]; end }
|
181
|
+
)
|
182
|
+
{
|
183
|
+
def ast
|
184
|
+
v = value
|
185
|
+
Compiler::Quantifier.new(v[0], v[1])
|
186
|
+
end
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
190
|
+
# rule either_all_or_none either s all s or s ( none / no ) end
|
191
|
+
|
192
|
+
rule quantity
|
193
|
+
one s { def value; 1; end }
|
194
|
+
/ number s { def value; number.value; end }
|
195
|
+
end
|
196
|
+
|
197
|
+
# >>>>>>>>>>>>>>>>>>>> Context Notes <<<<<<<<<<<<<<<<<<<<
|
198
|
+
rule as_agreed_by
|
199
|
+
s as s 'agreed' s d:('on' S date)? by s agents
|
200
|
+
{ def value; [ d.empty? ? nil : d.date.value, agents.value ]; end }
|
201
|
+
end
|
202
|
+
|
203
|
+
rule date
|
204
|
+
s d:(!(by/')') .)+
|
205
|
+
{ def value; d.text_value.strip; end }
|
206
|
+
end
|
207
|
+
|
208
|
+
rule agents
|
209
|
+
s h:agent s t:(',' s !context_type agent s)*
|
210
|
+
{
|
211
|
+
def value; [h.text_value] + t.elements.map{|e| e.agent.text_value }; end
|
212
|
+
def node_type; :linking; end
|
213
|
+
}
|
214
|
+
end
|
215
|
+
|
216
|
+
rule agent
|
217
|
+
id (s id)*
|
218
|
+
end
|
219
|
+
|
220
|
+
rule negative_prefix
|
221
|
+
s it s is s not s the s case s that s
|
222
|
+
end
|
223
|
+
|
224
|
+
rule agg_of of end
|
225
|
+
rule agg_in in end
|
226
|
+
rule restricted_to 'restricted' s 'to' s !alphanumeric end
|
227
|
+
# any is optionally used in an identifying role_list
|
228
|
+
rule any one / a end
|
229
|
+
|
230
|
+
# >>>>>>>>>>>>>>>>>>>> Internal vocabulary <<<<<<<<<<<<<<<<<<<<
|
231
|
+
rule a ('a' !alphanumeric /'an' !alphanumeric) end
|
232
|
+
rule all 'all' !alphanumeric end
|
233
|
+
rule ascending 'ascending' !alphanumeric end
|
234
|
+
rule at 'at' !alphanumeric end
|
235
|
+
rule both 'both' !alphanumeric end
|
236
|
+
rule converts 'converts' !alphanumeric end
|
237
|
+
rule descending 'descending' !alphanumeric end
|
238
|
+
rule each 'each' !alphanumeric end
|
239
|
+
rule either 'either' !alphanumeric end
|
240
|
+
rule entity 'entity' !alphanumeric end
|
241
|
+
rule exactly 'exactly' !alphanumeric end
|
242
|
+
rule from 'from' !alphanumeric end
|
243
|
+
rule includes 'includes' !alphanumeric end
|
244
|
+
rule least 'least' !alphanumeric end
|
245
|
+
rule matches 'matches' !alphanumeric end
|
246
|
+
rule most 'most' !alphanumeric end
|
247
|
+
rule no 'no' !alphanumeric end
|
248
|
+
rule none 'none' !alphanumeric end
|
249
|
+
rule not 'not' !alphanumeric end
|
250
|
+
rule occurs 'occurs' !alphanumeric end
|
251
|
+
rule one 'one' !alphanumeric end
|
252
|
+
rule some 'some' !alphanumeric end
|
253
|
+
|
254
|
+
# >>>>>>>>>>>>>>>>>>>> External vocabulary <<<<<<<<<<<<<<<<<<<<
|
255
|
+
rule according_to 'according' S to end
|
256
|
+
rule acyclic 'acyclic' !alphanumeric end
|
257
|
+
rule alias 'alias' !alphanumeric end
|
258
|
+
rule and 'and' !alphanumeric end
|
259
|
+
rule antisymmetric 'antisymmetric' !alphanumeric end
|
260
|
+
rule approximately 'approximately' !alphanumeric end
|
261
|
+
rule as 'as' !alphanumeric end
|
262
|
+
rule as_opposed_to as s 'opposed' S to end
|
263
|
+
rule asymmetric 'asymmetric' !alphanumeric end
|
264
|
+
rule because 'because' !alphanumeric end
|
265
|
+
rule but 'but' !alphanumeric end
|
266
|
+
rule by 'by' !alphanumeric end # fix? Used in 'returning' for ordering
|
267
|
+
rule case 'case' !alphanumeric end
|
268
|
+
rule definitely 'definitely' !alphanumeric end
|
269
|
+
rule ephemera 'ephemera' !alphanumeric end
|
270
|
+
rule false 'false' !alphanumeric end
|
271
|
+
rule feminine 'feminine' !alphanumeric end
|
272
|
+
rule identified ('known'/'identified') !alphanumeric end
|
273
|
+
rule if 'if' !alphanumeric end
|
274
|
+
rule in 'in' !alphanumeric end
|
275
|
+
rule import 'import' !alphanumeric end
|
276
|
+
rule independent 'independent' !alphanumeric end
|
277
|
+
rule stronglyintransitive 'strongly' s 'intransitive' !alphanumeric end
|
278
|
+
rule intransitive 'intransitive' !alphanumeric end
|
279
|
+
rule irreflexive 'irreflexive' !alphanumeric end
|
280
|
+
rule is 'is' !alphanumeric end
|
281
|
+
rule it 'it' !alphanumeric end
|
282
|
+
rule its 'its' !alphanumeric end
|
283
|
+
rule masculine 'masculine' !alphanumeric end
|
284
|
+
rule maybe 'maybe' !alphanumeric end
|
285
|
+
rule only 'only' !alphanumeric end
|
286
|
+
rule or 'or' !alphanumeric end
|
287
|
+
rule of 'of' !alphanumeric end
|
288
|
+
rule ordering_prefix by s (ascending/descending)? s end
|
289
|
+
rule otherwise 'otherwise' !alphanumeric end
|
290
|
+
rule partitioned 'partitioned' !alphanumeric end
|
291
|
+
rule personal 'personal' !alphanumeric end
|
292
|
+
rule radix_point '.' end
|
293
|
+
rule reflexive 'reflexive' !alphanumeric end
|
294
|
+
rule returning 'returning' !alphanumeric end
|
295
|
+
rule separate 'separate' !alphanumeric end
|
296
|
+
rule so_that 'so' S that end
|
297
|
+
rule static 'static' !alphanumeric end
|
298
|
+
rule symmetric 'symmetric' !alphanumeric end
|
299
|
+
rule that 'that' !alphanumeric end
|
300
|
+
rule the 'the' !alphanumeric end
|
301
|
+
rule then 'then' !alphanumeric end
|
302
|
+
rule to 'to' !alphanumeric end
|
303
|
+
rule to_avoid to s 'avoid' !alphanumeric end
|
304
|
+
rule transient 'transient' !alphanumeric end
|
305
|
+
rule transitive 'transitive' !alphanumeric end
|
306
|
+
rule true 'true' !alphanumeric end
|
307
|
+
rule vocabulary 'vocabulary' !alphanumeric end
|
308
|
+
rule where 'where' !alphanumeric end
|
309
|
+
rule which 'which' !alphanumeric end
|
310
|
+
rule was 'was' !alphanumeric end
|
311
|
+
rule who 'who' !alphanumeric end
|
312
|
+
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
@@ -0,0 +1,315 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# ActiveFacts CQL Parser.
|
4
|
+
# Parse rules the French syntax elements for CQL.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
|
7
|
+
#
|
8
|
+
module ActiveFacts
|
9
|
+
module CQL
|
10
|
+
grammar French
|
11
|
+
|
12
|
+
# >>>>>>>>>>>>>>>>>>>> Object Types <<<<<<<<<<<<<<<<<<<<
|
13
|
+
# The pattern to introduce a Value Type
|
14
|
+
rule written_as
|
15
|
+
s est s 'écrit' S 'en' s
|
16
|
+
end
|
17
|
+
|
18
|
+
rule auto_assignment
|
19
|
+
'auto-assigné' S to time:('assertion' / 'validation') !alphanumeric s
|
20
|
+
{
|
21
|
+
def auto_assigned_at
|
22
|
+
time.text_value == 'assertion' ? 'assert' : 'commit'
|
23
|
+
end
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# The pattern to introduce an Entity Type
|
28
|
+
rule identified_by
|
29
|
+
'identifié' s 'par' s
|
30
|
+
end
|
31
|
+
|
32
|
+
rule basetype_expression
|
33
|
+
is s i:( independent s )? identification
|
34
|
+
end
|
35
|
+
|
36
|
+
# The pattern to introduce an Entity Subtype
|
37
|
+
rule subtype_prefix
|
38
|
+
est s un s ('type'/'genre') s 'de' S
|
39
|
+
end
|
40
|
+
|
41
|
+
rule subtype_expression
|
42
|
+
subtype_prefix i:( independent s )? supertype_list ident:identification?
|
43
|
+
end
|
44
|
+
|
45
|
+
# The pattern to introduce an objectified fact type with implicit identification
|
46
|
+
rule is_where
|
47
|
+
existe s i:(independent s)? si
|
48
|
+
{ def independent; !i.empty?; end }
|
49
|
+
end
|
50
|
+
|
51
|
+
rule in_which # Introduce an objectification step
|
52
|
+
where / # Old syntax
|
53
|
+
dans s laquel # preferred syntax
|
54
|
+
end
|
55
|
+
|
56
|
+
# Units conversion keyword
|
57
|
+
rule conversion
|
58
|
+
converts s a:(approximately s)? to s
|
59
|
+
{
|
60
|
+
def approximate?
|
61
|
+
!a.empty?
|
62
|
+
end
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
# >>>>>>>>>>>>>>>>>>>> Constraints <<<<<<<<<<<<<<<<<<<<
|
67
|
+
# External presence constraint syntax:
|
68
|
+
rule each_occurs_in_clauses
|
69
|
+
s chaque s ('combinaison' S)? role_list s existe s quantifier 'fois' S
|
70
|
+
'parmis' S ce S 'qui' S 'suit' s ':' s
|
71
|
+
clauses_list s c:context_note? ';'
|
72
|
+
{
|
73
|
+
def role_list_ast
|
74
|
+
role_list.ast
|
75
|
+
end
|
76
|
+
def quantifier_ast
|
77
|
+
quantifier.ast
|
78
|
+
end
|
79
|
+
def clauses_ast
|
80
|
+
clauses_list.ast
|
81
|
+
end
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
rule either_or
|
86
|
+
s soit s r1:clauses s 'ou' S r2:clauses
|
87
|
+
s c:context_note? enforcement ';'
|
88
|
+
{
|
89
|
+
def role_list_ast
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
def quantifier_ast
|
93
|
+
Compiler::Quantifier.new(1, nil)
|
94
|
+
end
|
95
|
+
def clauses_ast
|
96
|
+
[r1.ast, r2.ast]
|
97
|
+
end
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
# Used for exclusion (at most one) and mandatory exclusion (exactly one)
|
102
|
+
rule for_each_how_many
|
103
|
+
'pour' S 'chaque' S role_list s
|
104
|
+
quantifier s 'des' S 'suivants' S 's\'applique' s ':' s
|
105
|
+
clauses_list s c:context_note? ';'
|
106
|
+
{
|
107
|
+
def role_list_ast
|
108
|
+
role_list.ast
|
109
|
+
end
|
110
|
+
def quantifier_ast
|
111
|
+
quantifier.ast
|
112
|
+
end
|
113
|
+
def clauses_ast
|
114
|
+
clauses_list.ast
|
115
|
+
end
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
rule either_or_not_both
|
120
|
+
s soit s r1:clauses s 'ou' S r2:clauses 'mais' S 'pas' S 'les' S 'deux'
|
121
|
+
s c:context_note? enforcement ';'
|
122
|
+
{
|
123
|
+
def role_list_ast
|
124
|
+
nil
|
125
|
+
end
|
126
|
+
def quantifier_ast
|
127
|
+
Compiler::Quantifier.new(1, 1)
|
128
|
+
end
|
129
|
+
def clauses_ast
|
130
|
+
[r1.ast, r2.ast]
|
131
|
+
end
|
132
|
+
}
|
133
|
+
end
|
134
|
+
|
135
|
+
rule a_only_if_b
|
136
|
+
s clauses s only_if r2:clauses s c:context_note? enforcement ';'
|
137
|
+
end
|
138
|
+
|
139
|
+
rule only_if
|
140
|
+
que s si s
|
141
|
+
end
|
142
|
+
|
143
|
+
rule if_b_then_a
|
144
|
+
s 'si' S clauses s 'puis' S r2:clauses s c:context_note? enforcement ';'
|
145
|
+
end
|
146
|
+
|
147
|
+
rule if_and_only_if
|
148
|
+
s clauses s tail:( 'si' S 'et' S ('seulement'/'uniquement'/'que') S 'si' S clauses s)+
|
149
|
+
c:context_note? enforcement ';'
|
150
|
+
end
|
151
|
+
|
152
|
+
# During the prescan we need to know where terms in a role list finish.
|
153
|
+
# This rule matches any non-term expressions that may follow a role list.
|
154
|
+
rule role_list_constraint_followers
|
155
|
+
existe
|
156
|
+
end
|
157
|
+
|
158
|
+
# >>>>>>>>>>>>>>>>>>>> Quantifiers <<<<<<<<<<<<<<<<<<<<
|
159
|
+
rule quantifier
|
160
|
+
(
|
161
|
+
( chaque s # "each"
|
162
|
+
{ def value; [1, nil]; end }
|
163
|
+
/ un s 'certain' 'e'? ) s # "some"
|
164
|
+
{ def value; nil; end }
|
165
|
+
/ ce s # "that"
|
166
|
+
{ def value; nil; end }
|
167
|
+
/ un s # "one"; masculine or feminine
|
168
|
+
{ def value; [1, 1]; end }
|
169
|
+
/ 'pas' s 'de' s # REVISIT: Example: "Personne n'a pas de Casier-judiciaire"
|
170
|
+
{ def value; [0, 0]; end }
|
171
|
+
/ exactement s quantity
|
172
|
+
{ def value; q = quantity.value; [q, q]; end }
|
173
|
+
/ au s moins s quantity most:( et s au s plus q:quantity )? # At least (or at most)
|
174
|
+
{ def value; [ quantity.value, most.empty? ? nil : most.q.value ]; end }
|
175
|
+
/ au s plus s quantity # At most
|
176
|
+
{ def value; [ nil, quantity.value ]; end }
|
177
|
+
/ entre s numeric_range s # within numeric_range
|
178
|
+
{ def value; numeric_range.value; end }
|
179
|
+
/ soit s tous s soit s aucun # either all or none
|
180
|
+
{ def value; [ -1, 1 ]; end }
|
181
|
+
)
|
182
|
+
{
|
183
|
+
def ast
|
184
|
+
v = value
|
185
|
+
Compiler::Quantifier.new(v[0], v[1])
|
186
|
+
end
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
190
|
+
rule quantity
|
191
|
+
un s { def value; 1; end }
|
192
|
+
/ number s { def value; number.value; end }
|
193
|
+
end
|
194
|
+
|
195
|
+
# >>>>>>>>>>>>>>>>>>>> Context Notes <<<<<<<<<<<<<<<<<<<<
|
196
|
+
rule as_agreed_by
|
197
|
+
s 'comme' S 'convenu' S d:('le' s date s)? 'par' S agents
|
198
|
+
{ def value; [ d.empty? ? nil : d.date.value, agents.value ]; end }
|
199
|
+
end
|
200
|
+
|
201
|
+
rule date
|
202
|
+
s d:(!(by/')') .)+
|
203
|
+
{ def value; d.text_value.strip; end }
|
204
|
+
end
|
205
|
+
|
206
|
+
rule agents
|
207
|
+
s h:agent s t:(',' s !context_type agent s)*
|
208
|
+
{
|
209
|
+
def value; [h.text_value] + t.elements.map{|e| e.agent.text_value }; end
|
210
|
+
def node_type; :linking; end
|
211
|
+
}
|
212
|
+
end
|
213
|
+
|
214
|
+
rule agent
|
215
|
+
id (s id)*
|
216
|
+
end
|
217
|
+
|
218
|
+
rule negative_prefix
|
219
|
+
s 'ce' S "n'est" s 'pas' s 'le' s 'cas' s 'que'
|
220
|
+
end
|
221
|
+
|
222
|
+
rule agg_of de end
|
223
|
+
rule agg_in dans end
|
224
|
+
rule restricted_to 'limité' s 'à' !alphanumeric s end
|
225
|
+
rule any un !alphanumeric end
|
226
|
+
|
227
|
+
# >>>>>>>>>>>>>>>>>>>> Internal vocabulary <<<<<<<<<<<<<<<<<<<<
|
228
|
+
rule all 'tous' !alphanumeric end
|
229
|
+
rule at 'a' !alphanumeric end
|
230
|
+
rule both 'les deux' !alphanumeric end
|
231
|
+
rule ce ('cette'/'cet'/'ce') !alphanumeric end # ce is masculine, cette feminine, cet is ce before a noun
|
232
|
+
rule chaque 'chaque' !alphanumeric end
|
233
|
+
rule converts 'convertit' !alphanumeric end
|
234
|
+
rule de 'de' !alphanumeric end
|
235
|
+
rule dans 'dans' !alphanumeric end
|
236
|
+
rule laquel 'laquel' 'le'? !alphanumeric end
|
237
|
+
rule descending 'descendant' !alphanumeric end
|
238
|
+
rule each chaque end
|
239
|
+
rule either 'soit' !alphanumeric end
|
240
|
+
rule entity 'entité' !alphanumeric end
|
241
|
+
rule est 'est' !alphanumeric end
|
242
|
+
rule exactement 'exactement' !alphanumeric end
|
243
|
+
rule existe 'existe' !alphanumeric end
|
244
|
+
rule from 'à partir de' !alphanumeric end # REVISIT: google translate
|
245
|
+
rule includes 'comprend' !alphanumeric end
|
246
|
+
rule matches 'matches' !alphanumeric end
|
247
|
+
rule moins 'moins' !alphanumeric end
|
248
|
+
rule none 'aucun' !alphanumeric end
|
249
|
+
rule not 'not' !alphanumeric end # REVISIT: Used in constraints
|
250
|
+
rule plus 'plus' !alphanumeric end
|
251
|
+
rule some 'quelques' !alphanumeric end
|
252
|
+
rule un 'un' 'e'? !alphanumeric end # un is masculine, une is feminine
|
253
|
+
rule que 'que' !alphanumeric end
|
254
|
+
|
255
|
+
# >>>>>>>>>>>>>>>>>>>> External vocabulary <<<<<<<<<<<<<<<<<<<<
|
256
|
+
rule according_to 'selon' !alphanumeric end
|
257
|
+
rule acyclic 'acyclique' !alphanumeric end
|
258
|
+
rule alias 'alias' !alphanumeric end
|
259
|
+
rule and 'et' !alphanumeric end
|
260
|
+
rule antisymmetric 'antisymmetric' !alphanumeric end
|
261
|
+
rule approximately 'environ' !alphanumeric end # REVISIT: google translate
|
262
|
+
rule as 'comme' !alphanumeric end
|
263
|
+
rule as_opposed_to 'au' S 'lieu' S 'de' !alphanumeric end
|
264
|
+
rule asymmetric 'asymétrique' !alphanumeric end
|
265
|
+
rule au 'au' !alphanumeric end
|
266
|
+
rule because ('parce' s 'que' / 'car') !alphanumeric end
|
267
|
+
rule but 'mais' !alphanumeric end
|
268
|
+
rule by 'par' !alphanumeric end
|
269
|
+
rule definitely 'définitivement' !alphanumeric end
|
270
|
+
rule entre 'entre' !alphanumeric end
|
271
|
+
rule ephemera 'éphémère' !alphanumeric end
|
272
|
+
rule existe 'existe' !alphanumeric end
|
273
|
+
rule false 'faux' !alphanumeric end
|
274
|
+
rule feminine 'féminin' !alphanumeric end
|
275
|
+
rule identified ('identifié') !alphanumeric end
|
276
|
+
rule if 'si' !alphanumeric end
|
277
|
+
rule import 'import' !alphanumeric end # REVISIT: translation?
|
278
|
+
rule independent 'indépendant' !alphanumeric end
|
279
|
+
rule stronglyintransitive 'stronglyintransitif' !alphanumeric end
|
280
|
+
rule intransitive 'intransitif' !alphanumeric end
|
281
|
+
rule irreflexive 'irréflexive' !alphanumeric end
|
282
|
+
rule is est end # Called from ObjectTypes.treetop in "is identified by"
|
283
|
+
rule its ('sa' / 'son') !alphanumeric end
|
284
|
+
rule masculine 'masculin' !alphanumeric end
|
285
|
+
rule maybe 'peut-être' !alphanumeric end # REVISIT: eventuellement = possibly?
|
286
|
+
rule only 'que' !alphanumeric end # REVISIT: Used in constraints
|
287
|
+
rule or 'ou' !alphanumeric end
|
288
|
+
rule ordering_prefix by s (ascending/descending)? s end
|
289
|
+
rule otherwise 'sinon' !alphanumeric end
|
290
|
+
rule partitioned 'partitionné' !alphanumeric end
|
291
|
+
rule personal 'personelle' !alphanumeric end
|
292
|
+
rule radix_point ',' end
|
293
|
+
rule reflexive 'réflexive' !alphanumeric end
|
294
|
+
rule returning 'retour' !alphanumeric end
|
295
|
+
rule separate 'distincte' !alphanumeric end
|
296
|
+
rule si 'si' !alphanumeric end
|
297
|
+
rule so_that 'pour' s 'que' !alphanumeric end
|
298
|
+
rule soit 'soit' !alphanumeric end
|
299
|
+
rule static 'statique' !alphanumeric end
|
300
|
+
rule symmetric 'symétrique' !alphanumeric end
|
301
|
+
rule that que end
|
302
|
+
rule then 'puis' !alphanumeric end
|
303
|
+
rule to 'à' !alphanumeric end
|
304
|
+
rule to_avoid ('pour' s 'empecher' s 'de' / 'pour' s 'ne' s 'pas') !alphanumeric end
|
305
|
+
rule transient 'transitoires' !alphanumeric end
|
306
|
+
rule transitive 'transitif' !alphanumeric end
|
307
|
+
rule true 'vrai' !alphanumeric end
|
308
|
+
rule vocabulary 'vocabulaire' !alphanumeric end
|
309
|
+
rule where 'où' !alphanumeric end
|
310
|
+
rule who 'qui' !alphanumeric end
|
311
|
+
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
# vi:encoding=utf-8
|