activerdf_rdflite 1.4 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -1
- data/doc/rdoc/classes/FetchingAdapter.html +150 -0
- data/doc/rdoc/classes/FetchingAdapter.src/M000015.html +36 -0
- data/doc/rdoc/classes/RDFLite.html +390 -0
- data/doc/rdoc/classes/RDFLite.src/M000001.html +55 -0
- data/doc/rdoc/classes/RDFLite.src/M000002.html +18 -0
- data/doc/rdoc/classes/RDFLite.src/M000003.html +20 -0
- data/doc/rdoc/classes/RDFLite.src/M000004.html +18 -0
- data/doc/rdoc/classes/RDFLite.src/M000005.html +45 -0
- data/doc/rdoc/classes/RDFLite.src/M000006.html +32 -0
- data/doc/rdoc/classes/RDFLite.src/M000007.html +20 -0
- data/doc/rdoc/classes/RDFLite.src/M000008.html +24 -0
- data/doc/rdoc/classes/RDFLite.src/M000009.html +36 -0
- data/doc/rdoc/classes/RDFLite.src/M000010.html +33 -0
- data/doc/rdoc/classes/RDFLite.src/M000011.html +19 -0
- data/doc/rdoc/classes/RDFLite.src/M000012.html +27 -0
- data/doc/rdoc/classes/String.html +137 -0
- data/doc/rdoc/classes/String.src/M000016.html +25 -0
- data/doc/rdoc/classes/SuggestingAdapter.html +190 -0
- data/doc/rdoc/classes/SuggestingAdapter.src/M000013.html +23 -0
- data/doc/rdoc/classes/SuggestingAdapter.src/M000014.html +46 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/LICENSE.html +756 -0
- data/doc/rdoc/files/README.html +127 -0
- data/doc/rdoc/files/lib/activerdf_rdflite/fetching_rb.html +115 -0
- data/doc/rdoc/files/lib/activerdf_rdflite/init_rb.html +116 -0
- data/doc/rdoc/files/lib/activerdf_rdflite/rdflite_rb.html +127 -0
- data/doc/rdoc/files/lib/activerdf_rdflite/suggesting_rb.html +115 -0
- data/doc/rdoc/fr_class_index.html +30 -0
- data/doc/rdoc/fr_file_index.html +32 -0
- data/doc/rdoc/fr_method_index.html +42 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/lib/activerdf_rdflite/rdflite.rb +27 -9
- data/test/test_rdflite.rb +8 -6
- metadata +102 -57
@@ -0,0 +1,55 @@
|
|
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>
|
@@ -0,0 +1,18 @@
|
|
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>size (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 76</span>
|
14
|
+
76: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">size</span>
|
15
|
+
77: <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-value str">'select count(*) from triple'</span>)[<span class="ruby-value">0</span>][<span class="ruby-value">0</span>].<span class="ruby-identifier">to_i</span>
|
16
|
+
78: <span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
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>dump (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 81</span>
|
14
|
+
81: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dump</span>
|
15
|
+
82: <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-value str">'select s,p,o,c from triple'</span>).<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>,<span class="ruby-identifier">p</span>,<span class="ruby-identifier">o</span>,<span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
|
16
|
+
83: [<span class="ruby-identifier">s</span>,<span class="ruby-identifier">p</span>,<span class="ruby-identifier">o</span>,<span class="ruby-identifier">c</span>].<span class="ruby-identifier">join</span>(<span class="ruby-value str">' '</span>)
|
17
|
+
84: <span class="ruby-keyword kw">end</span>
|
18
|
+
85: <span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
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>clear (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 88</span>
|
14
|
+
88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear</span>
|
15
|
+
89: <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-value str">'delete from triple'</span>)
|
16
|
+
90: <span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,45 @@
|
|
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>delete (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 96</span>
|
14
|
+
96: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">s</span>, <span class="ruby-identifier">p</span>, <span class="ruby-identifier">o</span>, <span class="ruby-identifier">c</span>=<span class="ruby-keyword kw">nil</span>)
|
15
|
+
97: <span class="ruby-comment cmt"># convert non-nil input to internal format</span>
|
16
|
+
98: <span class="ruby-identifier">quad</span> = [<span class="ruby-identifier">s</span>,<span class="ruby-identifier">p</span>,<span class="ruby-identifier">o</span>,<span class="ruby-identifier">c</span>].<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">internalise</span>(<span class="ruby-identifier">r</span>) }
|
17
|
+
99:
|
18
|
+
100: <span class="ruby-comment cmt"># construct where clause for deletion (for all non-nil input)</span>
|
19
|
+
101: <span class="ruby-identifier">where_clauses</span> = []
|
20
|
+
102: <span class="ruby-identifier">conditions</span> = []
|
21
|
+
103: <span class="ruby-identifier">quad</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span>,<span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
22
|
+
104: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">nil?</span>
|
23
|
+
105: <span class="ruby-identifier">conditions</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">r</span>
|
24
|
+
106: <span class="ruby-identifier">where_clauses</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{SPOC[i]} = ?"</span>
|
25
|
+
107: <span class="ruby-keyword kw">end</span>
|
26
|
+
108: <span class="ruby-keyword kw">end</span>
|
27
|
+
109:
|
28
|
+
110: <span class="ruby-comment cmt"># construct delete string</span>
|
29
|
+
111: <span class="ruby-identifier">ds</span> = <span class="ruby-value str">'delete from triple'</span>
|
30
|
+
112: <span class="ruby-identifier">ds</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" where #{where_clauses.join(' and ')}"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">where_clauses</span>.<span class="ruby-identifier">empty?</span>
|
31
|
+
113:
|
32
|
+
114: <span class="ruby-comment cmt"># execute delete string with possible deletion conditions (for each </span>
|
33
|
+
115: <span class="ruby-comment cmt"># non-empty where clause)</span>
|
34
|
+
116: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">"deleting #{[s,p,o,c].join(' ')}"</span>)
|
35
|
+
117: <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">ds</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">conditions</span>)
|
36
|
+
118:
|
37
|
+
119: <span class="ruby-comment cmt"># delete literal from ferret index</span>
|
38
|
+
120: <span class="ruby-ivar">@ferret</span>.<span class="ruby-identifier">search_each</span>(<span class="ruby-node">"subject:\"#{s}\", object:\"#{o}\""</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">idx</span>, <span class="ruby-identifier">score</span><span class="ruby-operator">|</span>
|
39
|
+
121: <span class="ruby-ivar">@ferret</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">idx</span>)
|
40
|
+
122: <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">keyword_search?</span>
|
41
|
+
123:
|
42
|
+
124: <span class="ruby-ivar">@db</span>
|
43
|
+
125: <span class="ruby-keyword kw">end</span></pre>
|
44
|
+
</body>
|
45
|
+
</html>
|
@@ -0,0 +1,32 @@
|
|
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>add (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 129</span>
|
14
|
+
129: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">s</span>,<span class="ruby-identifier">p</span>,<span class="ruby-identifier">o</span>,<span class="ruby-identifier">c</span>=<span class="ruby-keyword kw">nil</span>)
|
15
|
+
130: <span class="ruby-comment cmt"># check illegal input</span>
|
16
|
+
131: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-node">"adding non-resource #{s} while adding (#{s},#{p},#{o},#{c})"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:uri</span>)
|
17
|
+
132: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-node">"adding non-resource #{p} while adding (#{s},#{p},#{o},#{c})"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:uri</span>)
|
18
|
+
133:
|
19
|
+
134: <span class="ruby-identifier">triple</span> = [<span class="ruby-identifier">s</span>, <span class="ruby-identifier">p</span>, <span class="ruby-identifier">o</span>].<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span> <span class="ruby-identifier">serialise</span>(<span class="ruby-identifier">r</span>) }
|
20
|
+
135: <span class="ruby-identifier">add_ntriples</span>(<span class="ruby-identifier">triple</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">' '</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">" .\n"</span>, <span class="ruby-identifier">serialise</span>(<span class="ruby-identifier">c</span>) )
|
21
|
+
136:
|
22
|
+
137: <span class="ruby-comment cmt">## get internal representation (array)</span>
|
23
|
+
138: <span class="ruby-comment cmt">#quad = [s,p,o,c].collect {|r| internalise(r) }</span>
|
24
|
+
139:
|
25
|
+
140: <span class="ruby-comment cmt">## insert the triple into the datastore</span>
|
26
|
+
141: <span class="ruby-comment cmt">#@db.execute('insert into triple values (?,?,?,?)', *quad)</span>
|
27
|
+
142:
|
28
|
+
143: <span class="ruby-comment cmt">## if keyword-search available, insert the object into keyword search</span>
|
29
|
+
144: <span class="ruby-comment cmt">#@ferret << {:subject => s, :object => o} if keyword_search?</span>
|
30
|
+
145: <span class="ruby-keyword kw">end</span></pre>
|
31
|
+
</body>
|
32
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
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>flush (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 148</span>
|
14
|
+
148: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">flush</span>
|
15
|
+
149: <span class="ruby-comment cmt"># since we always write changes into sqlite3 immediately, we don't do </span>
|
16
|
+
150: <span class="ruby-comment cmt"># anything here</span>
|
17
|
+
151: <span class="ruby-keyword kw">true</span>
|
18
|
+
152: <span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,24 @@
|
|
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>load (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 155</span>
|
14
|
+
155: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load</span>(<span class="ruby-identifier">file</span>)
|
15
|
+
156: <span class="ruby-identifier">ntriples</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">readlines</span>(<span class="ruby-identifier">file</span>)
|
16
|
+
157: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"read #{ntriples.size} triples from file #{file}"</span>
|
17
|
+
158:
|
18
|
+
159: <span class="ruby-comment cmt"># use filename as context</span>
|
19
|
+
160: <span class="ruby-identifier">context</span> = <span class="ruby-identifier">internalise</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-node">"file:#{file}"</span>))
|
20
|
+
161:
|
21
|
+
162: <span class="ruby-identifier">add_ntriples</span>(<span class="ruby-identifier">ntriples</span>, <span class="ruby-identifier">context</span>)
|
22
|
+
163: <span class="ruby-keyword kw">end</span></pre>
|
23
|
+
</body>
|
24
|
+
</html>
|
@@ -0,0 +1,36 @@
|
|
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>add_ntriples (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 166</span>
|
14
|
+
166: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_ntriples</span>(<span class="ruby-identifier">ntriples</span>, <span class="ruby-identifier">context</span>)
|
15
|
+
167:
|
16
|
+
168: <span class="ruby-comment cmt"># add each triple to db</span>
|
17
|
+
169: <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">transaction</span>
|
18
|
+
170: <span class="ruby-identifier">insert</span> = <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">prepare</span>(<span class="ruby-value str">'insert into triple values (?,?,?,?);'</span>)
|
19
|
+
171:
|
20
|
+
172: <span class="ruby-identifier">ntriples</span> = <span class="ruby-constant">NTriplesParser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">ntriples</span>)
|
21
|
+
173: <span class="ruby-identifier">ntriples</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>,<span class="ruby-identifier">p</span>,<span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
|
22
|
+
174: <span class="ruby-comment cmt"># convert triples into internal db format</span>
|
23
|
+
175: <span class="ruby-identifier">subject</span>, <span class="ruby-identifier">predicate</span>, <span class="ruby-identifier">object</span> = [<span class="ruby-identifier">s</span>,<span class="ruby-identifier">p</span>,<span class="ruby-identifier">o</span>].<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span> <span class="ruby-identifier">internalise</span>(<span class="ruby-identifier">r</span>) }
|
24
|
+
176:
|
25
|
+
177: <span class="ruby-comment cmt"># insert triple into database</span>
|
26
|
+
178: <span class="ruby-identifier">insert</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">subject</span>, <span class="ruby-identifier">predicate</span>, <span class="ruby-identifier">object</span>, <span class="ruby-identifier">context</span>)
|
27
|
+
179:
|
28
|
+
180: <span class="ruby-comment cmt"># if keyword-search available, insert the object into keyword search</span>
|
29
|
+
181: <span class="ruby-ivar">@ferret</span> <span class="ruby-operator"><<</span> {<span class="ruby-identifier">:subject</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">subject</span>, <span class="ruby-identifier">:object</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">object</span>} <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">keyword_search?</span>
|
30
|
+
182: <span class="ruby-keyword kw">end</span>
|
31
|
+
183:
|
32
|
+
184: <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">commit</span>
|
33
|
+
185: <span class="ruby-ivar">@db</span>
|
34
|
+
186: <span class="ruby-keyword kw">end</span></pre>
|
35
|
+
</body>
|
36
|
+
</html>
|
@@ -0,0 +1,33 @@
|
|
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>query (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 189</span>
|
14
|
+
189: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query</span>(<span class="ruby-identifier">query</span>)
|
15
|
+
190: <span class="ruby-comment cmt"># construct query clauses</span>
|
16
|
+
191: <span class="ruby-identifier">sql</span>, <span class="ruby-identifier">conditions</span> = <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">query</span>)
|
17
|
+
192:
|
18
|
+
193: <span class="ruby-comment cmt"># executing query, passing all where-clause values as parameters (so that </span>
|
19
|
+
194: <span class="ruby-comment cmt"># sqlite will encode quotes correctly)</span>
|
20
|
+
195: <span class="ruby-identifier">results</span> = <span class="ruby-ivar">@db</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">conditions</span>)
|
21
|
+
196:
|
22
|
+
197: <span class="ruby-comment cmt"># if ASK query, we check whether we received a positive result count</span>
|
23
|
+
198: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">query</span>.<span class="ruby-identifier">ask?</span>
|
24
|
+
199: <span class="ruby-keyword kw">return</span> [[<span class="ruby-identifier">results</span>[<span class="ruby-value">0</span>][<span class="ruby-value">0</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>]]
|
25
|
+
200: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">query</span>.<span class="ruby-identifier">count?</span>
|
26
|
+
201: <span class="ruby-keyword kw">return</span> [[<span class="ruby-identifier">results</span>[<span class="ruby-value">0</span>][<span class="ruby-value">0</span>].<span class="ruby-identifier">to_i</span>]]
|
27
|
+
202: <span class="ruby-keyword kw">else</span>
|
28
|
+
203: <span class="ruby-comment cmt"># otherwise we convert results to ActiveRDF nodes and return them</span>
|
29
|
+
204: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">wrap</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">results</span>)
|
30
|
+
205: <span class="ruby-keyword kw">end</span>
|
31
|
+
206: <span class="ruby-keyword kw">end</span></pre>
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,19 @@
|
|
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>translate (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 209</span>
|
14
|
+
209: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">query</span>)
|
15
|
+
210: <span class="ruby-identifier">where</span>, <span class="ruby-identifier">conditions</span> = <span class="ruby-identifier">construct_where</span>(<span class="ruby-identifier">query</span>)
|
16
|
+
211: [<span class="ruby-identifier">construct_select</span>(<span class="ruby-identifier">query</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">construct_join</span>(<span class="ruby-identifier">query</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">where</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">construct_sort</span>(<span class="ruby-identifier">query</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">construct_limit</span>(<span class="ruby-identifier">query</span>), <span class="ruby-identifier">conditions</span>]
|
17
|
+
212: <span class="ruby-keyword kw">end</span></pre>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,27 @@
|
|
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>subproperties (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 414</span>
|
14
|
+
414: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">subproperties</span>(<span class="ruby-identifier">resource</span>)
|
15
|
+
415: <span class="ruby-identifier">subproperty</span> = <span class="ruby-constant">Namespace</span>.<span class="ruby-identifier">lookup</span>(<span class="ruby-identifier">:rdfs</span>,<span class="ruby-identifier">:subPropertyOf</span>)
|
16
|
+
416: <span class="ruby-identifier">children_query</span> = <span class="ruby-constant">Query</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">distinct</span>(<span class="ruby-identifier">:sub</span>).<span class="ruby-identifier">where</span>(<span class="ruby-identifier">:sub</span>, <span class="ruby-identifier">subproperty</span>, <span class="ruby-identifier">resource</span>)
|
17
|
+
417: <span class="ruby-identifier">children_query</span>.<span class="ruby-identifier">reasoning</span> = <span class="ruby-keyword kw">false</span>
|
18
|
+
418: <span class="ruby-identifier">children</span> = <span class="ruby-identifier">children_query</span>.<span class="ruby-identifier">execute</span>
|
19
|
+
419:
|
20
|
+
420: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">children</span>.<span class="ruby-identifier">empty?</span>
|
21
|
+
421: [<span class="ruby-identifier">resource</span>]
|
22
|
+
422: <span class="ruby-keyword kw">else</span>
|
23
|
+
423: [<span class="ruby-identifier">resource</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">children</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">subproperties</span>(<span class="ruby-identifier">c</span>)}.<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">compact</span>
|
24
|
+
424: <span class="ruby-keyword kw">end</span>
|
25
|
+
425: <span class="ruby-keyword kw">end</span></pre>
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,137 @@
|
|
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: String</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">String</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
|
+
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="#M000016">double_quote</a>
|
90
|
+
</div>
|
91
|
+
</div>
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
<!-- if includes -->
|
97
|
+
|
98
|
+
<div id="section">
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<!-- if method_list -->
|
108
|
+
<div id="methods">
|
109
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
110
|
+
|
111
|
+
<div id="method-M000016" class="method-detail">
|
112
|
+
<a name="M000016"></a>
|
113
|
+
|
114
|
+
<div class="method-heading">
|
115
|
+
<a href="String.src/M000016.html" target="Code" class="method-signature"
|
116
|
+
onclick="popupCode('String.src/M000016.html');return false;">
|
117
|
+
<span class="method-name">double_quote</span><span class="method-args">()</span>
|
118
|
+
</a>
|
119
|
+
</div>
|
120
|
+
|
121
|
+
<div class="method-description">
|
122
|
+
</div>
|
123
|
+
</div>
|
124
|
+
|
125
|
+
|
126
|
+
</div>
|
127
|
+
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
|
132
|
+
<div id="validator-badges">
|
133
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
</body>
|
137
|
+
</html>
|