Project

General

Profile

Element Expression Examples » History » Version 6

Robert Bossy, 04/11/2017 06:26 PM

1 6 Robert Bossy
h1. %{color:red}This page is obsolete, please go to https://github.com/Bibliome/alvisnlp/wiki/Element-expression-examples%
2 6 Robert Bossy
3 6 Robert Bossy
4 4 Robert Bossy
h1. Element Expression Examples
5 4 Robert Bossy
6 1 Robert Bossy
{{toc}}
7 1 Robert Bossy
8 4 Robert Bossy
The type of the expected kind of context element is given between brackets in the example title. For detailed information on all the expression parts, you may refer to [[Element Expression]].
9 1 Robert Bossy
10 1 Robert Bossy
h3. Sections in the corpus [corpus]
11 1 Robert Bossy
12 1 Robert Bossy
<pre>
13 1 Robert Bossy
documents.sections
14 1 Robert Bossy
</pre>
15 1 Robert Bossy
16 1 Robert Bossy
h3. Abstract sections [corpus]
17 1 Robert Bossy
18 1 Robert Bossy
<pre>
19 1 Robert Bossy
documents.sections:abstract
20 1 Robert Bossy
</pre>
21 1 Robert Bossy
22 1 Robert Bossy
or
23 1 Robert Bossy
24 1 Robert Bossy
<pre>
25 5 Robert Bossy
documents.sections[@name == "abstract"]
26 1 Robert Bossy
</pre>
27 1 Robert Bossy
28 1 Robert Bossy
First is faster.
29 1 Robert Bossy
30 1 Robert Bossy
h3. Abstract sections in the test set [corpus]
31 1 Robert Bossy
32 1 Robert Bossy
<pre>
33 5 Robert Bossy
documents[@set == "test"].sections:abstract
34 1 Robert Bossy
</pre>
35 1 Robert Bossy
36 1 Robert Bossy
This assumes that documents have a feature with key _set_ that denote the set to which it pertains.
37 1 Robert Bossy
38 3 Robert Bossy
h3. Documents whose PMID is in a file [corpus]
39 3 Robert Bossy
40 3 Robert Bossy
<pre>
41 5 Robert Bossy
documents[@pmid in "good_pmids.txt"]
42 3 Robert Bossy
</pre>
43 3 Robert Bossy
44 3 Robert Bossy
This assumes that the PMID of the document is in a feature with key _pmid_, and there is a file in the current directory named _good_pmids.txt_ containing all PMIDs of interest (one per line).
45 3 Robert Bossy
46 1 Robert Bossy
h3. All genes and taxa [section]
47 1 Robert Bossy
48 1 Robert Bossy
<pre>
49 1 Robert Bossy
layer:genes | layer:taxa
50 1 Robert Bossy
</pre>
51 1 Robert Bossy
52 1 Robert Bossy
or
53 1 Robert Bossy
54 1 Robert Bossy
<pre>
55 5 Robert Bossy
layer[@'ne-tpe' == "gene" or @'ne-type' == "species"]
56 1 Robert Bossy
</pre>
57 1 Robert Bossy
58 1 Robert Bossy
The first is faster. It assumes that all gene annotations are in a layer named _genes_, and that all taxon annotations are in a layer _taxa_. The annotations are given in the following order: first genes in standard order, then taxa in standard order.
59 1 Robert Bossy
60 1 Robert Bossy
The second assumes that annotations have a feature names _ne-type_ containing the named entity type of the annotation. The annotations are given in standard order regardless of the type.
61 1 Robert Bossy
62 1 Robert Bossy
h3. All words included in a sentence [annotation]
63 1 Robert Bossy
64 1 Robert Bossy
<pre>
65 1 Robert Bossy
inside:words
66 1 Robert Bossy
</pre>
67 1 Robert Bossy
68 1 Robert Bossy
This assumes that the context element is an annotation representing a sentence. It also assumes that all words are in a layer named _words_.
69 1 Robert Bossy
70 1 Robert Bossy
h3. All verbs [section]
71 1 Robert Bossy
72 1 Robert Bossy
<pre>
73 5 Robert Bossy
layer:words[@pos ^= "V"]
74 1 Robert Bossy
</pre>
75 1 Robert Bossy
76 1 Robert Bossy
or
77 1 Robert Bossy
78 1 Robert Bossy
<pre>
79 5 Robert Bossy
layer:words[@pos =~ "^V"]
80 1 Robert Bossy
</pre>
81 1 Robert Bossy
82 5 Robert Bossy
Both assume all word annotations are in a layer named _words_ and have a feature with key _pos_ whose value denote its POS.
83 1 Robert Bossy
84 1 Robert Bossy
h3. All syntactic dependencies [section]
85 1 Robert Bossy
86 1 Robert Bossy
<pre>
87 1 Robert Bossy
relations:dependencies.tuples
88 1 Robert Bossy
</pre>
89 1 Robert Bossy
90 1 Robert Bossy
This assumes syntactic dependencies are in a relation named _dependencies_.
91 1 Robert Bossy
92 1 Robert Bossy
h3. Words that are subject [section]
93 1 Robert Bossy
94 1 Robert Bossy
<pre>
95 5 Robert Bossy
relations:dependencies.tuples[@label == "SUBJ:V-N"].args:dependent
96 1 Robert Bossy
</pre>
97 1 Robert Bossy
98 1 Robert Bossy
If you insist to check they are subjet to verbs:
99 1 Robert Bossy
100 1 Robert Bossy
<pre>
101 5 Robert Bossy
relations:dependencies.tuples[@label == "SUBJ:V-N" and args:head.@pos ^= "V"].args:dependent
102 1 Robert Bossy
</pre>
103 1 Robert Bossy
104 1 Robert Bossy
h3. Subject of a verb [annotation]
105 1 Robert Bossy
106 1 Robert Bossy
<pre>
107 5 Robert Bossy
tuple:dependencies:head[@label == "SUBJ:V-N"].args:dependent
108 1 Robert Bossy
</pre>