Element Expression » History » Version 4
Robert Bossy, 08/25/2011 02:38 PM
1 | 4 | Robert Bossy | h1. Element Expression |
---|---|---|---|
2 | 4 | Robert Bossy | |
3 | 1 | Robert Bossy | {{toc}} |
4 | 1 | Robert Bossy | |
5 | 4 | Robert Bossy | h2. Introduction |
6 | 3 | Robert Bossy | |
7 | 1 | 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 [[ElementExpressionExamples]] useful too. |
8 | 1 | Robert Bossy | |
9 | 4 | Robert Bossy | h2. Context Element |
10 | 1 | Robert Bossy | |
11 | 1 | Robert Bossy | Expressions are evaluated within a context that includes an element. The context element can be one of the following: |
12 | 1 | Robert Bossy | * the corpus |
13 | 1 | Robert Bossy | * a document |
14 | 1 | Robert Bossy | * a section |
15 | 1 | Robert Bossy | * an annotation |
16 | 1 | Robert Bossy | * a relation |
17 | 1 | Robert Bossy | * a tuple |
18 | 1 | Robert Bossy | |
19 | 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. |
20 | 1 | Robert Bossy | |
21 | 4 | Robert Bossy | h2. Evaluation types |
22 | 1 | Robert Bossy | |
23 | 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. |
24 | 1 | Robert Bossy | |
25 | 4 | Robert Bossy | h3. Scalar types |
26 | 1 | Robert Bossy | |
27 | 4 | Robert Bossy | h4. Boolean |
28 | 1 | Robert Bossy | |
29 | 1 | Robert Bossy | The boolean type has two values: @false@ and @true@. |
30 | 1 | Robert Bossy | |
31 | 4 | Robert Bossy | h4. Number |
32 | 1 | Robert Bossy | |
33 | 1 | Robert Bossy | The number type is a double precision 64-bit floating point number (Java @double@). |
34 | 1 | Robert Bossy | |
35 | 4 | Robert Bossy | h4. String |
36 | 1 | Robert Bossy | |
37 | 1 | Robert Bossy | The string type is a 16-bit unicode character sequence (Java @String@). |
38 | 1 | Robert Bossy | |
39 | 4 | Robert Bossy | h3. Element list |
40 | 1 | Robert Bossy | |
41 | 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.). |
42 | 1 | Robert Bossy | |
43 | 4 | Robert Bossy | h3. Type coercion |
44 | 1 | Robert Bossy | |
45 | 1 | Robert Bossy | The majority of expressions have a priviledged or primary evaluation type, however they can be evaluated into another type. The value is computed using type coercion rules: |
46 | 1 | Robert Bossy | |
47 | 1 | Robert Bossy | | |*boolean*|*number*|*string*|*list*| |
48 | 1 | Robert Bossy | |*boolean*||false=0, true=1|false="false", true="true"|empty list| |
49 | 1 | Robert Bossy | |*number* |0=false, otherwise true||decimal notation string|empty list| |
50 | 1 | Robert Bossy | |*string* |""=false, otherwise true|decimal conversion||empty list| |
51 | 1 | Robert Bossy | |*list* |empty=false, otherwise true|element count|concatenation of static features|| |
52 | 1 | Robert Bossy | |
53 | 1 | Robert Bossy | Some expressions have specific coercion rules. |
54 | 1 | Robert Bossy | |
55 | 4 | Robert Bossy | h2. Operator precedence and associativity |
56 | 1 | Robert Bossy | |
57 | 1 | Robert Bossy | The following operators are listed in descending order of precedence. The precedence can be overriden with parentheses. |
58 | 1 | Robert Bossy | |
59 | 1 | Robert Bossy | |*Operators*|*Associative*| |
60 | 1 | Robert Bossy | |@if then else@|no| |
61 | 1 | Robert Bossy | |@or@|yes| |
62 | 1 | Robert Bossy | |@and@|yes| |
63 | 1 | Robert Bossy | |@not@|no| |
64 | 1 | Robert Bossy | |@== != < > <= >= ?= ^= =^ =~ in any@|no| |
65 | 1 | Robert Bossy | |@^@|yes| |
66 | 1 | Robert Bossy | |@+ -@|yes| |
67 | 1 | Robert Bossy | |@* / %@|yes| |
68 | 1 | Robert Bossy | |unary @-@|no| |
69 | 1 | Robert Bossy | |pipe|yes| |
70 | 1 | Robert Bossy | |@.@|yes| |
71 | 1 | Robert Bossy | |
72 | 4 | Robert Bossy | h2. Syntax for names |
73 | 1 | Robert Bossy | |
74 | 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: |
75 | 1 | Robert Bossy | * all characters are alphabetic (@A-Za-z@) or undescore (@_@) |
76 | 1 | Robert Bossy | * the name is different from any reserved word: |
77 | 1 | Robert Bossy | |@after@| |
78 | 1 | Robert Bossy | |@and@| |
79 | 1 | Robert Bossy | |@any@| |
80 | 1 | Robert Bossy | |@args@| |
81 | 1 | Robert Bossy | |@before@| |
82 | 1 | Robert Bossy | |@boolean@| |
83 | 1 | Robert Bossy | |@contents@| |
84 | 1 | Robert Bossy | |@corpus@| |
85 | 1 | Robert Bossy | |@document@| |
86 | 1 | Robert Bossy | |@documents@| |
87 | 1 | Robert Bossy | |@elements@| |
88 | 1 | Robert Bossy | |@else@| |
89 | 1 | Robert Bossy | |@end@| |
90 | 1 | Robert Bossy | |@false@| |
91 | 1 | Robert Bossy | |@if@| |
92 | 1 | Robert Bossy | |@in@| |
93 | 1 | Robert Bossy | |@inside@| |
94 | 1 | Robert Bossy | |@layer@| |
95 | 1 | Robert Bossy | |@length@| |
96 | 1 | Robert Bossy | |@not@| |
97 | 1 | Robert Bossy | |@number@| |
98 | 1 | Robert Bossy | |@or@| |
99 | 1 | Robert Bossy | |@outside@| |
100 | 1 | Robert Bossy | |@overlapping@| |
101 | 1 | Robert Bossy | |@relation@| |
102 | 1 | Robert Bossy | |@relations@| |
103 | 1 | Robert Bossy | |@section@| |
104 | 1 | Robert Bossy | |@sections@| |
105 | 1 | Robert Bossy | |@start@| |
106 | 1 | Robert Bossy | |@string@| |
107 | 1 | Robert Bossy | |@then@| |
108 | 1 | Robert Bossy | |@true@| |
109 | 1 | Robert Bossy | |@tuples@| |
110 | 1 | Robert Bossy | |
111 | 2 | Robert Bossy | Note that names and keywords are case-sensitive. All keywords are all lowercase. |
112 | 1 | Robert Bossy | |
113 | 4 | Robert Bossy | h2. Expression reference |
114 | 1 | Robert Bossy | |
115 | 2 | 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: |
116 | 1 | Robert Bossy | |
117 | 1 | Robert Bossy | <pre> |
118 | 2 | Robert Bossy | EXPR uppercase words are variable parts of the expression usage, they are meant to be replaced either by sub-expressions, names or constants |
119 | 1 | Robert Bossy | layer lowercase words are keywords |
120 | 2 | Robert Bossy | [ ... ] parts between brackets are optional |
121 | 2 | Robert Bossy | ( ) . + : all other sylmbols are operators, parenthes or a column, they are part of the expression syntax |
122 | 2 | Robert Bossy | </pre> |
123 | 2 | Robert Bossy | |
124 | 1 | Robert Bossy | If there is a preferred type for the expression, then this type is specified between brackets in the expression name. |
125 | 2 | Robert Bossy | |
126 | 4 | Robert Bossy | h4. Boolean constant [boolean] |
127 | 2 | Robert Bossy | |
128 | 2 | Robert Bossy | <pre> |
129 | 1 | Robert Bossy | false |
130 | 1 | Robert Bossy | true |
131 | 1 | Robert Bossy | </pre> |
132 | 1 | Robert Bossy | |
133 | 4 | Robert Bossy | h4. Integer constant [number] |
134 | 1 | Robert Bossy | |
135 | 1 | Robert Bossy | <pre> |
136 | 1 | Robert Bossy | [0-9]+ |
137 | 1 | Robert Bossy | </pre> |
138 | 1 | Robert Bossy | |
139 | 4 | Robert Bossy | h4. String constants [string] |
140 | 2 | Robert Bossy | |
141 | 1 | Robert Bossy | <pre> |
142 | 2 | Robert Bossy | "..." |
143 | 2 | Robert Bossy | </pre> |
144 | 2 | Robert Bossy | |
145 | 1 | Robert Bossy | String constants are double quoted character sequences. The usual Java escape sequences apply. |
146 | 1 | Robert Bossy | |
147 | 4 | Robert Bossy | h4. Boolean operators [boolean] |
148 | 1 | Robert Bossy | |
149 | 1 | Robert Bossy | <pre> |
150 | 1 | Robert Bossy | LEFT and RIGHT |
151 | 1 | Robert Bossy | LEFT or RIGHT |
152 | 1 | Robert Bossy | not EXPR |
153 | 1 | Robert Bossy | </pre> |
154 | 1 | Robert Bossy | |
155 | 1 | Robert Bossy | @LEFT@, @RIGHT@ and @EXPR@ are evaluated as booleans with the same context element. |
156 | 1 | Robert Bossy | Binary boolean operator evaluation is short-circuited. |
157 | 1 | Robert Bossy | |
158 | 4 | Robert Bossy | h4. General comparison [boolean] |
159 | 1 | Robert Bossy | |
160 | 1 | Robert Bossy | <pre> |
161 | 1 | Robert Bossy | LEFT == RIGHT |
162 | 1 | Robert Bossy | LEFT != RIGHT |
163 | 1 | Robert Bossy | </pre> |
164 | 1 | Robert Bossy | |
165 | 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. |
166 | 1 | Robert Bossy | |
167 | 4 | Robert Bossy | h4. Integer comparison [boolean] |
168 | 1 | Robert Bossy | |
169 | 1 | Robert Bossy | <pre> |
170 | 1 | Robert Bossy | LEFT < RIGHT |
171 | 1 | Robert Bossy | LEFT > RIGHT |
172 | 1 | Robert Bossy | LEFT <= RIGHT |
173 | 1 | Robert Bossy | LEFT >= RIGHT |
174 | 1 | Robert Bossy | </pre> |
175 | 1 | Robert Bossy | |
176 | 1 | Robert Bossy | @LEFT@ and @RIGHT@ are evaluated as numbers using the same context element. |
177 | 1 | Robert Bossy | |
178 | 4 | Robert Bossy | h4. String comparison [boolean] |
179 | 1 | Robert Bossy | |
180 | 1 | Robert Bossy | <pre> |
181 | 1 | Robert Bossy | LEFT ?= RIGHT |
182 | 1 | Robert Bossy | LEFT ^= RIGHT |
183 | 1 | Robert Bossy | LEFT =^ RIGHT |
184 | 1 | Robert Bossy | </pre> |
185 | 1 | Robert Bossy | |
186 | 1 | Robert Bossy | @LEFT@ and @RIGHT@ are evaluated as strings using the same context element. |
187 | 1 | Robert Bossy | Meaning of operators: |
188 | 1 | Robert Bossy | |@?=@|contains| |
189 | 1 | Robert Bossy | |@^=@|starts with| |
190 | 1 | Robert Bossy | |@=^@|ends with| |
191 | 1 | Robert Bossy | |
192 | 4 | Robert Bossy | h4. String concatenation [string] |
193 | 1 | Robert Bossy | |
194 | 1 | Robert Bossy | <pre> |
195 | 1 | Robert Bossy | LEFT ^ RIGHT |
196 | 1 | Robert Bossy | </pre> |
197 | 1 | Robert Bossy | |
198 | 1 | Robert Bossy | @LEFT@ and @RIGHT@ are evaluated as strings with the same context element. |
199 | 1 | Robert Bossy | |
200 | 4 | Robert Bossy | h4. Regexp match |
201 | 1 | Robert Bossy | |
202 | 1 | Robert Bossy | <pre> |
203 | 1 | Robert Bossy | TARGET =~ "PATTERN" |
204 | 1 | Robert Bossy | </pre> |
205 | 1 | Robert Bossy | |
206 | 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 |
207 | 1 | Robert Bossy | If evaluated as a boolean, then this expression returns either the target matches the pattern. |
208 | 1 | Robert Bossy | If evaluated as a number, then this expression returns the number of non-overlapping matches of the pattern in the target. |
209 | 1 | Robert Bossy | If evaluated as a string, then this expression returns the first match of the pattern in the target. |
210 | 1 | Robert Bossy | If evaluated as an element list, then this expression returns an empty list. |
211 | 1 | Robert Bossy | |
212 | 4 | Robert Bossy | h4. Arithmetic [number] |
213 | 1 | Robert Bossy | |
214 | 1 | Robert Bossy | <pre> |
215 | 1 | Robert Bossy | LEFT + RIGHT |
216 | 1 | Robert Bossy | LEFT - RIGHT |
217 | 1 | Robert Bossy | LEFT * RIGHT |
218 | 1 | Robert Bossy | LEFT / RIGHT |
219 | 1 | Robert Bossy | LEFT % RIGHT |
220 | 1 | Robert Bossy | </pre> |
221 | 1 | Robert Bossy | |
222 | 1 | Robert Bossy | @LEFT@ and @RIGHT@ are both evaluated as numbers with the same context element. |
223 | 1 | Robert Bossy | |
224 | 4 | Robert Bossy | h4. Unary minus [number] |
225 | 1 | Robert Bossy | |
226 | 1 | Robert Bossy | <pre> |
227 | 1 | Robert Bossy | - EXPR |
228 | 1 | Robert Bossy | </pre> |
229 | 1 | Robert Bossy | |
230 | 1 | Robert Bossy | @EXPR@ is evaluated as a number with the same context element. |
231 | 1 | Robert Bossy | |
232 | 4 | Robert Bossy | h4. Dictionary lookup [boolean] |
233 | 1 | Robert Bossy | |
234 | 1 | Robert Bossy | <pre> |
235 | 1 | Robert Bossy | EXPR in "FILE"[:"ENCODING"] |
236 | 1 | Robert Bossy | </pre> |
237 | 1 | Robert Bossy | |
238 | 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. |
239 | 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. |
240 | 1 | Robert Bossy | |
241 | 4 | Robert Bossy | h4. Feature |
242 | 1 | Robert Bossy | |
243 | 1 | Robert Bossy | <pre> |
244 | 1 | Robert Bossy | KEY |
245 | 1 | Robert Bossy | </pre> |
246 | 1 | Robert Bossy | |
247 | 1 | Robert Bossy | @KEY@ is a name. This expression returns the last value of the feature with key @KEY@ of context element. |
248 | 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+. |
249 | 1 | Robert Bossy | |
250 | 4 | Robert Bossy | h4. Any feature value equals |
251 | 1 | Robert Bossy | |
252 | 1 | Robert Bossy | <pre> |
253 | 1 | Robert Bossy | any @KEY@ == @EXPR@ |
254 | 1 | Robert Bossy | </pre> |
255 | 1 | Robert Bossy | |
256 | 1 | Robert Bossy | @KEY@ is a name. @EXPR@ is evaluated as a string with the same context element. |
257 | 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@. |
258 | 1 | Robert Bossy | |
259 | 4 | Robert Bossy | h4. Annotation positions [number] |
260 | 1 | Robert Bossy | |
261 | 1 | Robert Bossy | <pre> |
262 | 1 | Robert Bossy | start |
263 | 1 | Robert Bossy | end |
264 | 1 | Robert Bossy | </pre> |
265 | 1 | Robert Bossy | |
266 | 1 | Robert Bossy | These expressions return the start or end position if the context element is an annotation. Otherwise it returns @0@. |
267 | 1 | Robert Bossy | |
268 | 4 | Robert Bossy | h4. Element length [number] |
269 | 1 | Robert Bossy | |
270 | 1 | Robert Bossy | <pre> |
271 | 1 | Robert Bossy | length |
272 | 1 | Robert Bossy | </pre> |
273 | 1 | Robert Bossy | |
274 | 1 | Robert Bossy | If the context element is an annotation, then this expression returns its length. |
275 | 1 | Robert Bossy | If the context element is a section, then this expression returns returns the length of the section's contents. |
276 | 1 | Robert Bossy | |
277 | 4 | Robert Bossy | h4. Reference |
278 | 1 | Robert Bossy | |
279 | 1 | Robert Bossy | <pre> |
280 | 1 | Robert Bossy | $REF |
281 | 1 | Robert Bossy | </pre> |
282 | 1 | Robert Bossy | |
283 | 1 | Robert Bossy | @REF@ is a name. This expression returns the value of the named reference. |
284 | 1 | Robert Bossy | Available references should be documented by the module. |
285 | 1 | Robert Bossy | |
286 | 4 | Robert Bossy | h4. Section contents [string] |
287 | 1 | Robert Bossy | |
288 | 1 | Robert Bossy | <pre> |
289 | 1 | Robert Bossy | contents |
290 | 1 | Robert Bossy | </pre> |
291 | 1 | Robert Bossy | |
292 | 1 | Robert Bossy | If the context element is a section, then this expression returns its contents. Otherwise the empty string is returned. |
293 | 1 | Robert Bossy | |
294 | 4 | Robert Bossy | h4. Conditional |
295 | 1 | Robert Bossy | |
296 | 1 | Robert Bossy | <pre> |
297 | 1 | Robert Bossy | if CONDITION then TRUE else TRUE |
298 | 1 | Robert Bossy | </pre> |
299 | 1 | Robert Bossy | |
300 | 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. |
301 | 1 | Robert Bossy | |
302 | 4 | Robert Bossy | h4. Union [list] |
303 | 1 | Robert Bossy | |
304 | 1 | Robert Bossy | <pre> |
305 | 1 | Robert Bossy | LEFT | RIGHT |
306 | 1 | Robert Bossy | </pre> |
307 | 1 | Robert Bossy | |
308 | 1 | Robert Bossy | @LEFT@ and @RIGHT@ are evaluated as element lists with the same context element. This expression returns the concatenation of the two results. |
309 | 1 | Robert Bossy | Elements in the result list are not reordered. Duplicate lements remain. |
310 | 1 | Robert Bossy | |
311 | 4 | Robert Bossy | h4. Path |
312 | 1 | Robert Bossy | |
313 | 1 | Robert Bossy | <pre> |
314 | 1 | Robert Bossy | LEFT . RIGHT |
315 | 1 | Robert Bossy | </pre> |
316 | 1 | Robert Bossy | |
317 | 1 | Robert Bossy | @LEFT@ is evaluated as an element list with the same context element, then each element of the result is used as the context element to evaluate @RIGHT@. |
318 | 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. |
319 | 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. |
320 | 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. |
321 | 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. |
322 | 1 | Robert Bossy | |
323 | 4 | Robert Bossy | h3. Element navigation expressions [list] |
324 | 1 | Robert Bossy | |
325 | 1 | Robert Bossy | Element navigation expressions returns elements according to a navigation specification. The following subsections describe each available specification. |
326 | 1 | 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. |
327 | 1 | Robert Bossy | |
328 | 4 | Robert Bossy | h4. Filters |
329 | 1 | Robert Bossy | |
330 | 1 | Robert Bossy | <pre> |
331 | 1 | Robert Bossy | SPEC ( EXPR ) |
332 | 1 | Robert Bossy | </pre> |
333 | 1 | Robert Bossy | |
334 | 1 | Robert Bossy | @SPEC@ is a navigation specification. @EXPR@ is evaluated as a boolean with the current element as the context element. |
335 | 1 | Robert Bossy | The expression returns the list of elements for which @EXPR@ was evaluated as @true@. |
336 | 1 | Robert Bossy | |
337 | 4 | Robert Bossy | h4. Ranges |
338 | 1 | Robert Bossy | |
339 | 1 | Robert Bossy | <pre> |
340 | 1 | Robert Bossy | SPEC ( N ) |
341 | 1 | Robert Bossy | SPEC ( N : M) |
342 | 1 | Robert Bossy | SPEC ( : M ) |
343 | 1 | Robert Bossy | SPEC ( N : ) |
344 | 1 | Robert Bossy | </pre> |
345 | 1 | Robert Bossy | |
346 | 1 | Robert Bossy | @SPEC@ is a navigation specification. @N@ and @M@ are integer constants. |
347 | 1 | Robert Bossy | The returned list is a sublist of the list returned by @SPEC@: |
348 | 1 | Robert Bossy | |@N@|a singleton list with the @N@th element| |
349 | 1 | Robert Bossy | |@N : M@|the sublist from the @N@th (inclusive) to the @M@th (exclusive) elements| |
350 | 1 | Robert Bossy | |@: M@|the sublist from the start to the @M@th element (exlusive)| |
351 | 1 | Robert Bossy | |@N :@|the sublist from the @N@th element (inclusive) to the end| |
352 | 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). |
353 | 1 | Robert Bossy | If the indexes are out of the list boundaries then the index is "cropped". |
354 | 1 | Robert Bossy | |
355 | 4 | Robert Bossy | h4. Element corpus |
356 | 1 | Robert Bossy | |
357 | 1 | Robert Bossy | <pre> |
358 | 1 | Robert Bossy | corpus |
359 | 1 | Robert Bossy | </pre> |
360 | 1 | Robert Bossy | |
361 | 1 | Robert Bossy | This expression returns the currently annotated corpus. |
362 | 1 | Robert Bossy | |
363 | 4 | Robert Bossy | h4. Element document |
364 | 2 | Robert Bossy | |
365 | 2 | Robert Bossy | <pre> |
366 | 2 | Robert Bossy | document |
367 | 2 | Robert Bossy | </pre> |
368 | 2 | Robert Bossy | |
369 | 2 | Robert Bossy | This expression returns a singleton list containing the document to which the context element belongs. |
370 | 2 | Robert Bossy | If the context element is a document, then this document is returned. |
371 | 2 | Robert Bossy | If the context element is the corpus, then the empty list is returned. |
372 | 1 | Robert Bossy | |
373 | 4 | Robert Bossy | h4. Element section |
374 | 2 | Robert Bossy | |
375 | 2 | Robert Bossy | This expression returns a singleton list containing the section to which the context element belongs. |
376 | 2 | Robert Bossy | If the context element is a section, then this section is returned. |
377 | 2 | Robert Bossy | If the context element is the corpus or a document, then the empty list is returned. |
378 | 2 | Robert Bossy | |
379 | 4 | Robert Bossy | h4. Tuple relation |
380 | 1 | Robert Bossy | |
381 | 2 | Robert Bossy | <pre> |
382 | 2 | Robert Bossy | relation |
383 | 2 | Robert Bossy | </pre> |
384 | 2 | Robert Bossy | |
385 | 2 | 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. |
386 | 1 | Robert Bossy | |
387 | 4 | Robert Bossy | h4. Corpus documents |
388 | 1 | Robert Bossy | |
389 | 1 | Robert Bossy | <pre> |
390 | 1 | Robert Bossy | documents [ : ID ] |
391 | 1 | Robert Bossy | </pre> |
392 | 1 | Robert Bossy | |
393 | 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. |
394 | 1 | 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 the empty list. |
395 | 1 | Robert Bossy | |
396 | 4 | Robert Bossy | h4. Document sections |
397 | 1 | Robert Bossy | |
398 | 1 | Robert Bossy | <pre> |
399 | 1 | Robert Bossy | sections [ : NAME ] |
400 | 1 | Robert Bossy | </pre> |
401 | 1 | Robert Bossy | |
402 | 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. |
403 | 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. |
404 | 1 | Robert Bossy | |
405 | 4 | Robert Bossy | h4. Section annotations |
406 | 1 | Robert Bossy | |
407 | 1 | Robert Bossy | <pre> |
408 | 1 | Robert Bossy | layer [ : NAME ] |
409 | 1 | Robert Bossy | </pre> |
410 | 1 | Robert Bossy | |
411 | 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. |
412 | 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. |
413 | 1 | Robert Bossy | |
414 | 1 | Robert Bossy | In all cases, the list of annotations is sorted by standard order (increasing start, then decreasing end) and duplicates are removed. |
415 | 1 | Robert Bossy | |
416 | 4 | Robert Bossy | h4. Section relations |
417 | 1 | Robert Bossy | |
418 | 1 | Robert Bossy | <pre> |
419 | 1 | Robert Bossy | relations [ : NAME ] |
420 | 1 | Robert Bossy | </pre> |
421 | 1 | Robert Bossy | |
422 | 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. |
423 | 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. |
424 | 1 | Robert Bossy | |
425 | 4 | Robert Bossy | h4. Relation tuples |
426 | 1 | Robert Bossy | |
427 | 1 | Robert Bossy | <pre> |
428 | 1 | Robert Bossy | tuples |
429 | 1 | Robert Bossy | </pre> |
430 | 1 | Robert Bossy | |
431 | 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. |
432 | 1 | Robert Bossy | |
433 | 4 | Robert Bossy | h4. Tuple arguments |
434 | 1 | Robert Bossy | |
435 | 1 | Robert Bossy | <pre> |
436 | 1 | Robert Bossy | args [ : ROLE ] |
437 | 1 | Robert Bossy | </pre> |
438 | 1 | Robert Bossy | |
439 | 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). |
440 | 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. |
441 | 1 | Robert Bossy | |
442 | 4 | Robert Bossy | h4. Reverse tuple lookup |
443 | 1 | Robert Bossy | |
444 | 1 | Robert Bossy | <pre> |
445 | 1 | Robert Bossy | tuples : RELATION [ : ROLE ] |
446 | 1 | Robert Bossy | </pre> |
447 | 1 | Robert Bossy | |
448 | 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: |
449 | 1 | Robert Bossy | # the tuple pertain to the relation with name @RELATION@ in the same section |
450 | 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 |
451 | 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. |
452 | 1 | Robert Bossy | |
453 | 4 | Robert Bossy | h4. Annotation siblings |
454 | 1 | Robert Bossy | |
455 | 1 | Robert Bossy | <pre> |
456 | 2 | Robert Bossy | after : NAME |
457 | 2 | Robert Bossy | before : NAME |
458 | 2 | Robert Bossy | inside : NAME |
459 | 2 | Robert Bossy | outside : NAME |
460 | 2 | Robert Bossy | overlapping : NAME |
461 | 1 | Robert Bossy | </pre> |
462 | 1 | Robert Bossy | |
463 | 2 | 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: |
464 | 1 | Robert Bossy | |
465 | 2 | Robert Bossy | |@after@|start after the context annotation end| |
466 | 2 | Robert Bossy | |@before@|end before the context annotation start| |
467 | 2 | Robert Bossy | |@inside@|fully included in the context annotation span| |
468 | 2 | Robert Bossy | |@outside@|fully includes the context annotation| |
469 | 2 | Robert Bossy | |@overlapping@|overlaps (broad sense) the context annotation| |
470 | 1 | Robert Bossy | |
471 | 2 | 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. |
472 | 2 | Robert Bossy | In all cases, the returned list is sorted in standard order. |