pho 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. data/CHANGES +5 -0
  2. data/Rakefile +1 -1
  3. data/lib/pho/snapshot.rb +6 -1
  4. data/lib/pho/sparql.rb +4 -1
  5. data/tests/tc_snapshots.rb +14 -1
  6. data/tests/tc_sparql_helper.rb +23 -0
  7. metadata +60 -160
  8. data/doc/rdoc/classes/Pho/Analyzers.html +0 -310
  9. data/doc/rdoc/classes/Pho/CommandLine.html +0 -770
  10. data/doc/rdoc/classes/Pho/DatatypeProperty.html +0 -241
  11. data/doc/rdoc/classes/Pho/Enrichment/StoreEnricher.html +0 -410
  12. data/doc/rdoc/classes/Pho/Enrichment.html +0 -119
  13. data/doc/rdoc/classes/Pho/Etags.html +0 -310
  14. data/doc/rdoc/classes/Pho/Facet/Results.html +0 -299
  15. data/doc/rdoc/classes/Pho/Facet/Term.html +0 -177
  16. data/doc/rdoc/classes/Pho/Facet.html +0 -119
  17. data/doc/rdoc/classes/Pho/FieldPredicateMap.html +0 -668
  18. data/doc/rdoc/classes/Pho/FieldWeighting.html +0 -230
  19. data/doc/rdoc/classes/Pho/FileManagement/AbstractFileManager.html +0 -478
  20. data/doc/rdoc/classes/Pho/FileManagement/FileManager.html +0 -264
  21. data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +0 -259
  22. data/doc/rdoc/classes/Pho/FileManagement.html +0 -121
  23. data/doc/rdoc/classes/Pho/Job.html +0 -627
  24. data/doc/rdoc/classes/Pho/JobUpdate.html +0 -141
  25. data/doc/rdoc/classes/Pho/Jobs.html +0 -538
  26. data/doc/rdoc/classes/Pho/Namespaces.html +0 -164
  27. data/doc/rdoc/classes/Pho/OAI/Record.html +0 -165
  28. data/doc/rdoc/classes/Pho/OAI/Records.html +0 -331
  29. data/doc/rdoc/classes/Pho/OAI.html +0 -118
  30. data/doc/rdoc/classes/Pho/QueryProfile.html +0 -497
  31. data/doc/rdoc/classes/Pho/RDF/Parser.html +0 -279
  32. data/doc/rdoc/classes/Pho/RDF.html +0 -120
  33. data/doc/rdoc/classes/Pho/RDFCollection.html +0 -119
  34. data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +0 -325
  35. data/doc/rdoc/classes/Pho/ResourceHash/SetAlgebra.html +0 -241
  36. data/doc/rdoc/classes/Pho/ResourceHash.html +0 -123
  37. data/doc/rdoc/classes/Pho/Snapshot.html +0 -397
  38. data/doc/rdoc/classes/Pho/Sparql/SparqlClient.html +0 -594
  39. data/doc/rdoc/classes/Pho/Sparql/SparqlHelper.html +0 -692
  40. data/doc/rdoc/classes/Pho/Sparql.html +0 -187
  41. data/doc/rdoc/classes/Pho/Status.html +0 -296
  42. data/doc/rdoc/classes/Pho/Store.html +0 -1560
  43. data/doc/rdoc/classes/Pho/StoreSparqlClient.html +0 -183
  44. data/doc/rdoc/classes/Pho/Update/Changeset.html +0 -521
  45. data/doc/rdoc/classes/Pho/Update/ChangesetBuilder.html +0 -330
  46. data/doc/rdoc/classes/Pho/Update/ChangesetHelper.html +0 -159
  47. data/doc/rdoc/classes/Pho/Update/Changesets.html +0 -205
  48. data/doc/rdoc/classes/Pho/Update/LiteralStatement.html +0 -257
  49. data/doc/rdoc/classes/Pho/Update/ResourceStatement.html +0 -237
  50. data/doc/rdoc/classes/Pho/Update/Statement.html +0 -303
  51. data/doc/rdoc/classes/Pho/Update.html +0 -128
  52. data/doc/rdoc/classes/Pho.html +0 -283
  53. data/doc/rdoc/classes/String.html +0 -146
  54. data/doc/rdoc/created.rid +0 -1
  55. data/doc/rdoc/files/CHANGES.html +0 -351
  56. data/doc/rdoc/files/README.html +0 -191
  57. data/doc/rdoc/files/lib/pho/changeset_builder_rb.html +0 -108
  58. data/doc/rdoc/files/lib/pho/changeset_rb.html +0 -108
  59. data/doc/rdoc/files/lib/pho/command_line_rb.html +0 -101
  60. data/doc/rdoc/files/lib/pho/converter_rb.html +0 -108
  61. data/doc/rdoc/files/lib/pho/enrichment_rb.html +0 -101
  62. data/doc/rdoc/files/lib/pho/etags_rb.html +0 -108
  63. data/doc/rdoc/files/lib/pho/facet_rb.html +0 -101
  64. data/doc/rdoc/files/lib/pho/field_predicate_map_rb.html +0 -101
  65. data/doc/rdoc/files/lib/pho/file_management_rb.html +0 -101
  66. data/doc/rdoc/files/lib/pho/file_manager_rb.html +0 -108
  67. data/doc/rdoc/files/lib/pho/job_rb.html +0 -101
  68. data/doc/rdoc/files/lib/pho/oai_rb.html +0 -101
  69. data/doc/rdoc/files/lib/pho/query_profile_rb.html +0 -101
  70. data/doc/rdoc/files/lib/pho/rdf_collection_rb.html +0 -101
  71. data/doc/rdoc/files/lib/pho/rdf_rb.html +0 -108
  72. data/doc/rdoc/files/lib/pho/resource_hash_rb.html +0 -101
  73. data/doc/rdoc/files/lib/pho/snapshot_rb.html +0 -109
  74. data/doc/rdoc/files/lib/pho/sparql_rb.html +0 -101
  75. data/doc/rdoc/files/lib/pho/status_rb.html +0 -101
  76. data/doc/rdoc/files/lib/pho/store_rb.html +0 -108
  77. data/doc/rdoc/files/lib/pho_rb.html +0 -133
  78. data/doc/rdoc/fr_class_index.html +0 -72
  79. data/doc/rdoc/fr_file_index.html +0 -49
  80. data/doc/rdoc/fr_method_index.html +0 -237
  81. data/doc/rdoc/index.html +0 -24
  82. data/doc/rdoc/rdoc-style.css +0 -208
