Element Expression » History » Version 15
Robert Bossy, 04/11/2017 06:25 PM
1 | 15 | Robert Bossy | h1. %{color:red}This page is obsolete, please go to https://github.com/Bibliome/alvisnlp/wiki/Element-expression% |
---|---|---|---|
2 | 15 | Robert Bossy | |
3 | 15 | Robert Bossy | |
4 | 4 | Robert Bossy | h1. Element Expression |
5 | 4 | Robert Bossy | |
6 | 1 | Robert Bossy | {{toc}} |
7 | 1 | Robert Bossy | |
8 | 4 | Robert Bossy | h2. Introduction |
9 | 3 | Robert Bossy | |
10 | 8 | Robert Bossy | Element Expressions is a language for exploring and querying the AlvisNLP Corpus. It can be used to test features, count elements, retrieve annotations with certain characteristics, etc. This language shares a lot of common points with XPath, so if you are, or become, familiar with XPath, then good for you. You may find the following pages also useful: |
11 | 8 | Robert Bossy | |
12 | 8 | Robert Bossy | * [[Element Expression Examples]] contains several examples of expressions in increasing order of trickiness; |
13 | 8 | Robert Bossy | * [[Shell]] describes the AlvisNLP/ML Shell that you can use to train yourself to write expressions. |
14 | 7 | Robert Bossy | |
15 | 1 | Robert Bossy | |
16 | 4 | Robert Bossy | h2. Context Element |
17 | 1 | Robert Bossy | |
18 | 1 | Robert Bossy | Expressions are evaluated within a context that includes an element. The context element can be one of the following: |
19 | 1 | Robert Bossy | * the corpus |
20 | 1 | Robert Bossy | * a document |
21 | 1 | Robert Bossy | * a section |
22 | 1 | Robert Bossy | * an annotation |
23 | 1 | Robert Bossy | * a relation |
24 | 1 | Robert Bossy | * a tuple |
25 | 1 | Robert Bossy | |
26 | 1 | Robert Bossy | Some expressions are independent of the context element; their evaluation does not depend on it (for instance arithmetic operators). However the most useful expressions depend on the context element, for instance the evaluation of a feature value expression obviously depends on the context element. Wherever an expression is expected, for instance as a module parameter, the context element sould be documented. |
27 | 1 | Robert Bossy | |
28 | 4 | Robert Bossy | h2. Evaluation types |
29 | 1 | Robert Bossy | |
30 | 1 | Robert Bossy | An expression can be evaluated as on of four types: boolean, number, string or element list. The evaluation type should be documented along with the context element. |
31 | 1 | Robert Bossy | |
32 | 4 | Robert Bossy | h3. Scalar types |
33 | 1 | Robert Bossy | |
34 | 4 | Robert Bossy | h4. Boolean |
35 | 1 | Robert Bossy | |
36 | 1 | Robert Bossy | The boolean type has two values: @false@ and @true@. |
37 | 1 | Robert Bossy | |
38 | 9 | Robert Bossy | h4. Double |
39 | 1 | Robert Bossy | |
40 | 9 | Robert Bossy | The double type is a double precision 64-bit floating point number (Java @double@). |
41 | 1 | Robert Bossy | |
42 | 9 | Robert Bossy | h4. Integer |
43 | 9 | Robert Bossy | |
44 | 9 | Robert Bossy | The integer type is a 32-bit signed integer (Java @int@). |
45 | 9 | Robert Bossy | |
46 | 4 | Robert Bossy | h4. String |
47 | 1 | Robert Bossy | |
48 | 1 | Robert Bossy | The string type is a 16-bit unicode character sequence (Java @String@). |
49 | 1 | Robert Bossy | |
50 | 1 | Robert Bossy | h3. Element list |
51 | 1 | Robert Bossy | |
52 | 1 | Robert Bossy | The element list type is an ordered collection of elements. In most cases elements in an element list are of the same type (all Annotations or all Documents etc.). |
53 | 1 | Robert Bossy | |
54 | 4 | Robert Bossy | h3. Type coercion |
55 | 1 | Robert Bossy | |
56 | 12 | Robert Bossy | The majority of expressions have a priviledged or primary evaluation type, however they can be evaluated into any other type. The value is computed using the following type coercion rules: |
57 | 1 | Robert Bossy | |
58 | 1 | Robert Bossy | | |*boolean*|*number*|*string*|*list*| |
59 | 1 | Robert Bossy | |*boolean*||false=0, true=1|false="false", true="true"|empty list| |
60 | 1 | Robert Bossy | |*number* |0=false, otherwise true||decimal notation string|empty list| |
61 | 12 | Robert Bossy | |*string* |""=false, otherwise true|decimal conversion, 0 if string is not number||empty list| |
62 | 1 | Robert Bossy | |*list* |empty=false, otherwise true|element count|concatenation of static features|| |
63 | 1 | Robert Bossy | |
64 | 1 | Robert Bossy | Some expressions have specific coercion rules. |
65 | 1 | Robert Bossy | |
66 | 4 | Robert Bossy | h2. Operator precedence and associativity |
67 | 1 | Robert Bossy | |
68 | 1 | Robert Bossy | The following operators are listed in descending order of precedence. The precedence can be overriden with parentheses. |
69 | 1 | Robert Bossy | |
70 | 1 | Robert Bossy | |*Operators*|*Associative*| |
71 | 1 | Robert Bossy | |@if then else@|no| |
72 | 1 | Robert Bossy | |@or@|yes| |
73 | 1 | Robert Bossy | |@and@|yes| |
74 | 1 | Robert Bossy | |@not@|no| |
75 | 1 | Robert Bossy | |@== != < > <= >= ?= ^= =^ =~ in any@|no| |
76 | 1 | Robert Bossy | |@^@|yes| |
77 | 1 | Robert Bossy | |@+ -@|yes| |
78 | 1 | Robert Bossy | |@* / %@|yes| |
79 | 1 | Robert Bossy | |unary @-@|no| |
80 | 1 | Robert Bossy | |pipe|yes| |
81 | 1 | Robert Bossy | |@.@|yes| |
82 | 1 | Robert Bossy | |
83 | 4 | Robert Bossy | h2. Syntax for names |
84 | 1 | Robert Bossy | |
85 | 1 | Robert Bossy | Some expressions require a name (feature key or layer name for instance). Names are single quote character sequences. The quotes can be omitted if all the following conditions are met: |
86 | 1 | Robert Bossy | * all characters are alphabetic (@A-Za-z@) or undescore (@_@) |
87 | 1 | Robert Bossy | * the name is different from any reserved word: |
88 | 1 | Robert Bossy | |@after@| |
89 | 1 | Robert Bossy | |@and@| |
90 | 1 | Robert Bossy | |@any@| |
91 | 9 | Robert Bossy | |@arg@| |
92 | 1 | Robert Bossy | |@args@| |
93 | 1 | Robert Bossy | |@before@| |
94 | 1 | Robert Bossy | |@boolean@| |
95 | 1 | Robert Bossy | |@contents@| |
96 | 1 | Robert Bossy | |@corpus@| |
97 | 9 | Robert Bossy | |@delete@| |
98 | 1 | Robert Bossy | |@document@| |
99 | 1 | Robert Bossy | |@documents@| |
100 | 9 | Robert Bossy | |@double@| |
101 | 1 | Robert Bossy | |@elements@| |
102 | 1 | Robert Bossy | |@else@| |
103 | 1 | Robert Bossy | |@end@| |
104 | 1 | Robert Bossy | |@false@| |
105 | 10 | Robert Bossy | |@feat@| |
106 | 9 | Robert Bossy | |@fun@| |
107 | 1 | Robert Bossy | |@if@| |
108 | 1 | Robert Bossy | |@in@| |
109 | 9 | Robert Bossy | |@int@| |
110 | 1 | Robert Bossy | |@inside@| |
111 | 1 | Robert Bossy | |@layer@| |
112 | 1 | Robert Bossy | |@length@| |
113 | 1 | Robert Bossy | |@not@| |
114 | 9 | Robert Bossy | |@new@| |
115 | 1 | Robert Bossy | |@or@| |
116 | 1 | Robert Bossy | |@outside@| |
117 | 9 | Robert Bossy | |@overlapping@| |
118 | 1 | Robert Bossy | |@relation@| |
119 | 1 | Robert Bossy | |@relations@| |
120 | 1 | Robert Bossy | |@section@| |
121 | 1 | Robert Bossy | |@sections@| |
122 | 9 | Robert Bossy | |@span@| |
123 | 1 | Robert Bossy | |@start@| |
124 | 1 | Robert Bossy | |@string@| |
125 | 1 | Robert Bossy | |@then@| |
126 | 1 | Robert Bossy | |@true@| |
127 | 1 | Robert Bossy | |@tuples@| |
128 | 1 | Robert Bossy | |
129 | 2 | Robert Bossy | Note that names and keywords are case-sensitive. All keywords are all lowercase. |
130 | 1 | Robert Bossy | |
131 | 4 | Robert Bossy | h2. Expression reference |
132 | 1 | Robert Bossy | |
133 | 1 | Robert Bossy | In the following sections each available expression is described. The usage of the expression is given in preformatted paragraphs with the following conventions: |
134 | 1 | Robert Bossy | |
135 | 1 | Robert Bossy | <pre> |
136 | 12 | Robert Bossy | EXPR uppercase words are variable parts of the expression construct, they are meant to be replaced either by sub-expressions, names or constants |
137 | 2 | Robert Bossy | layer lowercase words are keywords |
138 | 2 | Robert Bossy | ( ) . + : all other sylmbols are operators, parenthes or a column, they are part of the expression syntax |
139 | 2 | Robert Bossy | </pre> |
140 | 1 | Robert Bossy | |
141 | 2 | Robert Bossy | If there is a preferred type for the expression, then this type is specified between brackets in the expression name. |
142 | 4 | Robert Bossy | |
143 | 2 | Robert Bossy | h4. Boolean constant [boolean] |
144 | 2 | Robert Bossy | |
145 | 1 | Robert Bossy | <pre> |
146 | 1 | Robert Bossy | false |
147 | 1 | Robert Bossy | true |
148 | 1 | Robert Bossy | </pre> |
149 | 1 | Robert Bossy | |
150 | 9 | Robert Bossy | h4. Integer constant [integer] |
151 | 1 | Robert Bossy | |
152 | 1 | Robert Bossy | <pre> |
153 | 1 | Robert Bossy | [0-9]+ |
154 | 1 | Robert Bossy | </pre> |
155 | 1 | Robert Bossy | |
156 | 9 | Robert Bossy | h4. Double constant [double] |
157 | 9 | Robert Bossy | |
158 | 9 | Robert Bossy | <pre> |
159 | 9 | Robert Bossy | ([0-9]*\.)?[0-9]+ |
160 | 9 | Robert Bossy | </pre> |
161 | 9 | Robert Bossy | |
162 | 4 | Robert Bossy | h4. String constants [string] |
163 | 2 | Robert Bossy | |
164 | 1 | Robert Bossy | <pre> |
165 | 2 | Robert Bossy | "..." |
166 | 2 | Robert Bossy | </pre> |
167 | 2 | Robert Bossy | |
168 | 1 | Robert Bossy | String constants are double quoted character sequences. The usual Java escape sequences apply. |
169 | 4 | Robert Bossy | |
170 | 1 | Robert Bossy | h4. Boolean operators [boolean] |
171 | 1 | Robert Bossy | |
172 | 1 | Robert Bossy | <pre> |
173 | 1 | Robert Bossy | LEFT and RIGHT |
174 | 1 | Robert Bossy | LEFT or RIGHT |
175 | 1 | Robert Bossy | not EXPR |
176 | 1 | Robert Bossy | </pre> |
177 | 1 | Robert Bossy | |
178 | 1 | Robert Bossy | @LEFT@, @RIGHT@ and @EXPR@ are evaluated as booleans with the same context element. |
179 | 4 | Robert Bossy | Binary boolean operator evaluation is short-circuited. |
180 | 1 | Robert Bossy | |
181 | 1 | Robert Bossy | h4. General comparison [boolean] |
182 | 1 | Robert Bossy | |
183 | 1 | Robert Bossy | <pre> |
184 | 1 | Robert Bossy | LEFT == RIGHT |
185 | 1 | Robert Bossy | LEFT != RIGHT |
186 | 1 | Robert Bossy | </pre> |
187 | 1 | Robert Bossy | |
188 | 1 | Robert Bossy | @LEFT@ and @RIGHT@ are evaluated as the same type with the same context element. If @LEFT@ is an expression of scalar type, then its type is used. Otherwise, the type of @RIGHT@ is used. |
189 | 4 | Robert Bossy | |
190 | 9 | Robert Bossy | h4. Number comparison [boolean] |
191 | 1 | Robert Bossy | |
192 | 1 | Robert Bossy | <pre> |
193 | 1 | Robert Bossy | LEFT < RIGHT |
194 | 1 | Robert Bossy | LEFT > RIGHT |
195 | 1 | Robert Bossy | LEFT <= RIGHT |
196 | 1 | Robert Bossy | LEFT >= RIGHT |
197 | 1 | Robert Bossy | </pre> |
198 | 1 | Robert Bossy | |
199 | 9 | Robert Bossy | @LEFT@ and @RIGHT@ are evaluated as doubles using the same context element. |
200 | 1 | Robert Bossy | |
201 | 4 | Robert Bossy | h4. String comparison [boolean] |
202 | 1 | Robert Bossy | |
203 | 1 | Robert Bossy | <pre> |
204 | 1 | Robert Bossy | LEFT ?= RIGHT |
205 | 1 | Robert Bossy | LEFT ^= RIGHT |
206 | 1 | Robert Bossy | LEFT =^ RIGHT |
207 | 1 | Robert Bossy | </pre> |
208 | 1 | Robert Bossy | |
209 | 1 | Robert Bossy | @LEFT@ and @RIGHT@ are evaluated as strings using the same context element. |
210 | 1 | Robert Bossy | Meaning of operators: |
211 | 1 | Robert Bossy | |@?=@|contains| |
212 | 1 | Robert Bossy | |@^=@|starts with| |
213 | 1 | Robert Bossy | |@=^@|ends with| |
214 | 4 | Robert Bossy | |
215 | 1 | Robert Bossy | h4. String concatenation [string] |
216 | 1 | Robert Bossy | |
217 | 1 | Robert Bossy | <pre> |
218 | 1 | Robert Bossy | LEFT ^ RIGHT |
219 | 1 | Robert Bossy | </pre> |
220 | 1 | Robert Bossy | |
221 | 1 | Robert Bossy | @LEFT@ and @RIGHT@ are evaluated as strings with the same context element. |
222 | 1 | Robert Bossy | |
223 | 1 | Robert Bossy | h4. Regexp match |
224 | 1 | Robert Bossy | |
225 | 1 | Robert Bossy | <pre> |
226 | 1 | Robert Bossy | TARGET =~ "PATTERN" |
227 | 1 | Robert Bossy | </pre> |
228 | 1 | Robert Bossy | |
229 | 1 | Robert Bossy | @TARGET@ is evaluated as a string with the same context element. @"PATTERN"@ is a string constant containing a regular expression in "Java syntax":http://download.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html |
230 | 1 | Robert Bossy | If evaluated as a boolean, then this expression returns either the target matches the pattern. |
231 | 1 | Robert Bossy | If evaluated as a number, then this expression returns the number of non-overlapping matches of the pattern in the target. |
232 | 1 | Robert Bossy | If evaluated as a string, then this expression returns the first match of the pattern in the target. |
233 | 1 | Robert Bossy | If evaluated as an element list, then this expression returns an empty list. |
234 | 4 | Robert Bossy | |
235 | 9 | Robert Bossy | h4. Arithmetic [double] |
236 | 1 | Robert Bossy | |
237 | 1 | Robert Bossy | <pre> |
238 | 1 | Robert Bossy | LEFT + RIGHT |
239 | 1 | Robert Bossy | LEFT - RIGHT |
240 | 1 | Robert Bossy | LEFT * RIGHT |
241 | 1 | Robert Bossy | LEFT / RIGHT |
242 | 1 | Robert Bossy | LEFT % RIGHT |
243 | 1 | Robert Bossy | </pre> |
244 | 1 | Robert Bossy | |
245 | 1 | Robert Bossy | @LEFT@ and @RIGHT@ are both evaluated as numbers with the same context element. |
246 | 1 | Robert Bossy | |
247 | 9 | Robert Bossy | h4. Unary minus [double] |
248 | 1 | Robert Bossy | |
249 | 1 | Robert Bossy | <pre> |
250 | 1 | Robert Bossy | - EXPR |
251 | 1 | Robert Bossy | </pre> |
252 | 1 | Robert Bossy | |
253 | 4 | Robert Bossy | @EXPR@ is evaluated as a number with the same context element. |
254 | 1 | Robert Bossy | |
255 | 1 | Robert Bossy | h4. Dictionary lookup [boolean] |
256 | 1 | Robert Bossy | |
257 | 1 | Robert Bossy | <pre> |
258 | 1 | Robert Bossy | EXPR in "FILE"[:"ENCODING"] |
259 | 1 | Robert Bossy | </pre> |
260 | 1 | Robert Bossy | |
261 | 1 | Robert Bossy | @EXPR@ is evaluated as a string with the same context element. @"FILE"@ is a string constant containg the path to a dictionary file. @"ENCODING"@ is a string constant containing the name of the dictionary file character set. If the encoding is omitted, UTF-8 is assumed. |
262 | 1 | Robert Bossy | The dictionary file must contain one entry per line. This expression returns true if and only if the dictionary contains the first operand. |
263 | 1 | Robert Bossy | |
264 | 9 | Robert Bossy | h4. Feature [string] |
265 | 1 | Robert Bossy | |
266 | 1 | Robert Bossy | <pre> |
267 | 12 | Robert Bossy | @KEY |
268 | 1 | Robert Bossy | </pre> |
269 | 1 | Robert Bossy | |
270 | 1 | Robert Bossy | @KEY@ is a name. This expression returns the last value of the feature with key @KEY@ of context element. |
271 | 1 | Robert Bossy | If this expression is evaluated as a boolean, then it returns @true@ if and only if the context element has a feature with key @KEY@, +even if the feature value is an empty string+. |
272 | 4 | Robert Bossy | |
273 | 9 | Robert Bossy | h4. Any feature value equals [boolean] |
274 | 1 | Robert Bossy | |
275 | 1 | Robert Bossy | <pre> |
276 | 12 | Robert Bossy | any KEY == EXPR |
277 | 1 | Robert Bossy | </pre> |
278 | 1 | Robert Bossy | |
279 | 1 | Robert Bossy | @KEY@ is a name. @EXPR@ is evaluated as a string with the same context element. |
280 | 1 | Robert Bossy | This expression returns true if at least one of the values of the feature with key @KEY@ in the context element equals @EXPR@. |
281 | 1 | Robert Bossy | |
282 | 1 | Robert Bossy | h4. Annotation positions [integer] |
283 | 9 | Robert Bossy | |
284 | 1 | Robert Bossy | <pre> |
285 | 1 | Robert Bossy | start |
286 | 1 | Robert Bossy | end |
287 | 1 | Robert Bossy | </pre> |
288 | 1 | Robert Bossy | |
289 | 12 | Robert Bossy | These expressions return respectively the start and end positions if the context element is an annotation. Otherwise it returns @0@. |
290 | 1 | Robert Bossy | |
291 | 9 | Robert Bossy | h4. Element length [integer] |
292 | 1 | Robert Bossy | |
293 | 1 | Robert Bossy | <pre> |
294 | 1 | Robert Bossy | length |
295 | 1 | Robert Bossy | </pre> |
296 | 1 | Robert Bossy | |
297 | 1 | Robert Bossy | If the context element is an annotation, then this expression returns its length. |
298 | 1 | Robert Bossy | If the context element is a section, then this expression returns returns the length of the section's contents. |
299 | 1 | Robert Bossy | |
300 | 4 | Robert Bossy | h4. Section contents [string] |
301 | 1 | Robert Bossy | |
302 | 1 | Robert Bossy | <pre> |
303 | 1 | Robert Bossy | contents |
304 | 1 | Robert Bossy | </pre> |
305 | 1 | Robert Bossy | |
306 | 1 | Robert Bossy | If the context element is a section, then this expression returns its contents. Otherwise the empty string is returned. |
307 | 1 | Robert Bossy | |
308 | 1 | Robert Bossy | h4. Conditional |
309 | 1 | Robert Bossy | |
310 | 1 | Robert Bossy | <pre> |
311 | 1 | Robert Bossy | if CONDITION then TRUE else TRUE |
312 | 1 | Robert Bossy | </pre> |
313 | 1 | Robert Bossy | |
314 | 1 | Robert Bossy | @CONDITION@ is evaluated as a boolean with the same context element. If the result is, then @TRUE@ is evaluated as the same type with the same context element. Otherwise @FALSE@ is evaluated as the same type with the same context element. |
315 | 1 | Robert Bossy | |
316 | 1 | Robert Bossy | h4. Union [list] |
317 | 4 | Robert Bossy | |
318 | 1 | Robert Bossy | <pre> |
319 | 9 | Robert Bossy | LEFT | RIGHT |
320 | 9 | Robert Bossy | </pre> |
321 | 9 | Robert Bossy | |
322 | 9 | Robert Bossy | @LEFT@ and @RIGHT@ are evaluated as element lists with the same context element. This expression returns the concatenation of the two results. |
323 | 9 | Robert Bossy | Elements in the result list are not reordered. Duplicate lements remain. |
324 | 1 | Robert Bossy | |
325 | 1 | Robert Bossy | h4. Path |
326 | 1 | Robert Bossy | |
327 | 1 | Robert Bossy | <pre> |
328 | 4 | Robert Bossy | LEFT . RIGHT |
329 | 9 | Robert Bossy | </pre> |
330 | 1 | Robert Bossy | |
331 | 1 | Robert Bossy | @LEFT@ is evaluated as an element list, then each element of the result is used as the context element to evaluate @RIGHT@. |
332 | 1 | Robert Bossy | If this expression is evaluated as a boolean, then it retuns @true@ if any evaluation of @RIGHT@ as a boolean is true. |
333 | 1 | Robert Bossy | If this expression is evaluated as a number, then it returns the sum of all successive evaluations of @RIGHT@ as a number. |
334 | 1 | Robert Bossy | If this expression is evaluated as a string, then it returns the concatenation of all successive evaluations of @RIGHT@ as a string. |
335 | 1 | Robert Bossy | If this expression is evaluated as a list, then it returns the concatenation of all successive evaluations of @RIGHT@ as a list. |
336 | 1 | Robert Bossy | |
337 | 1 | Robert Bossy | h3. Element navigation expressions [list] |
338 | 1 | Robert Bossy | |
339 | 9 | Robert Bossy | Element navigation expressions returns elements according to a navigation specification. The following subsections describe each available specification. |
340 | 9 | Robert Bossy | A specification can be followed by filters and ranges. The order of filter and ranges specifies the order in which they are applied. If a range follows a filter, then range is applied after the filter. |
341 | 4 | Robert Bossy | |
342 | 1 | Robert Bossy | h4. Filters |
343 | 1 | Robert Bossy | |
344 | 1 | Robert Bossy | <pre> |
345 | 12 | Robert Bossy | SPEC [ EXPR ] |
346 | 4 | Robert Bossy | </pre> |
347 | 1 | Robert Bossy | |
348 | 1 | Robert Bossy | @SPEC@ is a navigation specification. @EXPR@ is evaluated as a boolean with the current element as the context element. |
349 | 1 | Robert Bossy | The expression returns the list of elements for which @EXPR@ was evaluated as @true@. |
350 | 1 | Robert Bossy | |
351 | 1 | Robert Bossy | h4. Ranges |
352 | 1 | Robert Bossy | |
353 | 1 | Robert Bossy | <pre> |
354 | 12 | Robert Bossy | SPEC { N } |
355 | 12 | Robert Bossy | SPEC { N : M } |
356 | 12 | Robert Bossy | SPEC { : M } |
357 | 12 | Robert Bossy | SPEC { N : } |
358 | 1 | Robert Bossy | </pre> |
359 | 4 | Robert Bossy | |
360 | 1 | Robert Bossy | @SPEC@ is a navigation specification. @N@ and @M@ are integer constants. |
361 | 1 | Robert Bossy | The returned list is a sublist of the list returned by @SPEC@: |
362 | 1 | Robert Bossy | |@N@|a singleton list with the @N@th element| |
363 | 1 | Robert Bossy | |@N : M@|the sublist from the @N@th (inclusive) to the @M@th (exclusive) elements| |
364 | 1 | Robert Bossy | |@: M@|the sublist from the start to the @M@th element (exlusive)| |
365 | 1 | Robert Bossy | |@N :@|the sublist from the @N@th element (inclusive) to the end| |
366 | 1 | Robert Bossy | List indexes are zero-based: @0@ is the first, @1@ is the second, etc. If @N@ or @M@ are negative, then the length of the list + 1 is added to their value: @-1@ is the last (inclusive). |
367 | 1 | Robert Bossy | If the indexes are out of the list boundaries then the index is "cropped". |
368 | 1 | Robert Bossy | |
369 | 9 | Robert Bossy | h4. Self |
370 | 9 | Robert Bossy | |
371 | 9 | Robert Bossy | <pre> |
372 | 9 | Robert Bossy | $ |
373 | 9 | Robert Bossy | </pre> |
374 | 9 | Robert Bossy | |
375 | 9 | Robert Bossy | This expression returns the context element. |
376 | 9 | Robert Bossy | |
377 | 4 | Robert Bossy | h4. Element corpus |
378 | 1 | Robert Bossy | |
379 | 1 | Robert Bossy | <pre> |
380 | 1 | Robert Bossy | corpus |
381 | 1 | Robert Bossy | </pre> |
382 | 1 | Robert Bossy | |
383 | 1 | Robert Bossy | This expression returns the currently annotated corpus. |
384 | 1 | Robert Bossy | |
385 | 4 | Robert Bossy | h4. Element document |
386 | 2 | Robert Bossy | |
387 | 1 | Robert Bossy | <pre> |
388 | 1 | Robert Bossy | document |
389 | 2 | Robert Bossy | </pre> |
390 | 2 | Robert Bossy | |
391 | 2 | Robert Bossy | This expression returns a singleton list containing the document to which the context element belongs. |
392 | 1 | Robert Bossy | If the context element is a document, then this document is returned. |
393 | 2 | Robert Bossy | If the context element is the corpus, then the empty list is returned. |
394 | 2 | Robert Bossy | |
395 | 2 | Robert Bossy | h4. Element section |
396 | 2 | Robert Bossy | |
397 | 1 | Robert Bossy | This expression returns a singleton list containing the section to which the context element belongs. |
398 | 1 | Robert Bossy | If the context element is a section, then this section is returned. |
399 | 1 | Robert Bossy | If the context element is the corpus or a document, then the empty list is returned. |
400 | 4 | Robert Bossy | |
401 | 2 | Robert Bossy | h4. Tuple relation |
402 | 2 | Robert Bossy | |
403 | 2 | Robert Bossy | <pre> |
404 | 4 | Robert Bossy | relation |
405 | 1 | Robert Bossy | </pre> |
406 | 1 | Robert Bossy | |
407 | 1 | Robert Bossy | If the context element is a tuple, then this element returns a singleton list with the relation to which the tuple belongs. Otherwise it returns the empty list. |
408 | 2 | Robert Bossy | |
409 | 2 | Robert Bossy | h4. Corpus documents |
410 | 2 | Robert Bossy | |
411 | 2 | Robert Bossy | <pre> |
412 | 12 | Robert Bossy | documents |
413 | 12 | Robert Bossy | documents : ID |
414 | 1 | Robert Bossy | </pre> |
415 | 1 | Robert Bossy | |
416 | 1 | Robert Bossy | @ID@ is a name. If the context element is the corpus, then this expression returns a singleton list containing the document with the identifier @ID@. If @ID@ is omitted, then this expression returns a list containing all documents in the corpus. |
417 | 12 | Robert Bossy | If the context element is not the corpus, or there is no document in the corpus, or there is no document with the specified identifier, then this expression returns an empty list. |
418 | 1 | Robert Bossy | |
419 | 1 | Robert Bossy | h4. Document sections |
420 | 1 | Robert Bossy | |
421 | 1 | Robert Bossy | <pre> |
422 | 12 | Robert Bossy | sections |
423 | 12 | Robert Bossy | sections : NAME |
424 | 1 | Robert Bossy | </pre> |
425 | 1 | Robert Bossy | |
426 | 1 | Robert Bossy | @NAME@ is a name. If the context element is a document, then this expression returns a list containing all sections in the document with the name @NAME@. If @NAME@ is omitted, then this expression returns all sections of the document. |
427 | 1 | Robert Bossy | If the context element is not a document, or there is no section in the document, or there is no section with the specified name, then this expression returns the empty list. |
428 | 1 | Robert Bossy | |
429 | 1 | Robert Bossy | h4. Section annotations |
430 | 1 | Robert Bossy | |
431 | 4 | Robert Bossy | <pre> |
432 | 12 | Robert Bossy | layer |
433 | 12 | Robert Bossy | layer : NAME |
434 | 1 | Robert Bossy | </pre> |
435 | 1 | Robert Bossy | |
436 | 1 | Robert Bossy | @NAME@ is a name. If the context element is a section, then this expression returns a list containing all annotations in the layer named @NAME@. If @NAME@ is omitted, then this expression returns all annotations of all layers of the section. |
437 | 1 | Robert Bossy | If the context element is not a section, or there is no layer with the specified name, or there is no annotation in the section, or the layer with the specified name is empty, then this expression returns the empty list. |
438 | 1 | Robert Bossy | |
439 | 1 | Robert Bossy | In all cases, the list of annotations is sorted by standard order (increasing start, then decreasing end) and duplicates are removed. |
440 | 1 | Robert Bossy | |
441 | 1 | Robert Bossy | h4. Section relations |
442 | 1 | Robert Bossy | |
443 | 1 | Robert Bossy | <pre> |
444 | 12 | Robert Bossy | relations |
445 | 12 | Robert Bossy | relations : NAME |
446 | 1 | Robert Bossy | </pre> |
447 | 1 | Robert Bossy | |
448 | 1 | Robert Bossy | @NAME@ is a name. If the context element is a section, then this expression returns a singleton list containing the relation in the section with the name @NAME@. If @NAME@ is omitted, then this expression returns all relations of the section. |
449 | 1 | Robert Bossy | If the context element is not a section, or there is no relation in the section, or there is no relation with the specified name, then this expression returns the empty list. |
450 | 1 | Robert Bossy | |
451 | 1 | Robert Bossy | h4. Relation tuples |
452 | 1 | Robert Bossy | |
453 | 4 | Robert Bossy | <pre> |
454 | 1 | Robert Bossy | tuples |
455 | 1 | Robert Bossy | </pre> |
456 | 1 | Robert Bossy | |
457 | 1 | Robert Bossy | If the context element is a relation, then this expression returns a list of all tuples of the relation. Otherwise it returns the empty list. |
458 | 1 | Robert Bossy | |
459 | 1 | Robert Bossy | h4. Tuple arguments |
460 | 1 | Robert Bossy | |
461 | 4 | Robert Bossy | <pre> |
462 | 12 | Robert Bossy | args |
463 | 12 | Robert Bossy | args : ROLE |
464 | 1 | Robert Bossy | </pre> |
465 | 1 | Robert Bossy | |
466 | 1 | Robert Bossy | @ROLE@ is a name. If the context element is a tuple, then this expression returns a singleton list containing the annotation which is the argument of the tuple with the role @ROLE@. If @ROLE@ is omitted, then this expression returns a list containg all arguments of the tuple (in no particular order). |
467 | 1 | Robert Bossy | If the context element is not a tuple, or the tuple has no arguments, or if the tuple does not have an argument with the specified role, then this expression returns the empty list. |
468 | 1 | Robert Bossy | |
469 | 1 | Robert Bossy | h4. Reverse tuple lookup |
470 | 1 | Robert Bossy | |
471 | 4 | Robert Bossy | <pre> |
472 | 12 | Robert Bossy | tuples : RELATION |
473 | 12 | Robert Bossy | tuples : RELATION : ROLE |
474 | 1 | Robert Bossy | </pre> |
475 | 1 | Robert Bossy | |
476 | 1 | Robert Bossy | @RELATION@ and @ROLE@ are names. If the context element is an annotation, then this expression retuerns a list containing all tuples that satisfy all the following conditions: |
477 | 1 | Robert Bossy | # the tuple pertain to the relation with name @RELATION@ in the same section |
478 | 1 | Robert Bossy | # the annotation is the argument of the tuple with role @ROLE@, if @ROLE@ is omitted, then the annotation is an argument of the tuple regardless of the role |
479 | 1 | Robert Bossy | If the context element is not an annotation, or the section does not contain a relation with the specified name, then this expression returns the empty list. |
480 | 1 | Robert Bossy | |
481 | 1 | Robert Bossy | h4. Annotation siblings |
482 | 1 | Robert Bossy | |
483 | 1 | Robert Bossy | <pre> |
484 | 1 | Robert Bossy | after : NAME |
485 | 1 | Robert Bossy | before : NAME |
486 | 1 | Robert Bossy | inside : NAME |
487 | 1 | Robert Bossy | outside : NAME |
488 | 1 | Robert Bossy | overlapping : NAME |
489 | 9 | Robert Bossy | span : NAME |
490 | 1 | Robert Bossy | </pre> |
491 | 1 | Robert Bossy | |
492 | 1 | Robert Bossy | If the context element is an annotation, then this expression returns a list of annotations in the layer with name @NAME@ in the same section. The annotations included in the result list depend on the keyword: |
493 | 1 | Robert Bossy | |
494 | 1 | Robert Bossy | |@after@|start after the context annotation end| |
495 | 1 | Robert Bossy | |@before@|end before the context annotation start| |
496 | 1 | Robert Bossy | |@inside@|fully included in the context annotation span| |
497 | 1 | Robert Bossy | |@outside@|fully includes the context annotation| |
498 | 1 | Robert Bossy | |@overlapping@|overlaps (broad sense) the context annotation| |
499 | 9 | Robert Bossy | |@span@|exact same span as the context annotation| |
500 | 1 | Robert Bossy | |
501 | 1 | Robert Bossy | If the context element is not an annotation, or the section does not have a layer with the specified name, then this expression returns the empty list. |
502 | 1 | Robert Bossy | In all cases, the returned list is sorted in standard order. |
503 | 9 | Robert Bossy | |
504 | 14 | Robert Bossy | h3. Side-effect expressions |
505 | 9 | Robert Bossy | |
506 | 14 | Robert Bossy | Side-effect expressions affect the corpus data structure. Only some modules allow actions inside an expression; refer to the module documentation. |
507 | 9 | Robert Bossy | |
508 | 9 | Robert Bossy | h4. Element creation |
509 | 9 | Robert Bossy | |
510 | 9 | Robert Bossy | <pre> |
511 | 9 | Robert Bossy | new : document ( ID ) |
512 | 9 | Robert Bossy | new : section ( NAMEEXPR , CONTENTS) |
513 | 9 | Robert Bossy | new : section : NAME ( CONTENTS ) |
514 | 9 | Robert Bossy | new : relation : NAME |
515 | 9 | Robert Bossy | new : tuple |
516 | 9 | Robert Bossy | new : LAYER ( START , END ) |
517 | 9 | Robert Bossy | new : LAYER ( ANNOTATIONS ) |
518 | 9 | Robert Bossy | </pre> |
519 | 9 | Robert Bossy | |
520 | 9 | Robert Bossy | Expressions that start with @new:@ create a new element and return it. The type of the element depends on the next functor. The created element is attached to the context element. If the context element is not of the adequate type then the expression does nothing, and returns nothing. |
521 | 9 | Robert Bossy | @ID@ is an expression evaluated as a string. If the context element is the corpus, then @new:document(ID)@ creates a document with the specified identifier. If the corpus already contains a document with the specified identifier, then an error is issued. |
522 | 9 | Robert Bossy | @NAMEEXPR@ and @CONTENTS@ are expressions evaluated as strings. If the context element is a document, then @new:section(NAMEEXPR,CONTENTS)@ creates a section with the specified name and contents. |
523 | 9 | Robert Bossy | @NAME@ is a name: @new:section:NAME(CONTENTS)@ allowes to create a section by specifying the name without an expression. |
524 | 9 | Robert Bossy | If the context element is a section, then @new:relation:NAME@ creates a relation with the specified name. |
525 | 9 | Robert Bossy | @START@ and @END@ are expressions evaluated as integers. If the context element is a section, then @new:LAYER(START,END)@ creates an annotation with the specified positions, then adds it to the specified layer. |
526 | 9 | Robert Bossy | @ANNOTATIONS@ is an expression evaluated as a list of elements. @new:LAYER(ANNOTATIONS)@ creates an annotation that covers all annotations of the same section in @ANNOTATIONS@, then adds it to the specified layer. |
527 | 9 | Robert Bossy | |
528 | 9 | Robert Bossy | h4. Set argument |
529 | 9 | Robert Bossy | |
530 | 9 | Robert Bossy | <pre> |
531 | 9 | Robert Bossy | arg : ROLE ( ARG ) |
532 | 9 | Robert Bossy | </pre> |
533 | 9 | Robert Bossy | |
534 | 9 | Robert Bossy | @ROLE@ is a name and @ARG@ is an expression evaluated as a list of elements. If the context element is a tuple, the this expression sets the argument with the specified role to the first annotation in the result of @ARG@. If the evaluation of @ARG@ does not yield any annotation, then this expression does nothing. |
535 | 9 | Robert Bossy | This expression always return the context element, so different arguments can be chained by paths. |
536 | 9 | Robert Bossy | |
537 | 9 | Robert Bossy | h4. Set feature |
538 | 9 | Robert Bossy | |
539 | 9 | Robert Bossy | <pre> |
540 | 9 | Robert Bossy | feat : KEY ( VALUE ) |
541 | 9 | Robert Bossy | </pre> |
542 | 9 | Robert Bossy | |
543 | 9 | Robert Bossy | @KEY@ is a name and @VALUE@ is an expression evaluated as a string. This expression adds a feature with the specified key and value to the context element. |
544 | 9 | Robert Bossy | This expression always return the context element, so different arguments can be chained by paths. |
545 | 1 | Robert Bossy | |
546 | 9 | Robert Bossy | h4. Delete element |
547 | 9 | Robert Bossy | |
548 | 9 | Robert Bossy | <pre> |
549 | 9 | Robert Bossy | delete |
550 | 9 | Robert Bossy | </pre> |
551 | 9 | Robert Bossy | |
552 | 9 | Robert Bossy | This expression deletes the context element. The deletion is permanent. The corpus cannot be deleted. |
553 | 11 | Robert Bossy | |
554 | 9 | Robert Bossy | h4. Add to layer |
555 | 9 | Robert Bossy | |
556 | 9 | Robert Bossy | <pre> |
557 | 9 | Robert Bossy | add : NAME |
558 | 9 | Robert Bossy | </pre> |
559 | 9 | Robert Bossy | |
560 | 9 | Robert Bossy | If the context element is an annotation, then this expression adds it to the layer named @NAME@. |
561 | 9 | Robert Bossy | |
562 | 9 | Robert Bossy | h4. Remove from layer |
563 | 9 | Robert Bossy | |
564 | 9 | Robert Bossy | <pre> |
565 | 9 | Robert Bossy | remove : NAME |
566 | 9 | Robert Bossy | </pre> |
567 | 9 | Robert Bossy | |
568 | 9 | Robert Bossy | If the context element is an annotation, then this expression removes it from the layer named @NAME@. |
569 | 9 | Robert Bossy | |
570 | 9 | Robert Bossy | h3. Library function call |
571 | 9 | Robert Bossy | |
572 | 9 | Robert Bossy | <pre> |
573 | 9 | Robert Bossy | lib : FTOR1 : ... : FTORn ( ARG1 , ... , ARGm ) |
574 | 9 | Robert Bossy | </pre> |
575 | 9 | Robert Bossy | |
576 | 9 | Robert Bossy | This expression calls a library function with arguments @ARG1@, ..., @ARGm@. |