-
Notifications
You must be signed in to change notification settings - Fork 1
/
annotation.go
54 lines (48 loc) · 1.27 KB
/
annotation.go
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
package main
import "encoding/json"
// Annotation struct
type Annotation struct {
Context string `json:"@context"`
Type string `json:"@type"`
ID string `json:"@id"`
Motivation []string `json:"motivation"`
On []struct {
Type string `json:"@type"`
Full string `json:"full"`
Selector struct {
Type string `json:"@type"`
Default struct {
Type string `json:"@type"`
Value string `json:"value"`
} `json:"default"`
Item struct {
Type string `json:"@type"`
Value string `json:"value"`
} `json:"item"`
} `json:"selector"`
Within struct {
ID string `json:"@id"`
Type string `json:"@type"`
} `json:"within"`
} `json:"on"`
Resource []struct {
Type string `json:"@type"`
Chars string `json:"chars"`
Format string `json:"format"`
} `json:"resource"`
}
// Manifest of the annotation
func (a *Annotation) Manifest() string {
return a.On[0].Within.ID
}
// Canvas of the annotation
func (a *Annotation) Canvas() string {
return a.On[0].Full
}
// AnnotationList is a list of annotation
type AnnotationList struct {
Context string `json:"@context"`
ID string `json:"@id"`
Type string `json:"@type"`
Resources []json.RawMessage `json:"resources"`
}