@@ -1,241 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Pho::DatatypeProperty</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Pho::DatatypeProperty</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/pho/field_predicate_map_rb.html">
59
- lib/pho/field_predicate_map.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
- <div id="description">
82
- <p>
83
- Captures information about a mapped datatype from a Field Predicate Map
84
- </p>
85
-
86
- </div>
87
-
88
-
89
- </div>
90
-
91
- <div id="method-list">
92
- <h3 class="section-bar">Methods</h3>
93
-
94
- <div class="name-list">
95
- <a href="#M000151">new</a>&nbsp;&nbsp;
96
- <a href="#M000152">to_rdf</a>&nbsp;&nbsp;
97
- </div>
98
- </div>
99
-
100
- </div>
101
-
102
-
103
- <!-- if includes -->
104
-
105
- <div id="section">
106
-
107
-
108
-
109
-
110
-
111
- <div id="attribute-list">
112
- <h3 class="section-bar">Attributes</h3>
113
-
114
- <div class="name-list">
115
- <table>
116
- <tr class="top-aligned-row context-row">
117
- <td class="context-item-name">analyzer</td>
118
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
119
- <td class="context-item-desc">
120
- URI of the analyzer associated with this property
121
-
122
- </td>
123
- </tr>
124
- <tr class="top-aligned-row context-row">
125
- <td class="context-item-name">name</td>
126
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
127
- <td class="context-item-desc">
128
- Short name for the property
129
-
130
- </td>
131
- </tr>
132
- <tr class="top-aligned-row context-row">
133
- <td class="context-item-name">property_uri</td>
134
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
135
- <td class="context-item-desc">
136
- <a href="RDF.html">RDF</a> predicate URI for the mapped property
137
-
138
- </td>
139
- </tr>
140
- <tr class="top-aligned-row context-row">
141
- <td class="context-item-name">uri</td>
142
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
143
- <td class="context-item-desc">
144
- URI for this mapping
145
-
146
- </td>
147
- </tr>
148
- </table>
149
- </div>
150
- </div>
151
-
152
-
153
-
154
- <!-- if method_list -->
155
- <div id="methods">
156
- <h3 class="section-bar">Public Class methods</h3>
157
-
158
- <div id="method-M000151" class="method-detail">
159
- <a name="M000151"></a>
160
-
161
- <div class="method-heading">
162
- <a href="#M000151" class="method-signature">
163
- <span class="method-name">new</span><span class="method-args">(uri, property_uri, name, analyzer=nil)</span>
164
- </a>
165
- </div>
166
-
167
- <div class="method-description">
168
- <p><a class="source-toggle" href="#"
169
- onclick="toggleCode('M000151-source');return false;">[Source]</a></p>
170
- <div class="method-source-code" id="M000151-source">
171
- <pre>
172
- <span class="ruby-comment cmt"># File lib/pho/field_predicate_map.rb, line 64</span>
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>)
174
- <span class="ruby-ivar">@uri</span> = <span class="ruby-identifier">uri</span>
175
- <span class="ruby-ivar">@property_uri</span> = <span class="ruby-identifier">property_uri</span>
176
- <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
177
- <span class="ruby-ivar">@analyzer</span> = <span class="ruby-identifier">analyzer</span>
178
- <span class="ruby-keyword kw">end</span>
179
- </pre>
180
- </div>
181
- </div>
182
- </div>
183
-
184
- <h3 class="section-bar">Public Instance methods</h3>
185
-
186
- <div id="method-M000152" class="method-detail">
187
- <a name="M000152"></a>
188
-
189
- <div class="method-heading">
190
- <a href="#M000152" class="method-signature">
191
- <span class="method-name">to_rdf</span><span class="method-args">(ns=true)</span>
192
- </a>
193
- </div>
194
-
195
- <div class="method-description">
196
- <p>
197
- Convert this object into an <a href="RDF.html">RDF</a> representation.
198
- Generates a simple rdf:Description, optionally including namespaces
199
- </p>
200
- <table>
201
- <tr><td valign="top">ns:</td><td>include namespace declarations
202
-
203
- </td></tr>
204
- </table>
205
- <p><a class="source-toggle" href="#"
206
- onclick="toggleCode('M000152-source');return false;">[Source]</a></p>
207
- <div class="method-source-code" id="M000152-source">
208
- <pre>
209
- <span class="ruby-comment cmt"># File lib/pho/field_predicate_map.rb, line 73</span>
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>)
211
- <span class="ruby-identifier">rdf</span> = <span class="ruby-value str">&quot;&lt;rdf:Description &quot;</span>
212
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ns</span>
213
- <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; xmlns:rdf=\&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#\&quot; xmlns:frm=\&quot;#{Pho::Namespaces::FRAME}\&quot; xmlns:bf=\&quot;#{Pho::Namespaces::CONFIG}\&quot; &quot;</span>
214
- <span class="ruby-keyword kw">end</span>
215
- <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; rdf:about=\&quot;#{@uri}\&quot;&gt;&quot;</span>
216
- <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; &lt;frm:property rdf:resource=\&quot;#{@property_uri}\&quot;/&gt;&quot;</span>
217
- <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; &lt;frm:name&gt;#{@name}&lt;/frm:name&gt;&quot;</span>
218
- <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@analyzer</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
219
- <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; &lt;bf:analyzer rdf:resource=\&quot;#{@analyzer}\&quot; /&gt;&quot;</span>
220
- <span class="ruby-keyword kw">end</span>
221
- <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/rdf:Description&gt;&quot;</span>
222
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rdf</span>
223
- <span class="ruby-keyword kw">end</span>
224
- </pre>
225
- </div>
226
- </div>
227
- </div>
228
-
229
-
230
- </div>
231
-
232
-
233
- </div>
234
-
235
-
236
- <div id="validator-badges">
237
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
238
- </div>
239
-
240
- </body>
241
- </html>
@@ -1,410 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Pho::Enrichment::StoreEnricher</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Pho::Enrichment::StoreEnricher</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../../files/lib/pho/enrichment_rb.html">
59
- lib/pho/enrichment.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
-
82
-
83
- </div>
84
-
85
- <div id="method-list">
86
- <h3 class="section-bar">Methods</h3>
87
-
88
- <div class="name-list">
89
- <a href="#M000081">enrich</a>&nbsp;&nbsp;
90
- <a href="#M000079">infer</a>&nbsp;&nbsp;
91
- <a href="#M000080">merge</a>&nbsp;&nbsp;
92
- <a href="#M000078">new</a>&nbsp;&nbsp;
93
- </div>
94
- </div>
95
-
96
- </div>
97
-
98
-
99
- <!-- if includes -->
100
-
101
- <div id="section">
102
-
103
-
104
-
105
-
106
-
107
- <div id="attribute-list">
108
- <h3 class="section-bar">Attributes</h3>
109
-
110
- <div class="name-list">
111
- <table>
112
- <tr class="top-aligned-row context-row">
113
- <td class="context-item-name">sparql_client</td>
114
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
115
- <td class="context-item-desc"></td>
116
- </tr>
117
- <tr class="top-aligned-row context-row">
118
- <td class="context-item-name">store</td>
119
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
120
- <td class="context-item-desc"></td>
121
- </tr>
122
- </table>
123
- </div>
124
- </div>
125
-
126
-
127
-
128
- <!-- if method_list -->
129
- <div id="methods">
130
- <h3 class="section-bar">Public Class methods</h3>
131
-
132
- <div id="method-M000079" class="method-detail">
133
- <a name="M000079"></a>
134
-
135
- <div class="method-heading">
136
- <a href="#M000079" class="method-signature">
137
- <span class="method-name">infer</span><span class="method-args">(store, query, &amp;block)</span>
138
- </a>
139
- </div>
140
-
141
- <div class="method-description">
142
- <p>
143
- Enrich a store against itself
144
- </p>
145
- <p>
146
- For the common case where a store needs to be enriched against itself by
147
- inferring <a href="StoreEnricher.html#M000078">new</a> data from old using
148
- a CONSTRUCT query
149
- </p>
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#M000079">infer</a> the <a
156
- href="StoreEnricher.html#M000078">new</a> data
157
-
158
- </td></tr>
159
- </table>
160
- <p><a class="source-toggle" href="#"
161
- onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
162
- <div class="method-source-code" id="M000079-source">
163
- <pre>
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">&amp;</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">&amp;</span><span class="ruby-identifier">block</span> )
168
- <span class="ruby-keyword kw">end</span>
169
- </pre>
170
- </div>
171
- </div>
172
- </div>
173
-
174
- <div id="method-M000078" class="method-detail">
175
- <a name="M000078"></a>
176
-
177
- <div class="method-heading">
178
- <a href="#M000078" class="method-signature">
179
- <span class="method-name">new</span><span class="method-args">(store, sparql_client)</span>
180
- </a>
181
- </div>
182
-
183
- <div class="method-description">
184
- <p>
185
- Constructor
186
- </p>
187
- <table>
188
- <tr><td valign="top">store:</td><td>the store containing resource(s) to <a
189
- href="StoreEnricher.html#M000081">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>
196
- <p><a class="source-toggle" href="#"
197
- onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
198
- <div class="method-source-code" id="M000078-source">
199
- <pre>
200
- <span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 16</span>
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>)
202
- <span class="ruby-ivar">@store</span> = <span class="ruby-identifier">store</span>
203
- <span class="ruby-ivar">@sparql_client</span> = <span class="ruby-identifier">sparql_client</span>
204
- <span class="ruby-keyword kw">end</span>
205
- </pre>
206
- </div>
207
- </div>
208
- </div>
209
-
210
- <h3 class="section-bar">Public Instance methods</h3>
211
-
212
- <div id="method-M000081" class="method-detail">
213
- <a name="M000081"></a>
214
-
215
- <div class="method-heading">
216
- <a href="#M000081" class="method-signature">
217
- <span class="method-name">enrich</span><span class="method-args">(locator_query, enrichment_query, callback=nil) {|:query, query_response| ...}</span>
218
- </a>
219
- </div>
220
-
221
- <div class="method-description">
222
- <p>
223
- Enrich a store with data extracted from a SPARQL endpoint.
224
- </p>
225
- <p>
226
- The locator_query is used to find resources in the Platform <a
227
- href="../Store.html">Store</a> that should be enriched. The query should be
228
- a SPARQL SELECT query that returns the data to be used to parameterize the
229
- enrichment_query.
230
- </p>
231
- <p>
232
- For each query result, the enrichment_query will be submitted to the
233
- configured SPARQL endpoint, after first interpolating the string, providing
234
- the query result bindings as parameters. (See
235
- SparqlHelper.apply_initial_bindings and
236
- SparqlHelper.results_to_query_bindings
237
- </p>
238
- <p>
239
- If successful, the result of each enrichment query will then be pushed back
240
- into the Platform <a href="../Store.html">Store</a> by posting the results
241
- of the query to the metabox. <a href="../Enrichment.html">Enrichment</a>
242
- queries should therefore be CONSTRUCT or DESCRIBE queries. The SPARQL
243
- protocol request will be sent with an Accept header of application/rdf+xml
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>
268
- <pre>
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 &quot;Store returned #{resp.status} when storing: #{rdf}&quot;
278
- end
279
- end
280
- callback = MyCallback.new()
281
- enricher.enrich(&quot;SELECT ?item WHERE { ?item a ex:Class } LIMIT 10&quot;, &quot;DESCRIBE ?item&quot;, 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(&quot;SELECT ?item WHERE { ?item a ex:Class } LIMIT 10&quot;, &quot;DESCRIBE ?item&quot;) do |source, resp|
293
- if source == :query
294
- puts &quot;Enrichment query returned #{resp.status}&quot;
295
- else
296
- puts &quot;Store returned #{resp.status} when storing data&quot;
297
- end
298
- end
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#M000081">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>
312
- <p><a class="source-toggle" href="#"
313
- onclick="toggleCode('M000081-source');return false;">[Source]</a></p>
314
- <div class="method-source-code" id="M000081-source">
315
- <pre>
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>)
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>() )
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>)
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>
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>)
322
-
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">&quot;application/rdf+xml&quot;</span>)
325
-
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>
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">&amp;&amp;</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">&amp;&amp;</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>
349
- <span class="ruby-keyword kw">end</span>
350
- <span class="ruby-keyword kw">end</span>
351
- </pre>
352
- </div>
353
- </div>
354
- </div>
355
-
356
- <div id="method-M000080" class="method-detail">
357
- <a name="M000080"></a>
358
-
359
- <div class="method-heading">
360
- <a href="#M000080" class="method-signature">
361
- <span class="method-name">merge</span><span class="method-args">(query) {|resp, data| ...}</span>
362
- </a>
363
- </div>
364
-
365
- <div class="method-description">
366
- <p>
367
- Execute the provided query against the configured SPARQL endpoint and store
368
- the results in the Platform <a href="../Store.html">Store</a>
369
- </p>
370
- <table>
371
- <tr><td valign="top">query:</td><td>the SPARQL CONSTRUCT or DESCRIBE query to execute
372
-
373
- </td></tr>
374
- </table>
375
- <p><a class="source-toggle" href="#"
376
- onclick="toggleCode('M000080-source');return false;">[Source]</a></p>
377
- <div class="method-source-code" id="M000080-source">
378
- <pre>
379
- <span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 37</span>
380
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">query</span>)
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">&quot;application/rdf+xml&quot;</span> )
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>
383
- <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unable to execute query. Response: #{resp.status} #{resp.reason} #{resp.content}&quot;</span>
384
- <span class="ruby-keyword kw">end</span>
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
-
391
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">resp</span>
392
- <span class="ruby-keyword kw">end</span>
393
- </pre>
394
- </div>
395
- </div>
396
- </div>
397
-
398
-
399
- </div>
400
-
401
-
402
- </div>
403
-
404
-
405
- <div id="validator-badges">
406
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
407
- </div>
408
-
409
- </body>
410
- </html>