-
Notifications
You must be signed in to change notification settings - Fork 2
/
model.uml
323 lines (284 loc) · 8.88 KB
/
model.uml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
@startuml
hide stereotype
skinparam class {
BackgroundColor Linen
ArrowColor Black
BorderColor Navy
BackgroundColor<<functional>> LightSteelBlue
}
skinparam groupInheritance 2
title "STAM: Stand-off Text Annotation Model -- Extended Model"
class TextResource {
--
id : str
text: str
--
_id : int
_index: [TextSelection*]
--
<i>Holds the text</i>
<i>(and the reverse index)</i>
}
class TextSelection <<functional>> {
offset: (begin: int, end: int)
--
_referenced_by: [&Annotation+]
_part_of: [&TextResource]
_id : int
--
<i>Links text positions to annotations</i>
<i>Used by the reverse index</i>
<i>(not serialised)</i>
}
class AnnotationStore {
id: str?
annotations: [Annotation*]
datasets: [AnnotationDataSet*]
resources: [TextResource*]
--
<i>Holds the full annotation graph model</i>
<i>(entry-point)</i>
}
class AnnotationDataSet {
id: str?
keys: [DataKey*]
data: [AnnotationData*]
--
_id: int
--
<i>An annotation dataset holds</i>
<i>the actual data associated with annotations</i>
<i>and defines the vocabulary (the keys), it does</i>
<i>not hold the annotations themselves</i>
}
class Annotation {
id: str?
data: [&AnnotationData+]
target: Selector
--
_id : int
_referenced_by: [&Annotation*]
--
<i>An instance of an annotation</i>
<i>Core concept, i.e. nodes in the graph,
<i>binds everything together</i>
}
abstract class Selector {
--
<i>Selects the target</i>
<i>(or source) of annotation</i>
}
class TextSelector {
resource: &TextResource,
offsets: (begin: Cursor, end: Cursor)
--
_textselection: &TextSelection?
--
<i>Selects a single part of the text,</i>
<i>Offsets are unicode codepoints relative</i>
<i>to the text, zero-indexed, </i>
<i>end is non-inclusive,</i>
}
class ResourceSelector {
resource: &TextResource
---
<i>Selects a resource as a whole</i>
<i>(i.e. annotation is metadata)</i>
}
class DataSetSelector {
annotationset: &AnnotationDataSet
--
<i>Selects an annotation data set as</i>
<i>a whole (i.e. annotation is metadata)</i>
}
class DataKeySelector {
annotationset: &AnnotationDataSet
key: &DataKey
--
<i>Selects a data key</i>
<i>(i.e. annotation is metadata)</i>
}
class AnnotationDataSelector {
annotationset: &AnnotationDataSet
data: &AnnotationData
--
<i>Selects annotation data</i>
<i>(i.e. annotation is metadata)</i>
}
class AnnotationSelector {
annotation: &Annotation
offsets: (begin: Cursor, end: Cursor)?
--
_textselection: &TextSelection?
--
<i>Selects an annotation. May optionally</i>
<i>select a only part of the annotation's target</i>
<i>Offsets are relative</i>
<i>to the targeted annotation, </i>
<i>end is non-inclusive.</i>
}
class MultiSelector {
selectors: [Selector++]
--
<i>Combines selectors</i>
<i>The annotation applies</i>
<i>to each target individually</i>
<i>and independently.</i>
}
class CompositeSelector {
selectors: [Selector++]
--
<i>Combines selectors</i>
<i>The annotation applies</i>
<i>to all targets combined,</i>
<i>they are inter-dependant.</i>
}
class DirectionalSelector {
selectors: [Selector++]
--
<i>Expresses a direction between two or more selectors,</i>
<i>in the exact order specified (from -> to)</i>
<i>The annotation applies to all targets</i>
<i>combined, they are inter-dependant.</i>
}
class RangedInternalSelector <<functional>> {
begin: Selector,
end: Selector,
--
<i>Internal selector to select whole ranges</i>
<i>by internal ID. Allows for more compact</i>
<i>representation in memory. Used under</i>
<i>DirectonalSelector/CompositeSelector/MultiSelector.</i>
<i>(not serialised)</i>
}
Selector <|-[#green]- TextSelector
Selector <|-[#green]- ResourceSelector
Selector <|-[#green]- DataSetSelector
Selector <|-[#green]- DataKeySelector
Selector <|-[#green]- AnnotationDataSelector
Selector <|-[#green]- AnnotationSelector
Selector <|-[#green]- MultiSelector
Selector <|-[#green]- CompositeSelector
Selector <|-[#green]- DirectionalSelector
Selector <|.[#green]. RangedInternalSelector
class AnnotationData {
id: str?
key: &DataKey
value: DataValue
--
_id : int
_data_for: [&Annotation*]
_referenced_by: [&Annotation*]
_part_of_set: &AnnotationDataSet
--
<i>The value of the annotation</i>
}
class DataKey {
id: str
indexed: bool
--
_id: int
_key_for: [&AnnotationData*]
_referenced_by: [&Annotation*]
_part_of_set: &AnnotationDataSet
--
<i>The key of an annotation</i>
}
enum DataValue {
Null
String(value: str)
Bool(value: bool)
Int(value: int)
Float(value: float)
Datetime(value: datetime)
List(value: [DataValue])
--
<i>Encapsulates a data value</i>
<i>along with its type</i>
}
' There is no Map() in DataValue, a Map should be expressed as an Annotation on an Annotation
enum Cursor {
BeginAlignedCursor(value: int)
EndAlignedCursor(value: int)
--
<i>Used to select offsets</i>
<i>Units are unicode codepoints,</i>
<i>(not bytes!), zero-indexed</i>
}
enum TextSelectionOperator <<functional>> {
Equals(other: TextSelection)
Precedes(other: TextSelection, mindistance: int?, maxdistance: int?)
StartsBefore(other: TextSelection, mindistance: int?, maxdistance: int?)
Succeeds(other: TextSelection, mindistance: int?, maxdistance: int?)
EndsBefore(other: TextSelection, mindistance: int?, maxdistance: int?)
Near(other: TextSelection, mindistance: int?, maxdistance: int?)
Overlaps(other: TextSelection)
Embeds(other: TextSelection)
Before(other: TextSelection,spacing: bool, punct: bool)
After(other: TextSelection,spacing: bool, punct: bool)
SameBegin(other: TextSelection)
SameEnd(other: TextSelection)
SameRange(other: TextSelection)
Not(TextSelectionOperator)
And([TextSelectionOperator++])
Or([TextSelectionOperator++])
--
<i>Operators to compare text selections</i>
}
enum DataOperator <<functional>> {
Equals(other: DataValue)
GreaterThan(other: DataValue)
LessThan(other: DataValue)
GreaterThanOrEqual(other: DataValue)
LessThanOrEqual(other: DataValue)
HasElement(other: DataValue)
HasElement(key: DataValue)
And([DataOperator++])
Or([DataOperator++])
Not(DataOperator)
--
<i>Operators to test the value of</i>
<i>annotation data (DataValue)</i>
}
AnnotationStore "1" *--> "*" AnnotationDataSet : > datasets
AnnotationStore "1" *--> "*" TextResource : > resources
AnnotationStore "1" *--> "*" Annotation : > annotations
AnnotationDataSet "1" *--> "*" AnnotationData : > data
AnnotationDataSet "1" *--> "*" DataKey : > keys
Annotation "1" *--> "+" Selector : > target
Annotation "1" o-[#red]-> "*" AnnotationData : > data
Annotation "1" o.[#red].> "*" Annotation : > _referenced_by
AnnotationData "1" o.[#red].> "+" Annotation : > _data_for
AnnotationData "1" o.[#red].> "+" Annotation : > _referenced_by
AnnotationData "1" *--> "1" DataValue : > value
AnnotationData "1" *-[#red]-> "1" DataKey : > key
AnnotationData "1" o.[#red].> "1" AnnotationDataSet : > _part_of_set
TextSelector "1" o-[#red]-> "1" TextResource : > resource
TextSelector "1" o.[#red].> "1" TextSelection : > _textselection
AnnotationSelector "1" o.[#red].> "1" TextSelection : > _textselection
ResourceSelector "1" o-[#red]-> "1" TextResource : > resource
AnnotationSelector "1" o-[#red]-> "1" Annotation : > annotation
DataSetSelector "1" o-[#red]-> "1" AnnotationDataSet : > annotationset
DataKeySelector "1" o-[#red]-> "1" AnnotationDataSet : > annotationset
DataKeySelector "1" o-[#red]-> "1" DataKey : > key
AnnotationDataSelector "1" o-[#red]-> "1" AnnotationDataSet : > annotationset
AnnotationDataSelector "1" o-[#red]-> "1" AnnotationData : > data
DataKey "1" o.[#red].> "+" AnnotationData : > _key_for
DataKey "1" o.[#red].> "+" AnnotationData : > _referenced_by
DataKey "1" o.[#red].> "1" AnnotationDataSet : > _part_of_set
MultiSelector "1" --> "*" Selector : > selectors
CompositeSelector "1" --> "*" Selector : > selectors
DirectionalSelector "1" --> "*" Selector : > selectors
RangedInternalSelector "1" --> "1" Selector : > begin/end
TextSelector "1" --> "2" Cursor : > offsets
AnnotationSelector "1" --> "2" Cursor : > offsets
TextResource "1" *..> "*" TextSelection : > _index
TextSelection "1" o.[#red].> "*" Annotation : > _referenced_by
TextSelection "1" o.[#red].> "*" TextResource : > _part_of
TextSelectionOperator *..> TextSelection : > other
TextSelectionOperator .[#blue].> TextSelection : > <<applied to>>
TextSelectionOperator *..> TextSelectionOperator : > Not/And/Or
DataOperator .[#blue].> DataValue : > <<applied to>>
DataOperator *..> DataValue : > other
DataOperator *..> DataOperator : > Not/And/Or
@enduml