Element Expression Examples » History » Version 5
Robert Bossy, 09/19/2012 10:29 AM
1 | 4 | Robert Bossy | h1. Element Expression Examples |
---|---|---|---|
2 | 4 | Robert Bossy | |
3 | 1 | Robert Bossy | {{toc}} |
4 | 1 | Robert Bossy | |
5 | 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]]. |
6 | 1 | Robert Bossy | |
7 | 1 | Robert Bossy | h3. Sections in the corpus [corpus] |
8 | 1 | Robert Bossy | |
9 | 1 | Robert Bossy | <pre> |
10 | 1 | Robert Bossy | documents.sections |
11 | 1 | Robert Bossy | </pre> |
12 | 1 | Robert Bossy | |
13 | 1 | Robert Bossy | h3. Abstract sections [corpus] |
14 | 1 | Robert Bossy | |
15 | 1 | Robert Bossy | <pre> |
16 | 1 | Robert Bossy | documents.sections:abstract |
17 | 1 | Robert Bossy | </pre> |
18 | 1 | Robert Bossy | |
19 | 1 | Robert Bossy | or |
20 | 1 | Robert Bossy | |
21 | 1 | Robert Bossy | <pre> |
22 | 5 | Robert Bossy | documents.sections[@name == "abstract"] |
23 | 1 | Robert Bossy | </pre> |
24 | 1 | Robert Bossy | |
25 | 1 | Robert Bossy | First is faster. |
26 | 1 | Robert Bossy | |
27 | 1 | Robert Bossy | h3. Abstract sections in the test set [corpus] |
28 | 1 | Robert Bossy | |
29 | 1 | Robert Bossy | <pre> |
30 | 5 | Robert Bossy | documents[@set == "test"].sections:abstract |
31 | 1 | Robert Bossy | </pre> |
32 | 1 | Robert Bossy | |
33 | 1 | Robert Bossy | This assumes that documents have a feature with key _set_ that denote the set to which it pertains. |
34 | 1 | Robert Bossy | |
35 | 3 | Robert Bossy | h3. Documents whose PMID is in a file [corpus] |
36 | 3 | Robert Bossy | |
37 | 3 | Robert Bossy | <pre> |
38 | 5 | Robert Bossy | documents[@pmid in "good_pmids.txt"] |
39 | 3 | Robert Bossy | </pre> |
40 | 3 | Robert Bossy | |
41 | 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). |
42 | 3 | Robert Bossy | |
43 | 1 | Robert Bossy | h3. All genes and taxa [section] |
44 | 1 | Robert Bossy | |
45 | 1 | Robert Bossy | <pre> |
46 | 1 | Robert Bossy | layer:genes | layer:taxa |
47 | 1 | Robert Bossy | </pre> |
48 | 1 | Robert Bossy | |
49 | 1 | Robert Bossy | or |
50 | 1 | Robert Bossy | |
51 | 1 | Robert Bossy | <pre> |
52 | 5 | Robert Bossy | layer[@'ne-tpe' == "gene" or @'ne-type' == "species"] |
53 | 1 | Robert Bossy | </pre> |
54 | 1 | Robert Bossy | |
55 | 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. |
56 | 1 | Robert Bossy | |
57 | 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. |
58 | 1 | Robert Bossy | |
59 | 1 | Robert Bossy | h3. All words included in a sentence [annotation] |
60 | 1 | Robert Bossy | |
61 | 1 | Robert Bossy | <pre> |
62 | 1 | Robert Bossy | inside:words |
63 | 1 | Robert Bossy | </pre> |
64 | 1 | Robert Bossy | |
65 | 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_. |
66 | 1 | Robert Bossy | |
67 | 1 | Robert Bossy | h3. All verbs [section] |
68 | 1 | Robert Bossy | |
69 | 1 | Robert Bossy | <pre> |
70 | 5 | Robert Bossy | layer:words[@pos ^= "V"] |
71 | 1 | Robert Bossy | </pre> |
72 | 1 | Robert Bossy | |
73 | 1 | Robert Bossy | or |
74 | 1 | Robert Bossy | |
75 | 1 | Robert Bossy | <pre> |
76 | 5 | Robert Bossy | layer:words[@pos =~ "^V"] |
77 | 1 | Robert Bossy | </pre> |
78 | 1 | Robert Bossy | |
79 | 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. |
80 | 1 | Robert Bossy | |
81 | 1 | Robert Bossy | h3. All syntactic dependencies [section] |
82 | 1 | Robert Bossy | |
83 | 1 | Robert Bossy | <pre> |
84 | 1 | Robert Bossy | relations:dependencies.tuples |
85 | 1 | Robert Bossy | </pre> |
86 | 1 | Robert Bossy | |
87 | 1 | Robert Bossy | This assumes syntactic dependencies are in a relation named _dependencies_. |
88 | 1 | Robert Bossy | |
89 | 1 | Robert Bossy | h3. Words that are subject [section] |
90 | 1 | Robert Bossy | |
91 | 1 | Robert Bossy | <pre> |
92 | 5 | Robert Bossy | relations:dependencies.tuples[@label == "SUBJ:V-N"].args:dependent |
93 | 1 | Robert Bossy | </pre> |
94 | 1 | Robert Bossy | |
95 | 1 | Robert Bossy | If you insist to check they are subjet to verbs: |
96 | 1 | Robert Bossy | |
97 | 1 | Robert Bossy | <pre> |
98 | 5 | Robert Bossy | relations:dependencies.tuples[@label == "SUBJ:V-N" and args:head.@pos ^= "V"].args:dependent |
99 | 1 | Robert Bossy | </pre> |
100 | 1 | Robert Bossy | |
101 | 1 | Robert Bossy | h3. Subject of a verb [annotation] |
102 | 1 | Robert Bossy | |
103 | 1 | Robert Bossy | <pre> |
104 | 5 | Robert Bossy | tuple:dependencies:head[@label == "SUBJ:V-N"].args:dependent |
105 | 1 | Robert Bossy | </pre> |