activerdf_rdflite 1.3 → 1.4
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.
- data/CHANGELOG +4 -0
- data/lib/activerdf_rdflite/rdflite.rb +34 -19
- data/test/test_data.nt +18 -18
- data/test/test_fetching.rb +1 -1
- data/test/test_rdflite.rb +13 -1
- metadata +56 -98
- data/doc/rdoc/classes/FetchingAdapter.html +0 -150
- data/doc/rdoc/classes/FetchingAdapter.src/M000015.html +0 -36
- data/doc/rdoc/classes/RDFLite.html +0 -390
- data/doc/rdoc/classes/RDFLite.src/M000001.html +0 -55
- data/doc/rdoc/classes/RDFLite.src/M000002.html +0 -18
- data/doc/rdoc/classes/RDFLite.src/M000003.html +0 -20
- data/doc/rdoc/classes/RDFLite.src/M000004.html +0 -18
- data/doc/rdoc/classes/RDFLite.src/M000005.html +0 -45
- data/doc/rdoc/classes/RDFLite.src/M000006.html +0 -32
- data/doc/rdoc/classes/RDFLite.src/M000007.html +0 -20
- data/doc/rdoc/classes/RDFLite.src/M000008.html +0 -24
- data/doc/rdoc/classes/RDFLite.src/M000009.html +0 -36
- data/doc/rdoc/classes/RDFLite.src/M000010.html +0 -33
- data/doc/rdoc/classes/RDFLite.src/M000011.html +0 -19
- data/doc/rdoc/classes/RDFLite.src/M000012.html +0 -27
- data/doc/rdoc/classes/SuggestingAdapter.html +0 -190
- data/doc/rdoc/classes/SuggestingAdapter.src/M000013.html +0 -23
- data/doc/rdoc/classes/SuggestingAdapter.src/M000014.html +0 -46
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/LICENSE.html +0 -756
- data/doc/rdoc/files/README.html +0 -127
- data/doc/rdoc/files/lib/activerdf_rdflite/fetching_rb.html +0 -115
- data/doc/rdoc/files/lib/activerdf_rdflite/init_rb.html +0 -116
- data/doc/rdoc/files/lib/activerdf_rdflite/rdflite_rb.html +0 -127
- data/doc/rdoc/files/lib/activerdf_rdflite/suggesting_rb.html +0 -115
- data/doc/rdoc/fr_class_index.html +0 -30
- data/doc/rdoc/fr_file_index.html +0 -32
- data/doc/rdoc/fr_method_index.html +0 -42
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
@@ -1,36 +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>
|
7
|
-
<head>
|
8
|
-
<title>fetch (FetchingAdapter)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/activerdf_rdflite/fetching.rb, line 13</span>
|
14
|
-
13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fetch</span> <span class="ruby-identifier">url</span>
|
15
|
-
14: <span class="ruby-comment cmt"># check if url starts with http://</span>
|
16
|
-
15: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">url</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/http:\/\/(.*)/</span>)
|
17
|
-
16:
|
18
|
-
17: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"fetching from #{url}"</span>
|
19
|
-
18:
|
20
|
-
19: <span class="ruby-comment cmt">#model = Redland::Model.new</span>
|
21
|
-
20: <span class="ruby-comment cmt">#parser = Redland::Parser.new('rdfxml')</span>
|
22
|
-
21: <span class="ruby-comment cmt">#scan = Redland::Uri.new('http://feature.librdf.org/raptor-scanForRDF')</span>
|
23
|
-
22: <span class="ruby-comment cmt">#enable = Redland::Literal.new('1')</span>
|
24
|
-
23: <span class="ruby-comment cmt">#Redland::librdf_parser_set_feature(parser, scan.uri, enable.node)</span>
|
25
|
-
24: <span class="ruby-comment cmt">#parser.parse_into_model(model, url)</span>
|
26
|
-
25: <span class="ruby-comment cmt">#triples = Redland::Serializer.ntriples.model_to_string(nil, model)</span>
|
27
|
-
26:
|
28
|
-
27: <span class="ruby-identifier">triples</span> = <span class="ruby-node">`rapper --scan --quiet "#{url}"`</span>
|
29
|
-
28: <span class="ruby-identifier">lines</span> = <span class="ruby-identifier">triples</span>.<span class="ruby-identifier">split</span>(<span class="ruby-identifier">$/</span>)
|
30
|
-
29: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"found #{lines.size} triples"</span>
|
31
|
-
30:
|
32
|
-
31: <span class="ruby-identifier">context</span> = <span class="ruby-constant">RDFS</span><span class="ruby-operator">::</span><span class="ruby-constant">Resource</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">url</span>)
|
33
|
-
32: <span class="ruby-identifier">add_ntriples</span>(<span class="ruby-identifier">triples</span>, <span class="ruby-identifier">context</span>)
|
34
|
-
33: <span class="ruby-keyword kw">end</span></pre>
|
35
|
-
</body>
|
36
|
-
</html>
|
@@ -1,390 +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: RDFLite</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">RDFLite</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/lib/activerdf_rdflite/rdflite_rb.html">
|
59
|
-
lib/activerdf_rdflite/rdflite.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
|
-
ActiveRdfAdapter
|
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
|
-
<a href="RDFLite.html">RDFLite</a> is a lightweight RDF database on top of
|
84
|
-
sqlite3. It can act as adapter in ActiveRDF. It supports on-disk and
|
85
|
-
in-memory usage, and allows keyword search if ferret is installed.
|
86
|
-
</p>
|
87
|
-
|
88
|
-
</div>
|
89
|
-
|
90
|
-
|
91
|
-
</div>
|
92
|
-
|
93
|
-
<div id="method-list">
|
94
|
-
<h3 class="section-bar">Methods</h3>
|
95
|
-
|
96
|
-
<div class="name-list">
|
97
|
-
<a href="#M000006">add</a>
|
98
|
-
<a href="#M000009">add_ntriples</a>
|
99
|
-
<a href="#M000004">clear</a>
|
100
|
-
<a href="#M000005">delete</a>
|
101
|
-
<a href="#M000003">dump</a>
|
102
|
-
<a href="#M000007">flush</a>
|
103
|
-
<a href="#M000008">load</a>
|
104
|
-
<a href="#M000001">new</a>
|
105
|
-
<a href="#M000010">query</a>
|
106
|
-
<a href="#M000002">size</a>
|
107
|
-
<a href="#M000012">subproperties</a>
|
108
|
-
<a href="#M000011">translate</a>
|
109
|
-
</div>
|
110
|
-
</div>
|
111
|
-
|
112
|
-
</div>
|
113
|
-
|
114
|
-
|
115
|
-
<!-- if includes -->
|
116
|
-
|
117
|
-
<div id="section">
|
118
|
-
|
119
|
-
|
120
|
-
<div id="constants-list">
|
121
|
-
<h3 class="section-bar">Constants</h3>
|
122
|
-
|
123
|
-
<div class="name-list">
|
124
|
-
<table summary="Constants">
|
125
|
-
<tr class="top-aligned-row context-row">
|
126
|
-
<td class="context-item-name">SPOC</td>
|
127
|
-
<td>=</td>
|
128
|
-
<td class="context-item-value">['s','p','o','c']</td>
|
129
|
-
<td width="3em"> </td>
|
130
|
-
<td class="context-item-desc">
|
131
|
-
constants for extracting resources/literals from sql results
|
132
|
-
|
133
|
-
</td>
|
134
|
-
</tr>
|
135
|
-
<tr class="top-aligned-row context-row">
|
136
|
-
<td class="context-item-name">Resource</td>
|
137
|
-
<td>=</td>
|
138
|
-
<td class="context-item-value">/<([^>]*)>/</td>
|
139
|
-
</tr>
|
140
|
-
<tr class="top-aligned-row context-row">
|
141
|
-
<td class="context-item-name">Literal</td>
|
142
|
-
<td>=</td>
|
143
|
-
<td class="context-item-value">/"((?:\\"|[^"])*)"/</td>
|
144
|
-
</tr>
|
145
|
-
</table>
|
146
|
-
</div>
|
147
|
-
</div>
|
148
|
-
|
149
|
-
|
150
|
-
|
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-M000001" class="method-detail">
|
159
|
-
<a name="M000001"></a>
|
160
|
-
|
161
|
-
<div class="method-heading">
|
162
|
-
<a href="RDFLite.src/M000001.html" target="Code" class="method-signature"
|
163
|
-
onclick="popupCode('RDFLite.src/M000001.html');return false;">
|
164
|
-
<span class="method-name">new</span><span class="method-args">(params = {})</span>
|
165
|
-
</a>
|
166
|
-
</div>
|
167
|
-
|
168
|
-
<div class="method-description">
|
169
|
-
<p>
|
170
|
-
instantiates <a href="RDFLite.html">RDFLite</a> database available
|
171
|
-
parameters:
|
172
|
-
</p>
|
173
|
-
<ul>
|
174
|
-
<li>:location => filepath (defaults to memory)
|
175
|
-
|
176
|
-
</li>
|
177
|
-
<li>:keyword => true/false (defaults to false)
|
178
|
-
|
179
|
-
</li>
|
180
|
-
<li>:pidx, :oidx, etc. => true/false (enable/disable these indices)
|
181
|
-
|
182
|
-
</li>
|
183
|
-
</ul>
|
184
|
-
</div>
|
185
|
-
</div>
|
186
|
-
|
187
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
188
|
-
|
189
|
-
<div id="method-M000006" class="method-detail">
|
190
|
-
<a name="M000006"></a>
|
191
|
-
|
192
|
-
<div class="method-heading">
|
193
|
-
<a href="RDFLite.src/M000006.html" target="Code" class="method-signature"
|
194
|
-
onclick="popupCode('RDFLite.src/M000006.html');return false;">
|
195
|
-
<span class="method-name">add</span><span class="method-args">(s,p,o,c=nil)</span>
|
196
|
-
</a>
|
197
|
-
</div>
|
198
|
-
|
199
|
-
<div class="method-description">
|
200
|
-
<p>
|
201
|
-
adds triple(s,p,o) to datastore s,p must be resources, o can be primitive
|
202
|
-
data or resource
|
203
|
-
</p>
|
204
|
-
</div>
|
205
|
-
</div>
|
206
|
-
|
207
|
-
<div id="method-M000009" class="method-detail">
|
208
|
-
<a name="M000009"></a>
|
209
|
-
|
210
|
-
<div class="method-heading">
|
211
|
-
<a href="RDFLite.src/M000009.html" target="Code" class="method-signature"
|
212
|
-
onclick="popupCode('RDFLite.src/M000009.html');return false;">
|
213
|
-
<span class="method-name">add_ntriples</span><span class="method-args">(ntriples, context)</span>
|
214
|
-
</a>
|
215
|
-
</div>
|
216
|
-
|
217
|
-
<div class="method-description">
|
218
|
-
<p>
|
219
|
-
adds ntriples from given context into datastore
|
220
|
-
</p>
|
221
|
-
</div>
|
222
|
-
</div>
|
223
|
-
|
224
|
-
<div id="method-M000004" class="method-detail">
|
225
|
-
<a name="M000004"></a>
|
226
|
-
|
227
|
-
<div class="method-heading">
|
228
|
-
<a href="RDFLite.src/M000004.html" target="Code" class="method-signature"
|
229
|
-
onclick="popupCode('RDFLite.src/M000004.html');return false;">
|
230
|
-
<span class="method-name">clear</span><span class="method-args">()</span>
|
231
|
-
</a>
|
232
|
-
</div>
|
233
|
-
|
234
|
-
<div class="method-description">
|
235
|
-
<p>
|
236
|
-
deletes all triples from datastore
|
237
|
-
</p>
|
238
|
-
</div>
|
239
|
-
</div>
|
240
|
-
|
241
|
-
<div id="method-M000005" class="method-detail">
|
242
|
-
<a name="M000005"></a>
|
243
|
-
|
244
|
-
<div class="method-heading">
|
245
|
-
<a href="RDFLite.src/M000005.html" target="Code" class="method-signature"
|
246
|
-
onclick="popupCode('RDFLite.src/M000005.html');return false;">
|
247
|
-
<span class="method-name">delete</span><span class="method-args">(s, p, o, c=nil)</span>
|
248
|
-
</a>
|
249
|
-
</div>
|
250
|
-
|
251
|
-
<div class="method-description">
|
252
|
-
<p>
|
253
|
-
deletes triple(s,p,o,c) from datastore symbol parameters match anything:
|
254
|
-
delete(:s,:p,:o) will delete all triples you can specify a context to limit
|
255
|
-
deletion to that context: delete(:s,:p,:o, ‘<a
|
256
|
-
href="http://context">context</a>’) will delete all triples with that
|
257
|
-
context
|
258
|
-
</p>
|
259
|
-
</div>
|
260
|
-
</div>
|
261
|
-
|
262
|
-
<div id="method-M000003" class="method-detail">
|
263
|
-
<a name="M000003"></a>
|
264
|
-
|
265
|
-
<div class="method-heading">
|
266
|
-
<a href="RDFLite.src/M000003.html" target="Code" class="method-signature"
|
267
|
-
onclick="popupCode('RDFLite.src/M000003.html');return false;">
|
268
|
-
<span class="method-name">dump</span><span class="method-args">()</span>
|
269
|
-
</a>
|
270
|
-
</div>
|
271
|
-
|
272
|
-
<div class="method-description">
|
273
|
-
<p>
|
274
|
-
returns all triples in the datastore
|
275
|
-
</p>
|
276
|
-
</div>
|
277
|
-
</div>
|
278
|
-
|
279
|
-
<div id="method-M000007" class="method-detail">
|
280
|
-
<a name="M000007"></a>
|
281
|
-
|
282
|
-
<div class="method-heading">
|
283
|
-
<a href="RDFLite.src/M000007.html" target="Code" class="method-signature"
|
284
|
-
onclick="popupCode('RDFLite.src/M000007.html');return false;">
|
285
|
-
<span class="method-name">flush</span><span class="method-args">()</span>
|
286
|
-
</a>
|
287
|
-
</div>
|
288
|
-
|
289
|
-
<div class="method-description">
|
290
|
-
<p>
|
291
|
-
flushes openstanding changes to underlying sqlite3
|
292
|
-
</p>
|
293
|
-
</div>
|
294
|
-
</div>
|
295
|
-
|
296
|
-
<div id="method-M000008" class="method-detail">
|
297
|
-
<a name="M000008"></a>
|
298
|
-
|
299
|
-
<div class="method-heading">
|
300
|
-
<a href="RDFLite.src/M000008.html" target="Code" class="method-signature"
|
301
|
-
onclick="popupCode('RDFLite.src/M000008.html');return false;">
|
302
|
-
<span class="method-name">load</span><span class="method-args">(file)</span>
|
303
|
-
</a>
|
304
|
-
</div>
|
305
|
-
|
306
|
-
<div class="method-description">
|
307
|
-
<p>
|
308
|
-
loads triples from file in ntriples format
|
309
|
-
</p>
|
310
|
-
</div>
|
311
|
-
</div>
|
312
|
-
|
313
|
-
<div id="method-M000010" class="method-detail">
|
314
|
-
<a name="M000010"></a>
|
315
|
-
|
316
|
-
<div class="method-heading">
|
317
|
-
<a href="RDFLite.src/M000010.html" target="Code" class="method-signature"
|
318
|
-
onclick="popupCode('RDFLite.src/M000010.html');return false;">
|
319
|
-
<span class="method-name">query</span><span class="method-args">(query)</span>
|
320
|
-
</a>
|
321
|
-
</div>
|
322
|
-
|
323
|
-
<div class="method-description">
|
324
|
-
<p>
|
325
|
-
executes ActiveRDF query on datastore
|
326
|
-
</p>
|
327
|
-
</div>
|
328
|
-
</div>
|
329
|
-
|
330
|
-
<div id="method-M000002" class="method-detail">
|
331
|
-
<a name="M000002"></a>
|
332
|
-
|
333
|
-
<div class="method-heading">
|
334
|
-
<a href="RDFLite.src/M000002.html" target="Code" class="method-signature"
|
335
|
-
onclick="popupCode('RDFLite.src/M000002.html');return false;">
|
336
|
-
<span class="method-name">size</span><span class="method-args">()</span>
|
337
|
-
</a>
|
338
|
-
</div>
|
339
|
-
|
340
|
-
<div class="method-description">
|
341
|
-
<p>
|
342
|
-
returns the number of triples in the datastore (incl. possible duplicates)
|
343
|
-
</p>
|
344
|
-
</div>
|
345
|
-
</div>
|
346
|
-
|
347
|
-
<div id="method-M000012" class="method-detail">
|
348
|
-
<a name="M000012"></a>
|
349
|
-
|
350
|
-
<div class="method-heading">
|
351
|
-
<a href="RDFLite.src/M000012.html" target="Code" class="method-signature"
|
352
|
-
onclick="popupCode('RDFLite.src/M000012.html');return false;">
|
353
|
-
<span class="method-name">subproperties</span><span class="method-args">(resource)</span>
|
354
|
-
</a>
|
355
|
-
</div>
|
356
|
-
|
357
|
-
<div class="method-description">
|
358
|
-
</div>
|
359
|
-
</div>
|
360
|
-
|
361
|
-
<div id="method-M000011" class="method-detail">
|
362
|
-
<a name="M000011"></a>
|
363
|
-
|
364
|
-
<div class="method-heading">
|
365
|
-
<a href="RDFLite.src/M000011.html" target="Code" class="method-signature"
|
366
|
-
onclick="popupCode('RDFLite.src/M000011.html');return false;">
|
367
|
-
<span class="method-name">translate</span><span class="method-args">(query)</span>
|
368
|
-
</a>
|
369
|
-
</div>
|
370
|
-
|
371
|
-
<div class="method-description">
|
372
|
-
<p>
|
373
|
-
translates ActiveRDF query into internal sqlite query string
|
374
|
-
</p>
|
375
|
-
</div>
|
376
|
-
</div>
|
377
|
-
|
378
|
-
|
379
|
-
</div>
|
380
|
-
|
381
|
-
|
382
|
-
</div>
|
383
|
-
|
384
|
-
|
385
|
-
<div id="validator-badges">
|
386
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
387
|
-
</div>
|
388
|
-
|
389
|
-
</body>
|
390
|
-
</html>
|
@@ -1,55 +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>
|
7
|
-
<head>
|
8
|
-
<title>new (RDFLite)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/activerdf_rdflite/rdflite.rb, line 34</span>
|
14
|
-
34: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">params</span> = {})
|
15
|
-
35: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">"initialised rdflite with params #{params.to_s}"</span>
|
16
|
-
36:
|
17
|
-
37: <span class="ruby-ivar">@reads</span> = <span class="ruby-keyword kw">true</span>
|
18
|
-
38: <span class="ruby-ivar">@writes</span> = <span class="ruby-keyword kw">true</span>
|
19
|
-
39:
|
20
|
-
40: <span class="ruby-comment cmt"># if no file-location given, we use in-memory store</span>
|
21
|
-
41: <span class="ruby-identifier">file</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:location</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">':memory:'</span>
|
22
|
-
42: <span class="ruby-ivar">@db</span> = <span class="ruby-constant">SQLite3</span><span class="ruby-operator">::</span><span class="ruby-constant">Database</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">file</span>)
|
23
|
-
43:
|
24
|
-
44: <span class="ruby-comment cmt"># disable keyword search by default, enable only if ferret is found</span>
|
25
|
-
45: <span class="ruby-ivar">@keyword_search</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:keyword</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">false</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:keyword</span>]
|
26
|
-
46: <span class="ruby-ivar">@keyword_search</span> <span class="ruby-operator">&=</span> <span class="ruby-ivar">@@have_ferret</span>
|
27
|
-
47:
|
28
|
-
48: <span class="ruby-ivar">@reasoning</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:reasoning</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">false</span>
|
29
|
-
49:
|
30
|
-
50: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">keyword_search?</span>
|
31
|
-
51: <span class="ruby-comment cmt"># we initialise the ferret index, either as a file or in memory</span>
|
32
|
-
52: <span class="ruby-identifier">infos</span> = <span class="ruby-constant">Ferret</span><span class="ruby-operator">::</span><span class="ruby-constant">Index</span><span class="ruby-operator">::</span><span class="ruby-constant">FieldInfos</span>.<span class="ruby-identifier">new</span>
|
33
|
-
53:
|
34
|
-
54: <span class="ruby-comment cmt"># we setup the fields not to store object's contents</span>
|
35
|
-
55: <span class="ruby-identifier">infos</span>.<span class="ruby-identifier">add_field</span>(<span class="ruby-identifier">:subject</span>, <span class="ruby-identifier">:store</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:yes</span>, <span class="ruby-identifier">:index</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:no</span>, <span class="ruby-identifier">:term_vector</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:no</span>)
|
36
|
-
56: <span class="ruby-identifier">infos</span>.<span class="ruby-identifier">add_field</span>(<span class="ruby-identifier">:object</span>, <span class="ruby-identifier">:store</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:no</span>) <span class="ruby-comment cmt">#, :index => :omit_norms)</span>
|
37
|
-
57:
|
38
|
-
58: <span class="ruby-ivar">@ferret</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:location</span>]
|
39
|
-
59: <span class="ruby-constant">Ferret</span><span class="ruby-operator">::</span><span class="ruby-constant">I</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">:path</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:location</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">'.ferret'</span>, <span class="ruby-identifier">:field_infos</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">infos</span>)
|
40
|
-
60: <span class="ruby-keyword kw">else</span>
|
41
|
-
61: <span class="ruby-constant">Ferret</span><span class="ruby-operator">::</span><span class="ruby-constant">I</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">:field_infos</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">infos</span>)
|
42
|
-
62: <span class="ruby-keyword kw">end</span>
|
43
|
-
63: <span class="ruby-keyword kw">end</span>
|
44
|
-
64:
|
45
|
-
65: <span class="ruby-comment cmt"># turn off filesystem synchronisation for speed</span>
|
46
|
-
66: <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">synchronous</span> = <span class="ruby-value str">'off'</span>
|
47
|
-
67:
|
48
|
-
68: <span class="ruby-comment cmt"># create triples table. ignores duplicated triples</span>
|
49
|
-
69: <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-value str">'create table if not exists triple(s,p,o,c, unique(s,p,o,c) on conflict ignore)'</span>)
|
50
|
-
70:
|
51
|
-
71: <span class="ruby-identifier">create_indices</span>(<span class="ruby-identifier">params</span>)
|
52
|
-
72: <span class="ruby-ivar">@db</span>
|
53
|
-
73: <span class="ruby-keyword kw">end</span></pre>
|
54
|
-
</body>
|
55
|
-
</html>
|