pho 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +17 -0
- data/Rakefile +10 -2
- data/bin/talis_store +37 -92
- data/doc/rdoc/classes/Pho.html +11 -0
- data/doc/rdoc/classes/Pho/CommandLine.html +508 -0
- data/doc/rdoc/classes/Pho/DatatypeProperty.html +15 -15
- data/doc/rdoc/classes/Pho/Enrichment.html +1 -1
- data/doc/rdoc/classes/Pho/Enrichment/{ResourceEnricher.html → StoreEnricher.html} +158 -58
- data/doc/rdoc/classes/Pho/Etags.html +36 -36
- data/doc/rdoc/classes/Pho/Facet/Results.html +19 -19
- data/doc/rdoc/classes/Pho/Facet/Term.html +6 -6
- data/doc/rdoc/classes/Pho/FieldPredicateMap.html +94 -94
- data/doc/rdoc/classes/Pho/FieldWeighting.html +14 -14
- data/doc/rdoc/classes/Pho/FileManagement/AbstractFileManager.html +126 -91
- data/doc/rdoc/classes/Pho/FileManagement/FileManager.html +68 -62
- data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +22 -57
- data/doc/rdoc/classes/Pho/Job.html +68 -67
- data/doc/rdoc/classes/Pho/Jobs.html +62 -62
- data/doc/rdoc/classes/Pho/QueryProfile.html +64 -64
- data/doc/rdoc/classes/Pho/RDF.html +120 -0
- data/doc/rdoc/classes/Pho/RDF/Parser.html +277 -0
- data/doc/rdoc/classes/Pho/ResourceHash.html +1 -1
- data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +48 -46
- data/doc/rdoc/classes/Pho/ResourceHash/SetAlgebra.html +15 -14
- data/doc/rdoc/classes/Pho/Snapshot.html +36 -36
- data/doc/rdoc/classes/Pho/Sparql.html +50 -0
- data/doc/rdoc/classes/Pho/Sparql/SparqlClient.html +147 -68
- data/doc/rdoc/classes/Pho/Sparql/SparqlHelper.html +195 -114
- data/doc/rdoc/classes/Pho/Status.html +26 -26
- data/doc/rdoc/classes/Pho/Store.html +271 -264
- data/doc/rdoc/classes/Pho/StoreSparqlClient.html +183 -0
- data/doc/rdoc/classes/Pho/Update.html +1 -0
- data/doc/rdoc/classes/Pho/Update/Changeset.html +69 -68
- data/doc/rdoc/classes/Pho/Update/ChangesetBuilder.html +24 -24
- data/doc/rdoc/classes/Pho/Update/Changesets.html +15 -14
- data/doc/rdoc/classes/Pho/Update/LiteralStatement.html +18 -18
- data/doc/rdoc/classes/Pho/Update/ResourceStatement.html +24 -24
- data/doc/rdoc/classes/Pho/Update/Statement.html +28 -27
- data/doc/rdoc/classes/String.html +1 -1
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/CHANGES.html +53 -1
- data/doc/rdoc/files/lib/pho/changeset_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/command_line_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/converter_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/enrichment_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/file_management_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/file_manager_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/rdf_collection_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/rdf_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/sparql_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/store_rb.html +8 -1
- data/doc/rdoc/files/lib/pho_rb.html +4 -2
- data/doc/rdoc/fr_class_index.html +6 -1
- data/doc/rdoc/fr_file_index.html +2 -0
- data/doc/rdoc/fr_method_index.html +192 -172
- data/examples/calais/bio.txt +7 -0
- data/examples/calais/dump.rb +17 -0
- data/examples/calais/enlighten.rb +23 -0
- data/examples/calais/output.rdf +25 -0
- data/examples/sinatra/viewer.rb +20 -0
- data/lib/pho.rb +4 -1
- data/lib/pho/changeset.rb +17 -1
- data/lib/pho/command_line.rb +166 -0
- data/lib/pho/converter.rb +8 -3
- data/lib/pho/enrichment.rb +93 -28
- data/lib/pho/file_management.rb +32 -19
- data/lib/pho/file_manager.rb +22 -26
- data/lib/pho/rdf.rb +74 -0
- data/lib/pho/rdf_collection.rb +2 -17
- data/lib/pho/sparql.rb +150 -38
- data/lib/pho/store.rb +28 -2
- data/tests/tc_contentbox.rb +41 -0
- data/tests/tc_enrichment.rb +41 -4
- data/tests/tc_file_manager.rb +97 -7
- data/tests/tc_rdf_collection.rb +25 -13
- data/tests/tc_rdf_parser.rb +37 -0
- data/tests/tc_sparql.rb +72 -2
- data/tests/tc_sparql_helper.rb +16 -0
- data/tests/ts_pho.rb +2 -1
- metadata +20 -3
@@ -92,8 +92,8 @@ Captures information about a mapped datatype from a Field Predicate Map
|
|
92
92
|
<h3 class="section-bar">Methods</h3>
|
93
93
|
|
94
94
|
<div class="name-list">
|
95
|
-
<a href="#
|
96
|
-
<a href="#
|
95
|
+
<a href="#M000138">new</a>
|
96
|
+
<a href="#M000139">to_rdf</a>
|
97
97
|
</div>
|
98
98
|
</div>
|
99
99
|
|
@@ -133,7 +133,7 @@ Short name for the property
|
|
133
133
|
<td class="context-item-name">property_uri</td>
|
134
134
|
<td class="context-item-value"> [R] </td>
|
135
135
|
<td class="context-item-desc">
|
136
|
-
RDF predicate URI for the mapped property
|
136
|
+
<a href="RDF.html">RDF</a> predicate URI for the mapped property
|
137
137
|
|
138
138
|
</td>
|
139
139
|
</tr>
|
@@ -155,19 +155,19 @@ URI for this mapping
|
|
155
155
|
<div id="methods">
|
156
156
|
<h3 class="section-bar">Public Class methods</h3>
|
157
157
|
|
158
|
-
<div id="method-
|
159
|
-
<a name="
|
158
|
+
<div id="method-M000138" class="method-detail">
|
159
|
+
<a name="M000138"></a>
|
160
160
|
|
161
161
|
<div class="method-heading">
|
162
|
-
<a href="#
|
162
|
+
<a href="#M000138" class="method-signature">
|
163
163
|
<span class="method-name">new</span><span class="method-args">(uri, property_uri, name, analyzer=nil)</span>
|
164
164
|
</a>
|
165
165
|
</div>
|
166
166
|
|
167
167
|
<div class="method-description">
|
168
168
|
<p><a class="source-toggle" href="#"
|
169
|
-
onclick="toggleCode('
|
170
|
-
<div class="method-source-code" id="
|
169
|
+
onclick="toggleCode('M000138-source');return false;">[Source]</a></p>
|
170
|
+
<div class="method-source-code" id="M000138-source">
|
171
171
|
<pre>
|
172
172
|
<span class="ruby-comment cmt"># File lib/pho/field_predicate_map.rb, line 64</span>
|
173
173
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">property_uri</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">analyzer</span>=<span class="ruby-keyword kw">nil</span>)
|
@@ -183,19 +183,19 @@ URI for this mapping
|
|
183
183
|
|
184
184
|
<h3 class="section-bar">Public Instance methods</h3>
|
185
185
|
|
186
|
-
<div id="method-
|
187
|
-
<a name="
|
186
|
+
<div id="method-M000139" class="method-detail">
|
187
|
+
<a name="M000139"></a>
|
188
188
|
|
189
189
|
<div class="method-heading">
|
190
|
-
<a href="#
|
190
|
+
<a href="#M000139" class="method-signature">
|
191
191
|
<span class="method-name">to_rdf</span><span class="method-args">(ns=true)</span>
|
192
192
|
</a>
|
193
193
|
</div>
|
194
194
|
|
195
195
|
<div class="method-description">
|
196
196
|
<p>
|
197
|
-
Convert this object into an RDF representation.
|
198
|
-
rdf:Description, optionally including namespaces
|
197
|
+
Convert this object into an <a href="RDF.html">RDF</a> representation.
|
198
|
+
Generates a simple rdf:Description, optionally including namespaces
|
199
199
|
</p>
|
200
200
|
<table>
|
201
201
|
<tr><td valign="top">ns:</td><td>include namespace declarations
|
@@ -203,8 +203,8 @@ rdf:Description, optionally including namespaces
|
|
203
203
|
</td></tr>
|
204
204
|
</table>
|
205
205
|
<p><a class="source-toggle" href="#"
|
206
|
-
onclick="toggleCode('
|
207
|
-
<div class="method-source-code" id="
|
206
|
+
onclick="toggleCode('M000139-source');return false;">[Source]</a></p>
|
207
|
+
<div class="method-source-code" id="M000139-source">
|
208
208
|
<pre>
|
209
209
|
<span class="ruby-comment cmt"># File lib/pho/field_predicate_map.rb, line 73</span>
|
210
210
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_rdf</span>(<span class="ruby-identifier">ns</span>=<span class="ruby-keyword kw">true</span>)
|
@@ -95,7 +95,7 @@ endpoints and services
|
|
95
95
|
<div id="class-list">
|
96
96
|
<h3 class="section-bar">Classes and Modules</h3>
|
97
97
|
|
98
|
-
Class <a href="Enrichment/
|
98
|
+
Class <a href="Enrichment/StoreEnricher.html" class="link">Pho::Enrichment::StoreEnricher</a><br />
|
99
99
|
|
100
100
|
</div>
|
101
101
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
7
|
<head>
|
8
|
-
<title>Class: Pho::Enrichment::
|
8
|
+
<title>Class: Pho::Enrichment::StoreEnricher</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
11
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
@@ -50,7 +50,7 @@
|
|
50
50
|
<table class="header-table">
|
51
51
|
<tr class="top-aligned-row">
|
52
52
|
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Pho::Enrichment::
|
53
|
+
<td class="class-name-in-header">Pho::Enrichment::StoreEnricher</td>
|
54
54
|
</tr>
|
55
55
|
<tr class="top-aligned-row">
|
56
56
|
<td><strong>In:</strong></td>
|
@@ -86,10 +86,10 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
90
|
-
<a href="#
|
91
|
-
<a href="#
|
92
|
-
<a href="#
|
89
|
+
<a href="#M000075">enrich</a>
|
90
|
+
<a href="#M000073">infer</a>
|
91
|
+
<a href="#M000074">merge</a>
|
92
|
+
<a href="#M000072">new</a>
|
93
93
|
</div>
|
94
94
|
</div>
|
95
95
|
|
@@ -129,12 +129,12 @@
|
|
129
129
|
<div id="methods">
|
130
130
|
<h3 class="section-bar">Public Class methods</h3>
|
131
131
|
|
132
|
-
<div id="method-
|
133
|
-
<a name="
|
132
|
+
<div id="method-M000073" class="method-detail">
|
133
|
+
<a name="M000073"></a>
|
134
134
|
|
135
135
|
<div class="method-heading">
|
136
|
-
<a href="#
|
137
|
-
<span class="method-name">infer</span><span class="method-args">(store, query)</span>
|
136
|
+
<a href="#M000073" class="method-signature">
|
137
|
+
<span class="method-name">infer</span><span class="method-args">(store, query, &block)</span>
|
138
138
|
</a>
|
139
139
|
</div>
|
140
140
|
|
@@ -144,32 +144,38 @@ Enrich a store against itself
|
|
144
144
|
</p>
|
145
145
|
<p>
|
146
146
|
For the common case where a store needs to be enriched against itself by
|
147
|
-
inferring <a href="
|
148
|
-
|
147
|
+
inferring <a href="StoreEnricher.html#M000072">new</a> data from old using
|
148
|
+
a CONSTRUCT query
|
149
149
|
</p>
|
150
|
-
<
|
151
|
-
store
|
152
|
-
|
153
|
-
</
|
150
|
+
<table>
|
151
|
+
<tr><td valign="top">store:</td><td>the store to be updated
|
152
|
+
|
153
|
+
</td></tr>
|
154
|
+
<tr><td valign="top">query:</td><td>the SPARQL CONSTRUCT query to be used to <a
|
155
|
+
href="StoreEnricher.html#M000073">infer</a> the <a
|
156
|
+
href="StoreEnricher.html#M000072">new</a> data
|
157
|
+
|
158
|
+
</td></tr>
|
159
|
+
</table>
|
154
160
|
<p><a class="source-toggle" href="#"
|
155
|
-
onclick="toggleCode('
|
156
|
-
<div class="method-source-code" id="
|
161
|
+
onclick="toggleCode('M000073-source');return false;">[Source]</a></p>
|
162
|
+
<div class="method-source-code" id="M000073-source">
|
157
163
|
<pre>
|
158
|
-
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line
|
159
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">
|
160
|
-
<span class="ruby-identifier">enricher</span> = <span class="ruby-constant">
|
161
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">enricher</span>.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">query</span> )
|
164
|
+
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 28</span>
|
165
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">StoreEnricher</span>.<span class="ruby-identifier">infer</span>(<span class="ruby-identifier">store</span>, <span class="ruby-identifier">query</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
166
|
+
<span class="ruby-identifier">enricher</span> = <span class="ruby-constant">StoreEnricher</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">store</span>, <span class="ruby-identifier">store</span>.<span class="ruby-identifier">sparql_client</span>() )
|
167
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">enricher</span>.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">query</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
162
168
|
<span class="ruby-keyword kw">end</span>
|
163
169
|
</pre>
|
164
170
|
</div>
|
165
171
|
</div>
|
166
172
|
</div>
|
167
173
|
|
168
|
-
<div id="method-
|
169
|
-
<a name="
|
174
|
+
<div id="method-M000072" class="method-detail">
|
175
|
+
<a name="M000072"></a>
|
170
176
|
|
171
177
|
<div class="method-heading">
|
172
|
-
<a href="#
|
178
|
+
<a href="#M000072" class="method-signature">
|
173
179
|
<span class="method-name">new</span><span class="method-args">(store, sparql_client)</span>
|
174
180
|
</a>
|
175
181
|
</div>
|
@@ -178,15 +184,20 @@ using a CONSTRUCT query
|
|
178
184
|
<p>
|
179
185
|
Constructor
|
180
186
|
</p>
|
181
|
-
<
|
182
|
-
store
|
183
|
-
|
184
|
-
|
187
|
+
<table>
|
188
|
+
<tr><td valign="top">store:</td><td>the store containing resource(s) to <a
|
189
|
+
href="StoreEnricher.html#M000075">enrich</a>
|
190
|
+
|
191
|
+
</td></tr>
|
192
|
+
<tr><td valign="top">sparql_client:</td><td>SparqlClient object to be used as client for retrieving enrichments
|
193
|
+
|
194
|
+
</td></tr>
|
195
|
+
</table>
|
185
196
|
<p><a class="source-toggle" href="#"
|
186
|
-
onclick="toggleCode('
|
187
|
-
<div class="method-source-code" id="
|
197
|
+
onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
|
198
|
+
<div class="method-source-code" id="M000072-source">
|
188
199
|
<pre>
|
189
|
-
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line
|
200
|
+
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 16</span>
|
190
201
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">store</span>, <span class="ruby-identifier">sparql_client</span>)
|
191
202
|
<span class="ruby-ivar">@store</span> = <span class="ruby-identifier">store</span>
|
192
203
|
<span class="ruby-ivar">@sparql_client</span> = <span class="ruby-identifier">sparql_client</span>
|
@@ -198,12 +209,12 @@ Constructor
|
|
198
209
|
|
199
210
|
<h3 class="section-bar">Public Instance methods</h3>
|
200
211
|
|
201
|
-
<div id="method-
|
202
|
-
<a name="
|
212
|
+
<div id="method-M000075" class="method-detail">
|
213
|
+
<a name="M000075"></a>
|
203
214
|
|
204
215
|
<div class="method-heading">
|
205
|
-
<a href="#
|
206
|
-
<span class="method-name">enrich</span><span class="method-args">(locator_query, enrichment_query)</span>
|
216
|
+
<a href="#M000075" class="method-signature">
|
217
|
+
<span class="method-name">enrich</span><span class="method-args">(locator_query, enrichment_query, callback=nil) {|:query, query_response| ...}</span>
|
207
218
|
</a>
|
208
219
|
</div>
|
209
220
|
|
@@ -231,28 +242,110 @@ of the query to the metabox. <a href="../Enrichment.html">Enrichment</a>
|
|
231
242
|
queries should therefore be CONSTRUCT or DESCRIBE queries. The SPARQL
|
232
243
|
protocol request will be sent with an Accept header of application/rdf+xml
|
233
244
|
</p>
|
245
|
+
<p>
|
246
|
+
The method supports a callback object that can be provided as an optional
|
247
|
+
parameter to the query. If provided then then object should respond to
|
248
|
+
either or both of the following methods:
|
249
|
+
</p>
|
250
|
+
<pre>
|
251
|
+
pre_process(rdf_xml)
|
252
|
+
post_process(resp, rdf_xml)
|
253
|
+
</pre>
|
254
|
+
<p>
|
255
|
+
The first of these is invoked after each enrichment query has been executed
|
256
|
+
on the configured SPARQL endpoint. It is intended to support additional
|
257
|
+
filtering or annotation. If the <tt>pre_process</tt> method returns nil,
|
258
|
+
then no data will be written to the store, otherwise the return value is
|
259
|
+
substituted instead of the original value.
|
260
|
+
</p>
|
261
|
+
<p>
|
262
|
+
The second callback method, <tt>post_process</tt> is called after data has
|
263
|
+
been written to the store and provides access to the response from the
|
264
|
+
store, and the <a href="../RDF.html">RDF</a>/XML data that had been
|
265
|
+
attempted to be stored. As the request may have been un-successful, code
|
266
|
+
should check the status on the HTTPMessage parameter.
|
267
|
+
</p>
|
234
268
|
<pre>
|
235
|
-
|
236
|
-
|
269
|
+
class MyCallback
|
270
|
+
def pre_process(rdf)
|
271
|
+
if !should_store?(rdf)
|
272
|
+
return nil
|
273
|
+
end
|
274
|
+
return rdf
|
275
|
+
end
|
276
|
+
def post_process(resp, rdf)
|
277
|
+
puts "Store returned #{resp.status} when storing: #{rdf}"
|
278
|
+
end
|
279
|
+
end
|
280
|
+
callback = MyCallback.new()
|
281
|
+
enricher.enrich("SELECT ?item WHERE { ?item a ex:Class } LIMIT 10", "DESCRIBE ?item", callback)
|
282
|
+
</pre>
|
283
|
+
<p>
|
284
|
+
The callback support is primarily intended to support filtering and
|
285
|
+
notification of activities. For simple logging purposes, the method also
|
286
|
+
supports a block parameter. This is invoked after each enrichment query,
|
287
|
+
and each store response. The block can receive two values: the first is a
|
288
|
+
symbol (either +:query+ or +:store+) indicating the source of the response,
|
289
|
+
and the response object itself. E.g:
|
290
|
+
</p>
|
291
|
+
<pre>
|
292
|
+
enricher.enrich("SELECT ?item WHERE { ?item a ex:Class } LIMIT 10", "DESCRIBE ?item") do |source, resp|
|
293
|
+
if source == :query
|
294
|
+
puts "Enrichment query returned #{resp.status}"
|
295
|
+
else
|
296
|
+
puts "Store returned #{resp.status} when storing data"
|
297
|
+
end
|
298
|
+
end
|
237
299
|
</pre>
|
300
|
+
<table>
|
301
|
+
<tr><td valign="top">locator_query:</td><td>query to locate resources to be enriched
|
302
|
+
|
303
|
+
</td></tr>
|
304
|
+
<tr><td valign="top">enrichment_query:</td><td>query to be used to <a href="StoreEnricher.html#M000075">enrich</a> the
|
305
|
+
resource
|
306
|
+
|
307
|
+
</td></tr>
|
308
|
+
<tr><td valign="top">callback:</td><td>optional callback object
|
309
|
+
|
310
|
+
</td></tr>
|
311
|
+
</table>
|
238
312
|
<p><a class="source-toggle" href="#"
|
239
|
-
onclick="toggleCode('
|
240
|
-
<div class="method-source-code" id="
|
313
|
+
onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
|
314
|
+
<div class="method-source-code" id="M000075-source">
|
241
315
|
<pre>
|
242
|
-
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line
|
243
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enrich</span>(<span class="ruby-identifier">locator_query</span>, <span class="ruby-identifier">enrichment_query</span>)
|
316
|
+
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 108</span>
|
317
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enrich</span>(<span class="ruby-identifier">locator_query</span>, <span class="ruby-identifier">enrichment_query</span>, <span class="ruby-identifier">callback</span>=<span class="ruby-keyword kw">nil</span>)
|
244
318
|
<span class="ruby-identifier">results</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Sparql</span><span class="ruby-operator">::</span><span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">select</span>(<span class="ruby-identifier">locator_query</span>, <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">sparql_client</span>() )
|
245
319
|
<span class="ruby-identifier">bindings</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Sparql</span><span class="ruby-operator">::</span><span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">results_to_query_bindings</span>(<span class="ruby-identifier">results</span>)
|
246
320
|
<span class="ruby-identifier">bindings</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">binding</span><span class="ruby-operator">|</span>
|
247
321
|
<span class="ruby-identifier">bound_query</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Sparql</span><span class="ruby-operator">::</span><span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">apply_initial_bindings</span>(<span class="ruby-identifier">enrichment_query</span>, <span class="ruby-identifier">binding</span>)
|
248
322
|
|
249
|
-
<span class="ruby-
|
323
|
+
<span class="ruby-comment cmt">#TODO counting numbers of requests and responses?</span>
|
324
|
+
<span class="ruby-identifier">query_response</span> = <span class="ruby-ivar">@sparql_client</span>.<span class="ruby-identifier">query</span>(<span class="ruby-identifier">bound_query</span>, <span class="ruby-value str">"application/rdf+xml"</span>)
|
250
325
|
|
251
|
-
<span class="ruby-
|
252
|
-
|
253
|
-
|
254
|
-
<span class="ruby-keyword kw">end</span>
|
326
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
327
|
+
<span class="ruby-keyword kw">yield</span> <span class="ruby-operator">:</span><span class="ruby-identifier">query</span>, <span class="ruby-identifier">query_response</span>
|
328
|
+
<span class="ruby-keyword kw">end</span>
|
255
329
|
|
330
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">query_response</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value">200</span>
|
331
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">query_response</span>.<span class="ruby-identifier">content</span>
|
332
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">callback</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:pre_process</span>)
|
333
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">pre_process</span>(<span class="ruby-identifier">result</span>)
|
334
|
+
<span class="ruby-keyword kw">end</span>
|
335
|
+
|
336
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
337
|
+
<span class="ruby-identifier">store_response</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">store_data</span>( <span class="ruby-identifier">result</span> )
|
338
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">callback</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:post_process</span>)
|
339
|
+
<span class="ruby-identifier">callback</span>.<span class="ruby-identifier">post_process</span>(<span class="ruby-identifier">store_response</span>, <span class="ruby-identifier">result</span>)
|
340
|
+
<span class="ruby-keyword kw">end</span>
|
341
|
+
|
342
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
343
|
+
<span class="ruby-keyword kw">yield</span> <span class="ruby-operator">:</span><span class="ruby-identifier">store</span>, <span class="ruby-identifier">store_response</span>
|
344
|
+
<span class="ruby-keyword kw">end</span>
|
345
|
+
<span class="ruby-keyword kw">end</span>
|
346
|
+
|
347
|
+
<span class="ruby-keyword kw">end</span>
|
348
|
+
<span class="ruby-comment cmt">#end each binding</span>
|
256
349
|
<span class="ruby-keyword kw">end</span>
|
257
350
|
<span class="ruby-keyword kw">end</span>
|
258
351
|
</pre>
|
@@ -260,12 +353,12 @@ protocol request will be sent with an Accept header of application/rdf+xml
|
|
260
353
|
</div>
|
261
354
|
</div>
|
262
355
|
|
263
|
-
<div id="method-
|
264
|
-
<a name="
|
356
|
+
<div id="method-M000074" class="method-detail">
|
357
|
+
<a name="M000074"></a>
|
265
358
|
|
266
359
|
<div class="method-heading">
|
267
|
-
<a href="#
|
268
|
-
<span class="method-name">merge</span><span class="method-args">(query)</span>
|
360
|
+
<a href="#M000074" class="method-signature">
|
361
|
+
<span class="method-name">merge</span><span class="method-args">(query) {|resp, data| ...}</span>
|
269
362
|
</a>
|
270
363
|
</div>
|
271
364
|
|
@@ -274,20 +367,27 @@ protocol request will be sent with an Accept header of application/rdf+xml
|
|
274
367
|
Execute the provided query against the configured SPARQL endpoint and store
|
275
368
|
the results in the Platform <a href="../Store.html">Store</a>
|
276
369
|
</p>
|
277
|
-
<
|
278
|
-
query
|
279
|
-
|
370
|
+
<table>
|
371
|
+
<tr><td valign="top">query:</td><td>the SPARQL CONSTRUCT or DESCRIBE query to execute
|
372
|
+
|
373
|
+
</td></tr>
|
374
|
+
</table>
|
280
375
|
<p><a class="source-toggle" href="#"
|
281
|
-
onclick="toggleCode('
|
282
|
-
<div class="method-source-code" id="
|
376
|
+
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
|
377
|
+
<div class="method-source-code" id="M000074-source">
|
283
378
|
<pre>
|
284
|
-
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line
|
379
|
+
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 37</span>
|
285
380
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">query</span>)
|
286
381
|
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@sparql_client</span>.<span class="ruby-identifier">query</span>( <span class="ruby-identifier">query</span>, <span class="ruby-value str">"application/rdf+xml"</span> )
|
287
382
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">200</span>
|
288
383
|
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Unable to execute query. Response: #{resp.status} #{resp.reason} #{resp.content}"</span>
|
289
384
|
<span class="ruby-keyword kw">end</span>
|
290
|
-
<span class="ruby-identifier">
|
385
|
+
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span>
|
386
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">store_data</span>( <span class="ruby-identifier">data</span> )
|
387
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
388
|
+
<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">resp</span>, <span class="ruby-identifier">data</span>
|
389
|
+
<span class="ruby-keyword kw">end</span>
|
390
|
+
|
291
391
|
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">resp</span>
|
292
392
|
<span class="ruby-keyword kw">end</span>
|
293
393
|
</pre>
|
@@ -92,12 +92,12 @@ Simple mechanism for managing etags
|
|
92
92
|
<h3 class="section-bar">Methods</h3>
|
93
93
|
|
94
94
|
<div class="name-list">
|
95
|
-
<a href="#
|
96
|
-
<a href="#
|
97
|
-
<a href="#
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
100
|
-
<a href="#
|
95
|
+
<a href="#M000194">add</a>
|
96
|
+
<a href="#M000195">add_from_response</a>
|
97
|
+
<a href="#M000196">get</a>
|
98
|
+
<a href="#M000197">has_tag?</a>
|
99
|
+
<a href="#M000192">new</a>
|
100
|
+
<a href="#M000193">save</a>
|
101
101
|
</div>
|
102
102
|
</div>
|
103
103
|
|
@@ -137,19 +137,19 @@ Simple mechanism for managing etags
|
|
137
137
|
<div id="methods">
|
138
138
|
<h3 class="section-bar">Public Class methods</h3>
|
139
139
|
|
140
|
-
<div id="method-
|
141
|
-
<a name="
|
140
|
+
<div id="method-M000192" class="method-detail">
|
141
|
+
<a name="M000192"></a>
|
142
142
|
|
143
143
|
<div class="method-heading">
|
144
|
-
<a href="#
|
144
|
+
<a href="#M000192" class="method-signature">
|
145
145
|
<span class="method-name">new</span><span class="method-args">(file = nil)</span>
|
146
146
|
</a>
|
147
147
|
</div>
|
148
148
|
|
149
149
|
<div class="method-description">
|
150
150
|
<p><a class="source-toggle" href="#"
|
151
|
-
onclick="toggleCode('
|
152
|
-
<div class="method-source-code" id="
|
151
|
+
onclick="toggleCode('M000192-source');return false;">[Source]</a></p>
|
152
|
+
<div class="method-source-code" id="M000192-source">
|
153
153
|
<pre>
|
154
154
|
<span class="ruby-comment cmt"># File lib/pho/etags.rb, line 11</span>
|
155
155
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">file</span> = <span class="ruby-keyword kw">nil</span>)
|
@@ -167,19 +167,19 @@ Simple mechanism for managing etags
|
|
167
167
|
|
168
168
|
<h3 class="section-bar">Public Instance methods</h3>
|
169
169
|
|
170
|
-
<div id="method-
|
171
|
-
<a name="
|
170
|
+
<div id="method-M000194" class="method-detail">
|
171
|
+
<a name="M000194"></a>
|
172
172
|
|
173
173
|
<div class="method-heading">
|
174
|
-
<a href="#
|
174
|
+
<a href="#M000194" class="method-signature">
|
175
175
|
<span class="method-name">add</span><span class="method-args">(uri, tag)</span>
|
176
176
|
</a>
|
177
177
|
</div>
|
178
178
|
|
179
179
|
<div class="method-description">
|
180
180
|
<p><a class="source-toggle" href="#"
|
181
|
-
onclick="toggleCode('
|
182
|
-
<div class="method-source-code" id="
|
181
|
+
onclick="toggleCode('M000194-source');return false;">[Source]</a></p>
|
182
|
+
<div class="method-source-code" id="M000194-source">
|
183
183
|
<pre>
|
184
184
|
<span class="ruby-comment cmt"># File lib/pho/etags.rb, line 34</span>
|
185
185
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">tag</span>)
|
@@ -193,19 +193,19 @@ Simple mechanism for managing etags
|
|
193
193
|
</div>
|
194
194
|
</div>
|
195
195
|
|
196
|
-
<div id="method-
|
197
|
-
<a name="
|
196
|
+
<div id="method-M000195" class="method-detail">
|
197
|
+
<a name="M000195"></a>
|
198
198
|
|
199
199
|
<div class="method-heading">
|
200
|
-
<a href="#
|
200
|
+
<a href="#M000195" class="method-signature">
|
201
201
|
<span class="method-name">add_from_response</span><span class="method-args">(uri, response)</span>
|
202
202
|
</a>
|
203
203
|
</div>
|
204
204
|
|
205
205
|
<div class="method-description">
|
206
206
|
<p><a class="source-toggle" href="#"
|
207
|
-
onclick="toggleCode('
|
208
|
-
<div class="method-source-code" id="
|
207
|
+
onclick="toggleCode('M000195-source');return false;">[Source]</a></p>
|
208
|
+
<div class="method-source-code" id="M000195-source">
|
209
209
|
<pre>
|
210
210
|
<span class="ruby-comment cmt"># File lib/pho/etags.rb, line 41</span>
|
211
211
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_from_response</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">response</span>)
|
@@ -216,19 +216,19 @@ Simple mechanism for managing etags
|
|
216
216
|
</div>
|
217
217
|
</div>
|
218
218
|
|
219
|
-
<div id="method-
|
220
|
-
<a name="
|
219
|
+
<div id="method-M000196" class="method-detail">
|
220
|
+
<a name="M000196"></a>
|
221
221
|
|
222
222
|
<div class="method-heading">
|
223
|
-
<a href="#
|
223
|
+
<a href="#M000196" class="method-signature">
|
224
224
|
<span class="method-name">get</span><span class="method-args">(uri)</span>
|
225
225
|
</a>
|
226
226
|
</div>
|
227
227
|
|
228
228
|
<div class="method-description">
|
229
229
|
<p><a class="source-toggle" href="#"
|
230
|
-
onclick="toggleCode('
|
231
|
-
<div class="method-source-code" id="
|
230
|
+
onclick="toggleCode('M000196-source');return false;">[Source]</a></p>
|
231
|
+
<div class="method-source-code" id="M000196-source">
|
232
232
|
<pre>
|
233
233
|
<span class="ruby-comment cmt"># File lib/pho/etags.rb, line 45</span>
|
234
234
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">uri</span>)
|
@@ -239,19 +239,19 @@ Simple mechanism for managing etags
|
|
239
239
|
</div>
|
240
240
|
</div>
|
241
241
|
|
242
|
-
<div id="method-
|
243
|
-
<a name="
|
242
|
+
<div id="method-M000197" class="method-detail">
|
243
|
+
<a name="M000197"></a>
|
244
244
|
|
245
245
|
<div class="method-heading">
|
246
|
-
<a href="#
|
246
|
+
<a href="#M000197" class="method-signature">
|
247
247
|
<span class="method-name">has_tag?</span><span class="method-args">(uri)</span>
|
248
248
|
</a>
|
249
249
|
</div>
|
250
250
|
|
251
251
|
<div class="method-description">
|
252
252
|
<p><a class="source-toggle" href="#"
|
253
|
-
onclick="toggleCode('
|
254
|
-
<div class="method-source-code" id="
|
253
|
+
onclick="toggleCode('M000197-source');return false;">[Source]</a></p>
|
254
|
+
<div class="method-source-code" id="M000197-source">
|
255
255
|
<pre>
|
256
256
|
<span class="ruby-comment cmt"># File lib/pho/etags.rb, line 49</span>
|
257
257
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_tag?</span>(<span class="ruby-identifier">uri</span>)
|
@@ -262,19 +262,19 @@ Simple mechanism for managing etags
|
|
262
262
|
</div>
|
263
263
|
</div>
|
264
264
|
|
265
|
-
<div id="method-
|
266
|
-
<a name="
|
265
|
+
<div id="method-M000193" class="method-detail">
|
266
|
+
<a name="M000193"></a>
|
267
267
|
|
268
268
|
<div class="method-heading">
|
269
|
-
<a href="#
|
269
|
+
<a href="#M000193" class="method-signature">
|
270
270
|
<span class="method-name">save</span><span class="method-args">(other=nil)</span>
|
271
271
|
</a>
|
272
272
|
</div>
|
273
273
|
|
274
274
|
<div class="method-description">
|
275
275
|
<p><a class="source-toggle" href="#"
|
276
|
-
onclick="toggleCode('
|
277
|
-
<div class="method-source-code" id="
|
276
|
+
onclick="toggleCode('M000193-source');return false;">[Source]</a></p>
|
277
|
+
<div class="method-source-code" id="M000193-source">
|
278
278
|
<pre>
|
279
279
|
<span class="ruby-comment cmt"># File lib/pho/etags.rb, line 20</span>
|
280
280
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save</span>(<span class="ruby-identifier">other</span>=<span class="ruby-keyword kw">nil</span>)
|