ld4l-open_annotation_rdf 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -0
- data/lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb +9 -0
- data/lib/ld4l/open_annotation_rdf/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efbc3d8423150742b110eec287f640b819db3a7b
|
4
|
+
data.tar.gz: a99be5482b844af7b94a3853af03ea32c9cd8698
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a982ffbf744c568ab1aee9408d47174d1c6036f2ca1d07bbb89d99159af666339df383e3d67bd65db0f695240798c47cdb68bb24e474ddfd04935c7f5fe68434
|
7
|
+
data.tar.gz: 507a364ac06b47bd7a4bbcabb88787acf81b01d50e5ff9084e07ada148c82e10efe15d4e0b47e1706f1f9226b2f0f277a4a91b0ca9d1d4790401e0159d2bac64
|
data/README.md
CHANGED
@@ -122,42 +122,79 @@ puts stb.dump :ttl
|
|
122
122
|
<http://example.org/term/engineering> a <http://www.w3.org/ns/oa#SemanticTag> .
|
123
123
|
```
|
124
124
|
|
125
|
+
*Resume annotation of known type.*
|
126
|
+
This is the more efficient approach and should be used if the type of the annotation is known.
|
127
|
+
```
|
128
|
+
a1 = LD4L::OpenAnnotationRDF::CommentAnnotation.resume(RDF::URI('http://localhost/c10'))
|
129
|
+
# => #<LD4L::OpenAnnotationRDF::CommentAnnotation:0x3fdd8267adc8(default)>
|
130
|
+
comment = a1.getComment
|
131
|
+
# => "This book is a good resource on archery technique."
|
132
|
+
|
133
|
+
a2 = LD4L::OpenAnnotationRDF::TagAnnotation.resume(RDF::URI('http://localhost/t10'))
|
134
|
+
# => #<LD4L::OpenAnnotationRDF::TagAnnotation:0x3fdd826073f0(default)>
|
135
|
+
tag = a2.getTag
|
136
|
+
# => "archery"
|
137
|
+
|
138
|
+
a3 = LD4L::OpenAnnotationRDF::SemanticTagAnnotation.resume(RDF::URI('http://localhost/st10'))
|
139
|
+
# => #<LD4L::OpenAnnotationRDF::SemanticTagAnnotation:0x3fdd8259c7a8(default)>
|
140
|
+
term = a2.getTerm
|
141
|
+
# => #<RDF::URI:0x3fdbb4f37300 URI:http://example.org/term/engineering>
|
142
|
+
```
|
143
|
+
|
125
144
|
*Resume annotation of unknown type.*
|
126
145
|
```
|
127
146
|
## Using RDF::URI
|
128
147
|
# Create the annotations first using previous examples.
|
129
148
|
a1 = LD4L::OpenAnnotationRDF::Annotation.resume(RDF::URI('http://localhost/c10'))
|
130
149
|
# => #<LD4L::OpenAnnotationRDF::CommentAnnotation:0x3fdd8267adc8(default)>
|
150
|
+
comment = a1.getComment
|
151
|
+
# => "This book is a good resource on archery technique."
|
131
152
|
|
132
153
|
a2 = LD4L::OpenAnnotationRDF::Annotation.resume(RDF::URI('http://localhost/t10'))
|
133
154
|
# => #<LD4L::OpenAnnotationRDF::TagAnnotation:0x3fdd826073f0(default)>
|
155
|
+
tag = a2.getTag
|
156
|
+
# => "archery"
|
134
157
|
|
135
158
|
a3 = LD4L::OpenAnnotationRDF::Annotation.resume(RDF::URI('http://localhost/st10'))
|
136
159
|
# => #<LD4L::OpenAnnotationRDF::SemanticTagAnnotation:0x3fdd8259c7a8(default)>
|
160
|
+
term = a2.getTerm
|
161
|
+
# => #<RDF::URI:0x3fdbb4f37300 URI:http://example.org/term/engineering>
|
137
162
|
|
138
163
|
|
139
164
|
## Using string URI
|
140
165
|
# Create the annotations first using previous examples.
|
141
166
|
a1 = LD4L::OpenAnnotationRDF::Annotation.resume('http://localhost/c10')
|
142
167
|
# => #<LD4L::OpenAnnotationRDF::CommentAnnotation:0x3fdd8267adc8(default)>
|
168
|
+
# => #<LD4L::OpenAnnotationRDF::CommentAnnotation:0x3fdd8267adc8(default)>
|
169
|
+
comment = a1.getComment
|
143
170
|
|
144
171
|
a2 = LD4L::OpenAnnotationRDF::Annotation.resume('http://localhost/t10')
|
145
172
|
# => #<LD4L::OpenAnnotationRDF::TagAnnotation:0x3fdd826073f0(default)>
|
173
|
+
tag = a2.getTag
|
174
|
+
# => "archery"
|
146
175
|
|
147
176
|
a3 = LD4L::OpenAnnotationRDF::Annotation.resume('http://localhost/st10')
|
148
177
|
# => #<LD4L::OpenAnnotationRDF::SemanticTagAnnotation:0x3fdd8259c7a8(default)>
|
178
|
+
term = a2.getTerm
|
179
|
+
# => #<RDF::URI:0x3fdbb4f37300 URI:http://example.org/term/engineering>
|
149
180
|
|
150
181
|
|
151
182
|
## Using localname expanded using configured base_uri
|
152
183
|
# Create the annotations first using previous examples.
|
153
184
|
a1 = LD4L::OpenAnnotationRDF::Annotation.resume('c10')
|
154
185
|
# => #<LD4L::OpenAnnotationRDF::CommentAnnotation:0x3fdd8267adc8(default)>
|
186
|
+
comment = a1.getComment
|
187
|
+
# => "This book is a good resource on archery technique."
|
155
188
|
|
156
189
|
a2 = LD4L::OpenAnnotationRDF::Annotation.resume('t10')
|
157
190
|
# => #<LD4L::OpenAnnotationRDF::TagAnnotation:0x3fdd826073f0(default)>
|
191
|
+
tag = a2.getTag
|
192
|
+
# => "archery"
|
158
193
|
|
159
194
|
a3 = LD4L::OpenAnnotationRDF::Annotation.resume('st10')
|
160
195
|
# => #<LD4L::OpenAnnotationRDF::SemanticTagAnnotation:0x3fdd8259c7a8(default)>
|
196
|
+
term = a2.getTerm
|
197
|
+
# => #<RDF::URI:0x3fdbb4f37300 URI:http://example.org/term/engineering>
|
161
198
|
```
|
162
199
|
|
163
200
|
### Configurations
|
@@ -13,6 +13,15 @@ module LD4L
|
|
13
13
|
# TODO: Should a semantic tag be destroyed when the last annotation referencing the term is destroyed?
|
14
14
|
# TODO: What if other triples have been attached beyond the type?
|
15
15
|
|
16
|
+
##
|
17
|
+
# Get the term URI of the semantic tag body.
|
18
|
+
#
|
19
|
+
# @return the term URI
|
20
|
+
def getTerm
|
21
|
+
# return existing body if term is unchanged
|
22
|
+
@body ? @body.rdf_subject : nil
|
23
|
+
end
|
24
|
+
|
16
25
|
##
|
17
26
|
# Set the hasBody property to the URI of the controlled vocabulary term that is the annotation and
|
18
27
|
# create the semantic tag body instance identifying the term as a semantic tag annotation.
|