pho 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/README.html +176 -0
- data/doc/rdoc/fr_class_index.html +26 -0
- data/doc/rdoc/fr_file_index.html +27 -0
- data/doc/rdoc/fr_method_index.html +26 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/lib/pho.rb +3 -0
- data/lib/pho/field_predicate_map.rb +268 -0
- data/lib/pho/rdf_collection.rb +26 -5
- data/lib/pho/snapshot.rb +0 -1
- data/lib/pho/store.rb +24 -0
- data/tests/tc_field_predicate_map.rb +299 -0
- data/tests/tc_rdf_collection.rb +9 -4
- data/tests/ts_pho.rb +1 -0
- metadata +14 -2
data/Rakefile
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Wed, 25 Feb 2009 12:58:32 +0000
|
@@ -0,0 +1,176 @@
|
|
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>File: README</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="fileHeader">
|
50
|
+
<h1>README</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>README
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Fri Feb 20 20:41:16 +0000 2009</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
The Pho ruby module provides a lightweight Ruby client library for
|
74
|
+
interacting with the Talis Platform API (<a
|
75
|
+
href="http://n2.talis.com/wiki/Platform_API">n2.talis.com/wiki/Platform_API</a>).
|
76
|
+
</p>
|
77
|
+
<h2>Author</h2>
|
78
|
+
<p>
|
79
|
+
Leigh Dodds (leigh.dodds@talis.com)
|
80
|
+
</p>
|
81
|
+
<h2>Download</h2>
|
82
|
+
<p>
|
83
|
+
The latest version of this library can be downloaded from:
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
<a href="http://pho.rubyforge.net">pho.rubyforge.net</a>
|
87
|
+
</p>
|
88
|
+
<h2>Usage</h2>
|
89
|
+
<p>
|
90
|
+
To use Pho you can:
|
91
|
+
</p>
|
92
|
+
<pre>
|
93
|
+
require 'pho'
|
94
|
+
</pre>
|
95
|
+
<p>
|
96
|
+
And then create an instance of the appropriate class, e.g Store:
|
97
|
+
</p>
|
98
|
+
<pre>
|
99
|
+
store = Pho::Store.new("http://api.talis.com/testing", "user", "pass")
|
100
|
+
response = store.describe("http://www.example.org")
|
101
|
+
</pre>
|
102
|
+
<p>
|
103
|
+
For more detailed examples consult the documentation for the Store class
|
104
|
+
</p>
|
105
|
+
<h2>Control over HTTP interactions</h2>
|
106
|
+
<p>
|
107
|
+
Pho is dependent on the HTTPClient module and all HTTP interactions are
|
108
|
+
delegated to an instance of the HTTPClient class. In circumstances where
|
109
|
+
greater control over the HTTP interaction is required, e.g. to configure
|
110
|
+
proxy servers, etc, an existing instance of this class can be provided,
|
111
|
+
e.g:
|
112
|
+
</p>
|
113
|
+
<pre>
|
114
|
+
client = HTTPClient.new
|
115
|
+
=> configure client as required
|
116
|
+
store = Pho::Store.new("http://api.talis.com/testing", "user", "pass", client)
|
117
|
+
=> pass instance of client as parameter
|
118
|
+
response = store.describe("http://www.example.org")
|
119
|
+
</pre>
|
120
|
+
<h2>License</h2>
|
121
|
+
<p>
|
122
|
+
Copyright 2009 Leigh Dodds
|
123
|
+
</p>
|
124
|
+
<p>
|
125
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
126
|
+
you may not use this file except in compliance with the License.
|
127
|
+
</p>
|
128
|
+
<p>
|
129
|
+
You may obtain a copy of the License at
|
130
|
+
</p>
|
131
|
+
<p>
|
132
|
+
<a
|
133
|
+
href="http://www.apache.org/licenses/LICENSE-2.0">www.apache.org/licenses/LICENSE-2.0</a>
|
134
|
+
</p>
|
135
|
+
<p>
|
136
|
+
Unless required by applicable law or agreed to in writing, software
|
137
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
138
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
139
|
+
</p>
|
140
|
+
<p>
|
141
|
+
See the License for the specific language governing permissions and
|
142
|
+
limitations under the License.
|
143
|
+
</p>
|
144
|
+
|
145
|
+
</div>
|
146
|
+
|
147
|
+
|
148
|
+
</div>
|
149
|
+
|
150
|
+
|
151
|
+
</div>
|
152
|
+
|
153
|
+
|
154
|
+
<!-- if includes -->
|
155
|
+
|
156
|
+
<div id="section">
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
<!-- if method_list -->
|
166
|
+
|
167
|
+
|
168
|
+
</div>
|
169
|
+
|
170
|
+
|
171
|
+
<div id="validator-badges">
|
172
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
173
|
+
</div>
|
174
|
+
|
175
|
+
</body>
|
176
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
3
|
+
<!DOCTYPE html
|
4
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
5
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
6
|
+
|
7
|
+
<!--
|
8
|
+
|
9
|
+
Classes
|
10
|
+
|
11
|
+
-->
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
13
|
+
<head>
|
14
|
+
<title>Classes</title>
|
15
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
16
|
+
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
|
17
|
+
<base target="docwin" />
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div id="index">
|
21
|
+
<h1 class="section-bar">Classes</h1>
|
22
|
+
<div id="index-entries">
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
3
|
+
<!DOCTYPE html
|
4
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
5
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
6
|
+
|
7
|
+
<!--
|
8
|
+
|
9
|
+
Files
|
10
|
+
|
11
|
+
-->
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
13
|
+
<head>
|
14
|
+
<title>Files</title>
|
15
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
16
|
+
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
|
17
|
+
<base target="docwin" />
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div id="index">
|
21
|
+
<h1 class="section-bar">Files</h1>
|
22
|
+
<div id="index-entries">
|
23
|
+
<a href="files/README.html">README</a><br />
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
3
|
+
<!DOCTYPE html
|
4
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
5
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
6
|
+
|
7
|
+
<!--
|
8
|
+
|
9
|
+
Methods
|
10
|
+
|
11
|
+
-->
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
13
|
+
<head>
|
14
|
+
<title>Methods</title>
|
15
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
16
|
+
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
|
17
|
+
<base target="docwin" />
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div id="index">
|
21
|
+
<h1 class="section-bar">Methods</h1>
|
22
|
+
<div id="index-entries">
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/doc/rdoc/index.html
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
5
|
+
|
6
|
+
<!--
|
7
|
+
|
8
|
+
Pho (Talis Platform Client) Reference
|
9
|
+
|
10
|
+
-->
|
11
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
12
|
+
<head>
|
13
|
+
<title>Pho (Talis Platform Client) Reference</title>
|
14
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
15
|
+
</head>
|
16
|
+
<frameset rows="20%, 80%">
|
17
|
+
<frameset cols="25%,35%,45%">
|
18
|
+
<frame src="fr_file_index.html" title="Files" name="Files" />
|
19
|
+
<frame src="fr_class_index.html" name="Classes" />
|
20
|
+
<frame src="fr_method_index.html" name="Methods" />
|
21
|
+
</frameset>
|
22
|
+
<frame src="files/README.html" name="docwin" />
|
23
|
+
</frameset>
|
24
|
+
</html>
|
@@ -0,0 +1,208 @@
|
|
1
|
+
|
2
|
+
body {
|
3
|
+
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
+
font-size: 90%;
|
5
|
+
margin: 0;
|
6
|
+
margin-left: 40px;
|
7
|
+
padding: 0;
|
8
|
+
background: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
+
h1 { font-size: 150%; }
|
13
|
+
h2,h3,h4 { margin-top: 1em; }
|
14
|
+
|
15
|
+
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
+
a:hover { background: #039; color: #eef; }
|
17
|
+
|
18
|
+
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
+
td > a {
|
20
|
+
background: transparent;
|
21
|
+
color: #039;
|
22
|
+
text-decoration: none;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* and inside a section title */
|
26
|
+
.section-title > a {
|
27
|
+
background: transparent;
|
28
|
+
color: #eee;
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
/* === Structural elements =================================== */
|
33
|
+
|
34
|
+
div#index {
|
35
|
+
margin: 0;
|
36
|
+
margin-left: -40px;
|
37
|
+
padding: 0;
|
38
|
+
font-size: 90%;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
div#index a {
|
43
|
+
margin-left: 0.7em;
|
44
|
+
}
|
45
|
+
|
46
|
+
div#index .section-bar {
|
47
|
+
margin-left: 0px;
|
48
|
+
padding-left: 0.7em;
|
49
|
+
background: #ccc;
|
50
|
+
font-size: small;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
div#classHeader, div#fileHeader {
|
55
|
+
width: auto;
|
56
|
+
color: white;
|
57
|
+
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
+
margin: 0;
|
59
|
+
margin-left: -40px;
|
60
|
+
border-bottom: 3px solid #006;
|
61
|
+
}
|
62
|
+
|
63
|
+
div#classHeader a, div#fileHeader a {
|
64
|
+
background: inherit;
|
65
|
+
color: white;
|
66
|
+
}
|
67
|
+
|
68
|
+
div#classHeader td, div#fileHeader td {
|
69
|
+
background: inherit;
|
70
|
+
color: white;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
div#fileHeader {
|
75
|
+
background: #057;
|
76
|
+
}
|
77
|
+
|
78
|
+
div#classHeader {
|
79
|
+
background: #048;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
.class-name-in-header {
|
84
|
+
font-size: 180%;
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
div#bodyContent {
|
90
|
+
padding: 0 1.5em 0 1.5em;
|
91
|
+
}
|
92
|
+
|
93
|
+
div#description {
|
94
|
+
padding: 0.5em 1.5em;
|
95
|
+
background: #efefef;
|
96
|
+
border: 1px dotted #999;
|
97
|
+
}
|
98
|
+
|
99
|
+
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
+
color: #125;;
|
101
|
+
background: transparent;
|
102
|
+
}
|
103
|
+
|
104
|
+
div#validator-badges {
|
105
|
+
text-align: center;
|
106
|
+
}
|
107
|
+
div#validator-badges img { border: 0; }
|
108
|
+
|
109
|
+
div#copyright {
|
110
|
+
color: #333;
|
111
|
+
background: #efefef;
|
112
|
+
font: 0.75em sans-serif;
|
113
|
+
margin-top: 5em;
|
114
|
+
margin-bottom: 0;
|
115
|
+
padding: 0.5em 2em;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/* === Classes =================================== */
|
120
|
+
|
121
|
+
table.header-table {
|
122
|
+
color: white;
|
123
|
+
font-size: small;
|
124
|
+
}
|
125
|
+
|
126
|
+
.type-note {
|
127
|
+
font-size: small;
|
128
|
+
color: #DEDEDE;
|
129
|
+
}
|
130
|
+
|
131
|
+
.xxsection-bar {
|
132
|
+
background: #eee;
|
133
|
+
color: #333;
|
134
|
+
padding: 3px;
|
135
|
+
}
|
136
|
+
|
137
|
+
.section-bar {
|
138
|
+
color: #333;
|
139
|
+
border-bottom: 1px solid #999;
|
140
|
+
margin-left: -20px;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
.section-title {
|
145
|
+
background: #79a;
|
146
|
+
color: #eee;
|
147
|
+
padding: 3px;
|
148
|
+
margin-top: 2em;
|
149
|
+
margin-left: -30px;
|
150
|
+
border: 1px solid #999;
|
151
|
+
}
|
152
|
+
|
153
|
+
.top-aligned-row { vertical-align: top }
|
154
|
+
.bottom-aligned-row { vertical-align: bottom }
|
155
|
+
|
156
|
+
/* --- Context section classes ----------------------- */
|
157
|
+
|
158
|
+
.context-row { }
|
159
|
+
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
+
.context-item-value { font-size: small; color: #448; }
|
161
|
+
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
+
|
163
|
+
/* --- Method classes -------------------------- */
|
164
|
+
.method-detail {
|
165
|
+
background: #efefef;
|
166
|
+
padding: 0;
|
167
|
+
margin-top: 0.5em;
|
168
|
+
margin-bottom: 1em;
|
169
|
+
border: 1px dotted #ccc;
|
170
|
+
}
|
171
|
+
.method-heading {
|
172
|
+
color: black;
|
173
|
+
background: #ccc;
|
174
|
+
border-bottom: 1px solid #666;
|
175
|
+
padding: 0.2em 0.5em 0 0.5em;
|
176
|
+
}
|
177
|
+
.method-signature { color: black; background: inherit; }
|
178
|
+
.method-name { font-weight: bold; }
|
179
|
+
.method-args { font-style: italic; }
|
180
|
+
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
+
|
182
|
+
/* --- Source code sections -------------------- */
|
183
|
+
|
184
|
+
a.source-toggle { font-size: 90%; }
|
185
|
+
div.method-source-code {
|
186
|
+
background: #262626;
|
187
|
+
color: #ffdead;
|
188
|
+
margin: 1em;
|
189
|
+
padding: 0.5em;
|
190
|
+
border: 1px dashed #999;
|
191
|
+
overflow: hidden;
|
192
|
+
}
|
193
|
+
|
194
|
+
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
+
|
196
|
+
/* --- Ruby keyword styles --------------------- */
|
197
|
+
|
198
|
+
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
+
|
200
|
+
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
+
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
+
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
+
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
+
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
+
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
+
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
+
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
+
.ruby-value { color: #7fffd4; background: transparent; }
|
data/lib/pho.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'httpclient'
|
3
3
|
require 'json'
|
4
|
+
require 'yaml'
|
4
5
|
|
5
6
|
require 'pho/etags'
|
6
7
|
require 'pho/store'
|
7
8
|
require 'pho/snapshot'
|
9
|
+
require 'pho/field_predicate_map'
|
8
10
|
require 'pho/rdf_collection'
|
9
11
|
|
10
12
|
module Pho
|
@@ -21,5 +23,6 @@ module Pho
|
|
21
23
|
|
22
24
|
|
23
25
|
NAMESPACE_CONFIG = "http://schemas.talis.com/2006/bigfoot/configuration#"
|
26
|
+
NAMESPACE_FRAME = "http://schemas.talis.com/2006/frame/schema#"
|
24
27
|
|
25
28
|
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
module Pho
|
2
|
+
|
3
|
+
#Declares URI constants for the various text analyzers supported by the Talis Platform
|
4
|
+
#
|
5
|
+
#Analyzers are configured to operate on specific DataTypePropertys using the FieldPredicateMap
|
6
|
+
class Analyzers
|
7
|
+
|
8
|
+
#A standard English analyzer and the default if no analyzer is specified. Words are split on punctuation characters, removing the punctuation. Words containing a dot are not split. Words containing both hyphens and numbers are not split. Email addresses and hostnames are not split. Stop words are removed. Searches on fields with this type of analyzer are case insensitive.
|
9
|
+
#
|
10
|
+
#The following words are considered to be stop words and will not be indexed: a, an, and, are, as, at, be, but, by, for, if, in, into, is, it, no, not, of, on, or, such, that, the, their, then, there, these, they, this, to, was, will, with
|
11
|
+
STANDARD = "http://schemas.talis.com/2007/bigfoot/analyzers#standard-en".freeze
|
12
|
+
|
13
|
+
#A standard Greek language analyzer. Words are split on punctuation characters, removing the punctuation. Words containing a dot are not split. Words containing both hyphens and numbers are not split. Email addresses and hostnames are not split. Stop words are removed. Searches on fields with this type of analyzer are case insensitive.
|
14
|
+
GREEK = "http://schemas.talis.com/2007/bigfoot/analyzers#standard-el".freeze
|
15
|
+
|
16
|
+
#A standard German language analyzer. Words are split on punctuation characters, removing the punctuation. Words containing a dot are not split. Words containing both hyphens and numbers are not split. Email addresses and hostnames are not split. Stop words are removed and any remaining words are stemmed. Searches on fields with this type of analyzer are case insensitive.
|
17
|
+
|
18
|
+
#The following words are considered to be stop words and will not be indexed: einer, eine, eines, einem, einen, der, die, das, dass, daß, du, er, sie, es, was, wer, wie, wir, und, oder, ohne, mit, am, im, in, aus, auf, ist, sein, war, wird, ihr, ihre, ihres, als, für, von, mit, dich, dir, mich, mir, mein, sein, kein, durch, wegen, wird
|
19
|
+
GERMAN = "http://schemas.talis.com/2007/bigfoot/analyzers#standard-de".freeze
|
20
|
+
|
21
|
+
#A standard French language analyzer. Words are split on punctuation characters, removing the punctuation. Words containing a dot are not split. Words containing both hyphens and numbers are not split. Email addresses and hostnames are not split. Stop words are removed and any remaining words are stemmed. Searches on fields with this type of analyzer are case insensitive.
|
22
|
+
#
|
23
|
+
#The following words are considered to be stop words and will not be indexed: a, afin, ai, ainsi, après, attendu, au, aujourd, auquel, aussi, autre, autres, aux, auxquelles, auxquels, avait, avant, avec, avoir, c, car, ce, ceci, cela, celle, celles, celui, cependant, certain, certaine, certaines, certains, ces, cet, cette, ceux, chez, ci, combien, comme, comment, concernant, contre, d, dans, de, debout, dedans, dehors, delà, depuis, derrière, des, désormais, desquelles, desquels, dessous, dessus, devant, devers, devra, divers, diverse, diverses, doit, donc, dont, du, duquel, durant, dès, elle, elles, en, entre, environ, est, et, etc, etre, eu, eux, excepté, hormis, hors, hélas, hui, il, ils, j, je, jusqu, jusque, l, la, laquelle, le, lequel, les, lesquelles, lesquels, leur, leurs, lorsque, lui, là, ma, mais, malgré, me, merci, mes, mien, mienne, miennes, miens, moi, moins, mon, moyennant, même, mêmes, n, ne, ni, non, nos, notre, nous, néanmoins, nôtre, nôtres, on, ont, ou, outre, où, par, parmi, partant, pas, passé, pendant, plein, plus, plusieurs, pour, pourquoi, proche, près, puisque, qu, quand, que, quel, quelle, quelles, quels, qui, quoi, quoique, revoici, revoilà, s, sa, sans, sauf, se, selon, seront, ses, si, sien, sienne, siennes, siens, sinon, soi, soit, son, sont, sous, suivant, sur, ta, te, tes, tien, tienne, tiennes, tiens, toi, ton, tous, tout, toute, toutes, tu, un, une, va, vers, voici, voilà, vos, votre, vous, vu, vôtre, vôtres, y, à, ça, ès, été, être, ô.
|
24
|
+
FRENCH = "http://schemas.talis.com/2007/bigfoot/analyzers#standard-fr".freeze
|
25
|
+
|
26
|
+
#A standard CJK language analyzer.
|
27
|
+
CJK = "http://schemas.talis.com/2007/bigfoot/analyzers#standard-cjk".freeze
|
28
|
+
|
29
|
+
#A standard Dutch language analyzer. Words are split on punctuation characters, removing the punctuation. Words containing a dot are not split. Words containing both hyphens and numbers are not split. Email addresses and hostnames are not split. Stop words are removed. Searches on fields with this type of analyzer are case sensitive.
|
30
|
+
|
31
|
+
#The following words are considered to be stop words and will not be indexed: de, en, van, ik, te, dat, die, in, een, hij, het, niet, zijn, is, was, op, aan, met, als, voor, had, er, maar, om, hem, dan, zou, of, wat, mijn, men, dit, zo, door, over, ze, zich, bij, ook, tot, je, mij, uit, der, daar, haar, naar, heb, hoe, heeft, hebben, deze, u, want, nog, zal, me, zij, nu, ge, geen, omdat, iets, worden, toch, al, waren, veel, meer, doen, toen, moet, ben, zonder, kan, hun, dus, alles, onder, ja, eens, hier, wie, werd, altijd, doch, wordt, wezen, kunnen, ons, zelf, tegen, na, reeds, wil, kon, niets, uw, iemand, geweest, andere
|
32
|
+
DUTCH = "http://schemas.talis.com/2007/bigfoot/analyzers#standard-nl".freeze
|
33
|
+
|
34
|
+
CHINESE = "http://schemas.talis.com/2007/bigfoot/analyzers#standard-cn".freeze
|
35
|
+
|
36
|
+
#This analyzer does not split the field at all. The entire value of the field is indexed as a single token.
|
37
|
+
KEYWORD = "http://schemas.talis.com/2007/bigfoot/analyzers#keyword".freeze
|
38
|
+
|
39
|
+
#English analyzer without stop words. This is identical to the standard English analyzer but all words are indexed.
|
40
|
+
NO_STOP_WORD_STANDARD = "http://schemas.talis.com/2007/bigfoot/analyzers#nostop-en".freeze
|
41
|
+
|
42
|
+
#English analyzer without stop words and with accent support. This is identical to the standard English analyzer but all words are indexed plus any accented characters in the ISO Latin 1 character set are replaced by their unaccented equivalent
|
43
|
+
#See API documentation at http://n2.talis.com/wiki/Field_Predicate_Map for details of replacements
|
44
|
+
NORMALISE_STANDARD = "http://schemas.talis.com/2007/bigfoot/analyzers#norm-en".freeze
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
#Captures information about a mapped datatype from a Field Predicate Map
|
49
|
+
class DatatypeProperty
|
50
|
+
#URI for this mapping
|
51
|
+
attr_reader :uri
|
52
|
+
#RDF predicate URI for the mapped property
|
53
|
+
attr_reader :property_uri
|
54
|
+
#Short name for the property
|
55
|
+
attr_reader :name
|
56
|
+
#URI of the analyzer associated with this property
|
57
|
+
attr_reader :analyzer
|
58
|
+
|
59
|
+
def initialize(uri, property_uri, name, analyzer=nil)
|
60
|
+
@uri = uri
|
61
|
+
@property_uri = property_uri
|
62
|
+
@name = name
|
63
|
+
@analyzer = analyzer
|
64
|
+
end
|
65
|
+
|
66
|
+
#Convert this object into an RDF representation. Generates a simple rdf:Description, optionally including namespaces
|
67
|
+
#ns:: include namespace declarations
|
68
|
+
def to_rdf(ns=true)
|
69
|
+
rdf = "<rdf:Description "
|
70
|
+
if ns
|
71
|
+
rdf << " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:frm=\"#{Pho::NAMESPACE_FRAME}\" xmlns:bf=\"#{Pho::NAMESPACE_CONFIG}\" "
|
72
|
+
end
|
73
|
+
rdf << " rdf:about=\"#{@uri}\">"
|
74
|
+
rdf << " <frm:property rdf:resource=\"#{@property_uri}\"/>"
|
75
|
+
rdf << " <frm:name>#{@name}</frm:name>"
|
76
|
+
if @analyzer != nil
|
77
|
+
rdf << " <bf:analyzer rdf:resource=\"#{@analyzer}\" />"
|
78
|
+
end
|
79
|
+
rdf << "</rdf:Description>"
|
80
|
+
return rdf
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
#Models a the Field Predicate Map configuration associated with a Platform Store.
|
86
|
+
#
|
87
|
+
#Class methods exist to create a FieldPredicateMap instance by reading from a store, and to
|
88
|
+
#create DatatypeProperty instances checking that the supplied data is valid according to the
|
89
|
+
#same logic as used by the Platform API.
|
90
|
+
class FieldPredicateMap
|
91
|
+
|
92
|
+
#Label associated with the resource in the Platform config
|
93
|
+
attr_reader :label
|
94
|
+
|
95
|
+
#URI for this resource
|
96
|
+
attr_reader :uri
|
97
|
+
|
98
|
+
#An array of DatatypeProperty instances
|
99
|
+
attr_reader :datatype_properties
|
100
|
+
|
101
|
+
|
102
|
+
#Read a FieldPredicateMap instance from the provided store. The method will retrieve the config
|
103
|
+
#as JSON, and parse it to create an object instance.
|
104
|
+
def FieldPredicateMap.read_from_store(store)
|
105
|
+
resp = store.get_field_predicate_map(Pho::ACCEPT_JSON)
|
106
|
+
if resp.status != 200
|
107
|
+
raise "Unable to read Field Predicate Map from store. Response code was #{resp.status}"
|
108
|
+
end
|
109
|
+
|
110
|
+
fpmap_uri = store.build_uri("/config/fpmaps/1")
|
111
|
+
|
112
|
+
json = JSON.parse( resp.content )
|
113
|
+
|
114
|
+
label = json[fpmap_uri]["http:\/\/www.w3.org\/2000\/01\/rdf-schema#label"][0]["value"]
|
115
|
+
fpmap = FieldPredicateMap.new(fpmap_uri, label)
|
116
|
+
|
117
|
+
mapped_properties = json[fpmap_uri]["http:\/\/schemas.talis.com\/2006\/frame\/schema#mappedDatatypeProperty"]
|
118
|
+
mapped_properties.each { |uri|
|
119
|
+
property = json[uri["value"]]
|
120
|
+
property_uri = property["http:\/\/schemas.talis.com\/2006\/frame\/schema#property"][0]["value"]
|
121
|
+
name = property["http:\/\/schemas.talis.com\/2006\/frame\/schema#name"][0]["value"]
|
122
|
+
fpmap << DatatypeProperty.new(uri["value"], property_uri, name)
|
123
|
+
}
|
124
|
+
|
125
|
+
return fpmap
|
126
|
+
end
|
127
|
+
|
128
|
+
#Create a DatatypeProperty instance, automatically assigning a unique identifier to it, and adding
|
129
|
+
#validating the supplied data to ensure it matches the platform rules
|
130
|
+
def FieldPredicateMap.create_mapping(store, property_uri, name, analyzer=nil)
|
131
|
+
check_value("property_uri", property_uri)
|
132
|
+
check_value("name", name)
|
133
|
+
if !name.match(/^[a-zA-Z][a-zA-Z0-9]*$/)
|
134
|
+
raise "Name does not conform to regular expression: ^[a-zA-Z][a-zA-Z0-9]*$"
|
135
|
+
end
|
136
|
+
if analyzer != nil && analyzer.empty?
|
137
|
+
analyzer = nil
|
138
|
+
end
|
139
|
+
suffix = get_suffix(property_uri)
|
140
|
+
mapping_uri = store.build_uri("/config/fpmaps/1##{suffix}")
|
141
|
+
return DatatypeProperty.new(mapping_uri, property_uri, name, analyzer)
|
142
|
+
end
|
143
|
+
|
144
|
+
def initialize(uri, label, datatype_properties = [])
|
145
|
+
@uri = uri
|
146
|
+
@label = label
|
147
|
+
@datatype_properties = datatype_properties
|
148
|
+
end
|
149
|
+
|
150
|
+
#Append a DatatypeProperty object to this map.
|
151
|
+
#Note that the method does not validate the object, and neither does it check for
|
152
|
+
#duplicate mappings.
|
153
|
+
def <<(obj)
|
154
|
+
@datatype_properties << obj
|
155
|
+
end
|
156
|
+
|
157
|
+
#Lookup the name mapped to the specified uri
|
158
|
+
#
|
159
|
+
#uri:: the property uri to search for
|
160
|
+
def get_name(uri)
|
161
|
+
p = @datatype_properties.detect { |mapping| uri == mapping.property_uri }
|
162
|
+
if p == nil
|
163
|
+
return nil
|
164
|
+
else
|
165
|
+
return p.name
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
#Lookup the property mapped to the specified name
|
170
|
+
#
|
171
|
+
#name:: the name to search for
|
172
|
+
def get_property_uri(name)
|
173
|
+
p = @datatype_properties.detect { |mapping| name == mapping.name }
|
174
|
+
if p == nil
|
175
|
+
return nil
|
176
|
+
else
|
177
|
+
return p.property_uri
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
#Is there a mapping for a property with this name?
|
182
|
+
def mapped_name?(name)
|
183
|
+
return get_property_uri(name) != nil
|
184
|
+
end
|
185
|
+
|
186
|
+
#Is there a mapping for this uri?
|
187
|
+
def mapped_uri?(uri)
|
188
|
+
return get_name(uri) != nil
|
189
|
+
end
|
190
|
+
|
191
|
+
#Find the DatatypeProperty (if any) with the following name mapping
|
192
|
+
def get_by_name(name)
|
193
|
+
return @datatype_properties.detect { |mapping| name == mapping.name }
|
194
|
+
end
|
195
|
+
|
196
|
+
#Find the DatatypeProperty using a property uri
|
197
|
+
def get_by_uri(uri)
|
198
|
+
return @datatype_properties.detect { |mapping| uri == mapping.property_uri }
|
199
|
+
end
|
200
|
+
|
201
|
+
#Remove a DatatypeProperty from the collection
|
202
|
+
def remove(datatype_property)
|
203
|
+
return @datatype_properties.delete(datatype_property)
|
204
|
+
end
|
205
|
+
|
206
|
+
#Remove a DatatypeProperty by its mapped name
|
207
|
+
def remove_by_name(name)
|
208
|
+
p = get_by_name(name)
|
209
|
+
if (p != nil)
|
210
|
+
return remove(p)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
#Remove a DatatypeProperty by its mapped uri
|
215
|
+
def remove_by_uri(uri)
|
216
|
+
p = get_by_uri(uri)
|
217
|
+
if (p != nil)
|
218
|
+
return remove(p)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
#Dump this object to an RDF/XML representation suitable for submitting to the Platform
|
223
|
+
def to_rdf
|
224
|
+
rdf = "<rdf:RDF xmlns:frm=\"#{Pho::NAMESPACE_FRAME}\" "
|
225
|
+
rdf << " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" "
|
226
|
+
rdf << " xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" "
|
227
|
+
rdf << " xmlns:bf=\"#{Pho::NAMESPACE_CONFIG}\" > "
|
228
|
+
|
229
|
+
rdf << " <rdf:Description rdf:about=\"#{@uri}\"> "
|
230
|
+
|
231
|
+
rdf << " <rdf:type rdf:resource=\"#{Pho::NAMESPACE_CONFIG}FieldPredicateMap\"/> "
|
232
|
+
rdf << " <rdfs:label>#{@label}</rdfs:label> "
|
233
|
+
|
234
|
+
@datatype_properties.each do |property|
|
235
|
+
rdf << " <frm:mappedDatatypeProperty rdf:resource=\"#{property.uri}\"/> "
|
236
|
+
end
|
237
|
+
|
238
|
+
rdf << " </rdf:Description>"
|
239
|
+
|
240
|
+
@datatype_properties.each do |property|
|
241
|
+
rdf << property.to_rdf(false)
|
242
|
+
end
|
243
|
+
|
244
|
+
rdf << "</rdf:RDF>"
|
245
|
+
end
|
246
|
+
|
247
|
+
#Upload an RDF/XML presentation of this object to the provided Platform Store
|
248
|
+
def upload(store)
|
249
|
+
return store.put_field_predicate_map(self.to_rdf)
|
250
|
+
end
|
251
|
+
|
252
|
+
private
|
253
|
+
def FieldPredicateMap.get_suffix(uri)
|
254
|
+
candidate_suffix = uri.split("/").last
|
255
|
+
if candidate_suffix.index("#") != -1
|
256
|
+
return candidate_suffix.split("#").last
|
257
|
+
end
|
258
|
+
return candidate_suffix
|
259
|
+
end
|
260
|
+
|
261
|
+
def FieldPredicateMap.check_value(name, val)
|
262
|
+
if val == nil or val.empty?
|
263
|
+
raise "#{name} cannot be nil or empty string"
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
data/lib/pho/rdf_collection.rb
CHANGED
@@ -27,16 +27,21 @@ module Pho
|
|
27
27
|
files_to_store = new_files()
|
28
28
|
files_to_store.each do |filename|
|
29
29
|
file = File.new(filename)
|
30
|
-
|
31
|
-
#TODO error checking
|
30
|
+
store_file(file, filename)
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
34
|
#Retry anything known to have failed
|
36
35
|
def retry_failures()
|
37
|
-
|
36
|
+
retries = failures()
|
37
|
+
retries.each do |filename|
|
38
|
+
File.delete( get_fail_file_for(filename) )
|
39
|
+
#store it
|
40
|
+
file = File.new(filename)
|
41
|
+
store_file(file, filename)
|
42
|
+
end
|
38
43
|
end
|
39
|
-
|
44
|
+
|
40
45
|
#Reset the directory to clear out any previous statuses
|
41
46
|
#Store can also be reset at the same time: use with care!
|
42
47
|
def reset(reset_store=false)
|
@@ -102,7 +107,23 @@ module Pho
|
|
102
107
|
def get_ok_file_for(filename)
|
103
108
|
return filename.gsub(/\.#{@rdf_suffix}/, ".#{@ok_suffix}")
|
104
109
|
end
|
105
|
-
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def store_file(file, filename)
|
114
|
+
response = @store.store_file(file)
|
115
|
+
if (response.status < 300 )
|
116
|
+
File.open(get_ok_file_for(filename), "w") do |file|
|
117
|
+
file.print( "OK" )
|
118
|
+
end
|
119
|
+
else
|
120
|
+
File.open(get_fail_file_for(filename), "w") do |file|
|
121
|
+
YAML::dump(response, file)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
106
127
|
end
|
107
128
|
|
108
129
|
end
|
data/lib/pho/snapshot.rb
CHANGED
data/lib/pho/store.rb
CHANGED
@@ -422,7 +422,31 @@ module Pho
|
|
422
422
|
response = @client.get(u, nil, nil)
|
423
423
|
return response
|
424
424
|
end
|
425
|
+
|
426
|
+
#############
|
427
|
+
# CONFIG
|
428
|
+
#############
|
429
|
+
|
430
|
+
#Read the field predicate map configuration for this store. The config can be requested in any
|
431
|
+
#format supported by the platform, but the default will return JSON. See FieldPredicateMap.read_from_store
|
432
|
+
#for a convenient way to quickly create a FieldPredicateMap object based on a specific stores's configuration.
|
433
|
+
#
|
434
|
+
#output:: mimetype to use in request
|
435
|
+
def get_field_predicate_map(output=ACCEPT_JSON)
|
436
|
+
u = build_uri("/config/fpmaps/1")
|
437
|
+
response = @client.get(u, nil, output)
|
438
|
+
return response
|
439
|
+
end
|
425
440
|
|
441
|
+
#Update/replace the current Field Predicate map configuration in the store. Assumes that the provided
|
442
|
+
#data is valid RDF/XML. Use FieldPredicateMap.upload as a convenience function
|
443
|
+
#
|
444
|
+
#data:: a string containing an RDF/XML document
|
445
|
+
def put_field_predicate_map(data)
|
446
|
+
u = build_uri("/config/fpmaps/1")
|
447
|
+
headers = {"Content-Type" => "application/rdf+xml"}
|
448
|
+
return @client.put(u, data, headers)
|
449
|
+
end
|
426
450
|
end
|
427
451
|
|
428
452
|
end
|
@@ -0,0 +1,299 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'pho'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'mocha'
|
5
|
+
require 'rexml/document'
|
6
|
+
|
7
|
+
class FieldPredicateMapTest < Test::Unit::TestCase
|
8
|
+
|
9
|
+
TEST_FPMAP = <<-EOL
|
10
|
+
{
|
11
|
+
"http:\/\/api.talis.com\/stores\/testing\/config\/fpmaps\/1#description" : {
|
12
|
+
"http:\/\/schemas.talis.com\/2006\/frame\/schema#property" : [ { "value" : "http:\/\/purl.org\/dc\/elements\/1.1\/description", "type" : "uri" } ],
|
13
|
+
"http:\/\/schemas.talis.com\/2006\/frame\/schema#name" : [ { "value" : "description", "type" : "literal" } ]
|
14
|
+
},
|
15
|
+
"http:\/\/api.talis.com\/stores\/testing\/config\/fpmaps\/1" : {
|
16
|
+
"http:\/\/www.w3.org\/2000\/01\/rdf-schema#label" : [ { "value" : "default field\/predicate map", "type" : "literal" } ],
|
17
|
+
"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#type" : [ { "value" : "http:\/\/schemas.talis.com\/2006\/bigfoot\/configuration#FieldPredicateMap", "type" : "uri" } ],
|
18
|
+
"http:\/\/schemas.talis.com\/2006\/frame\/schema#mappedDatatypeProperty" : [
|
19
|
+
{ "value" : "http:\/\/api.talis.com\/stores\/testing\/config\/fpmaps\/1#name", "type" : "uri" },
|
20
|
+
{ "value" : "http:\/\/api.talis.com\/stores\/testing\/config\/fpmaps\/1#title", "type" : "uri" },
|
21
|
+
{ "value" : "http:\/\/api.talis.com\/stores\/testing\/config\/fpmaps\/1#description", "type" : "uri" }
|
22
|
+
]
|
23
|
+
},
|
24
|
+
"http:\/\/api.talis.com\/stores\/testing\/config\/fpmaps\/1#title" : {
|
25
|
+
"http:\/\/schemas.talis.com\/2006\/frame\/schema#property" : [ { "value" : "http:\/\/purl.org\/dc\/elements\/1.1\/title", "type" : "uri" } ],
|
26
|
+
"http:\/\/schemas.talis.com\/2006\/frame\/schema#name" : [ { "value" : "title", "type" : "literal" } ]
|
27
|
+
},
|
28
|
+
"http:\/\/api.talis.com\/stores\/testing\/config\/fpmaps\/1#name" : {
|
29
|
+
"http:\/\/schemas.talis.com\/2006\/frame\/schema#property" : [ { "value" : "http:\/\/xmlns.com\/foaf\/0.1\/name", "type" : "uri" } ],
|
30
|
+
"http:\/\/schemas.talis.com\/2006\/frame\/schema#name" : [ { "value" : "name", "type" : "literal" } ]
|
31
|
+
}
|
32
|
+
}
|
33
|
+
EOL
|
34
|
+
|
35
|
+
def setup
|
36
|
+
@fpmap = Pho::FieldPredicateMap.new("http://api.talis.com/stores/testing/config/fpmaps/1", "Test FieldPredicate Map")
|
37
|
+
|
38
|
+
@fpmap << Pho::DatatypeProperty.new("http://api.talis.com/stores/testing/config/fpmaps/1#test",
|
39
|
+
"http://www.example.org/ns/test", "test")
|
40
|
+
|
41
|
+
@fpmap << Pho::DatatypeProperty.new("http://api.talis.com/stores/testing/config/fpmaps/1#title",
|
42
|
+
"http://www.example.org/ns/title", "title", Pho::Analyzers::STANDARD)
|
43
|
+
|
44
|
+
@fpmap << Pho::DatatypeProperty.new("http://api.talis.com/stores/testing/config/fpmaps/1#address",
|
45
|
+
"http://www.example.org/ns/address", "address")
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def teardown
|
50
|
+
@fpmap = nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_get
|
54
|
+
p = @fpmap.get_by_name("test")
|
55
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1#test", p.uri)
|
56
|
+
|
57
|
+
p = @fpmap.get_by_uri("http://www.example.org/ns/test")
|
58
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1#test", p.uri)
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_remove
|
63
|
+
p = @fpmap.get_by_name("test")
|
64
|
+
assert_not_nil(p)
|
65
|
+
@fpmap.remove(p)
|
66
|
+
assert_equal(nil, @fpmap.get_by_name("test") )
|
67
|
+
assert_equal(2, @fpmap.datatype_properties.length)
|
68
|
+
|
69
|
+
p = @fpmap.remove_by_name("title")
|
70
|
+
assert_not_nil(p)
|
71
|
+
|
72
|
+
p = @fpmap.remove_by_uri("http://www.example.org/ns/address")
|
73
|
+
assert_not_nil(p)
|
74
|
+
|
75
|
+
assert_equal(0, @fpmap.datatype_properties.length)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_datatype_property_to_rdf_no_analyzer
|
79
|
+
|
80
|
+
prop = Pho::DatatypeProperty.new("http://api.talis.com/stores/testing/config/fpmaps/1#test",
|
81
|
+
"http://www.example.org/ns/test", "test")
|
82
|
+
|
83
|
+
rdf = prop.to_rdf
|
84
|
+
|
85
|
+
assert_equal(true, rdf != nil)
|
86
|
+
|
87
|
+
#Check it parses
|
88
|
+
doc = nil
|
89
|
+
assert_nothing_raised {
|
90
|
+
doc = REXML::Document.new(rdf)
|
91
|
+
}
|
92
|
+
|
93
|
+
root = doc.root
|
94
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1#test", root.attributes["about"])
|
95
|
+
|
96
|
+
assert_has_single_property_with_resource(root, "frm:property", "http://www.example.org/ns/test")
|
97
|
+
assert_has_single_property_with_literal(root, "frm:name", "test")
|
98
|
+
|
99
|
+
assert_equal(0, root.get_elements("bf:analyzer").length)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_datatype_property_to_rdf_with_analyzer
|
103
|
+
|
104
|
+
prop = Pho::DatatypeProperty.new("http://api.talis.com/stores/testing/config/fpmaps/1#test",
|
105
|
+
"http://www.example.org/ns/test", "test", Pho::Analyzers::NORMALISE_STANDARD)
|
106
|
+
|
107
|
+
rdf = prop.to_rdf
|
108
|
+
|
109
|
+
assert_equal(true, rdf != nil)
|
110
|
+
|
111
|
+
#Check it parses
|
112
|
+
doc = nil
|
113
|
+
assert_nothing_raised {
|
114
|
+
doc = REXML::Document.new(rdf)
|
115
|
+
}
|
116
|
+
|
117
|
+
root = doc.root
|
118
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1#test", root.attributes["about"])
|
119
|
+
|
120
|
+
assert_has_single_property_with_resource(root, "frm:property", "http://www.example.org/ns/test")
|
121
|
+
assert_has_single_property_with_literal(root, "frm:name", "test")
|
122
|
+
assert_has_single_property_with_resource(root, "bf:analyzer", "http://schemas.talis.com/2007/bigfoot/analyzers#norm-en")
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
def assert_has_single_property_with_literal(el, property, value)
|
127
|
+
|
128
|
+
assert_equal(1, el.get_elements(property).length)
|
129
|
+
child = el.get_elements(property)[0]
|
130
|
+
assert_equal(value, child.text)
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
def assert_has_single_property_with_resource(el, property, resource_uri)
|
135
|
+
assert_equal(1, el.get_elements(property).length)
|
136
|
+
analyzer = el.get_elements(property)[0]
|
137
|
+
assert_equal(resource_uri, analyzer.attributes["resource"])
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_get_fpmaps_from_store
|
141
|
+
mc = mock()
|
142
|
+
mc.expects(:set_auth)
|
143
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/config/fpmaps/1", anything, {"Accept" => "application/json"})
|
144
|
+
|
145
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
146
|
+
resp = store.get_field_predicate_map()
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_read_fpmaps_from_store_as_xml
|
151
|
+
mc = mock()
|
152
|
+
mc.expects(:set_auth)
|
153
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/config/fpmaps/1", anything, {"Accept" => "application/rdf+xml"})
|
154
|
+
|
155
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
156
|
+
resp = store.get_field_predicate_map(Pho::ACCEPT_RDF)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_put_fpmaps_to_store
|
160
|
+
mc = mock()
|
161
|
+
mc.expects(:set_auth)
|
162
|
+
mc.expects(:put).with("http://api.talis.com/stores/testing/config/fpmaps/1", anything, {"Content-Type" => "application/rdf+xml"} )
|
163
|
+
|
164
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
165
|
+
resp = store.put_field_predicate_map(@fpmap)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_upload_to_store
|
169
|
+
mc = mock()
|
170
|
+
mc.expects(:set_auth)
|
171
|
+
mc.expects(:put).with("http://api.talis.com/stores/testing/config/fpmaps/1", anything, {"Content-Type" => "application/rdf+xml"} )
|
172
|
+
|
173
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
174
|
+
@fpmap.upload(store)
|
175
|
+
end
|
176
|
+
def test_read_from_store
|
177
|
+
mc = mock()
|
178
|
+
mc.expects(:set_auth)
|
179
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/config/fpmaps/1", anything,
|
180
|
+
{"Accept" => "application/json"}).returns( HTTP::Message.new_response(TEST_FPMAP))
|
181
|
+
|
182
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
183
|
+
|
184
|
+
fpmap = Pho::FieldPredicateMap.read_from_store(store)
|
185
|
+
assert_not_nil(fpmap)
|
186
|
+
assert_equal("default field/predicate map", fpmap.label)
|
187
|
+
assert_equal(3, fpmap.datatype_properties.length)
|
188
|
+
|
189
|
+
sorted = fpmap.datatype_properties.sort { |x,y|
|
190
|
+
x.name <=> y.name
|
191
|
+
}
|
192
|
+
|
193
|
+
assert_expected_datatype_property(sorted[0], "description",
|
194
|
+
"http://api.talis.com/stores/testing/config/fpmaps/1#description",
|
195
|
+
"http://purl.org/dc/elements/1.1/description")
|
196
|
+
|
197
|
+
assert_expected_datatype_property(sorted[1], "name",
|
198
|
+
"http://api.talis.com/stores/testing/config/fpmaps/1#name",
|
199
|
+
"http://xmlns.com/foaf/0.1/name")
|
200
|
+
|
201
|
+
assert_expected_datatype_property(sorted[2], "title",
|
202
|
+
"http://api.talis.com/stores/testing/config/fpmaps/1#title",
|
203
|
+
"http://purl.org/dc/elements/1.1/title")
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
def assert_expected_datatype_property(dp, name, uri, property_uri)
|
208
|
+
assert_equal(name, dp.name)
|
209
|
+
assert_equal(uri, dp.uri)
|
210
|
+
assert_equal(property_uri, dp.property_uri)
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_get_name
|
214
|
+
|
215
|
+
name = @fpmap.get_name("http://www.example.org/ns/title")
|
216
|
+
assert_not_nil(name)
|
217
|
+
assert_equal("title", name)
|
218
|
+
|
219
|
+
name = @fpmap.get_name("http://www.example.org/ns/location")
|
220
|
+
assert_nil(name)
|
221
|
+
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_get_property_uri
|
225
|
+
|
226
|
+
uri = @fpmap.get_property_uri("address")
|
227
|
+
assert_not_nil(uri)
|
228
|
+
assert_equal("http://www.example.org/ns/address", uri)
|
229
|
+
|
230
|
+
uri = @fpmap.get_property_uri("location")
|
231
|
+
assert_nil(uri)
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_mapped_name?
|
236
|
+
assert_equal(true, @fpmap.mapped_name?("address"))
|
237
|
+
assert_equal(false, @fpmap.mapped_name?("location"))
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_mapped_uri?
|
241
|
+
assert_equal(true, @fpmap.mapped_uri?("http://www.example.org/ns/address"))
|
242
|
+
assert_equal(false, @fpmap.mapped_uri?("http://www.example.org/ns/location"))
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_create_mapping_with_slash_uri
|
246
|
+
mc = mock()
|
247
|
+
mc.stub_everything
|
248
|
+
mc.expects(:build_uri).with("/config/fpmaps/1#title").returns("http://api.talis.com/stores/testing/config/fpmaps/1#title")
|
249
|
+
|
250
|
+
mapping = Pho::FieldPredicateMap.create_mapping(mc, "http://www.example.org/ns/title", "title")
|
251
|
+
assert_not_nil(mapping)
|
252
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1#title", mapping.uri)
|
253
|
+
assert_equal("http://www.example.org/ns/title", mapping.property_uri)
|
254
|
+
assert_equal("title", mapping.name)
|
255
|
+
assert_equal(nil, mapping.analyzer)
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_create_mapping_with_hash_uri
|
259
|
+
mc = mock()
|
260
|
+
mc.stub_everything
|
261
|
+
mc.expects(:build_uri).with("/config/fpmaps/1#document").returns("http://api.talis.com/stores/testing/config/fpmaps/1#document")
|
262
|
+
|
263
|
+
mapping = Pho::FieldPredicateMap.create_mapping(mc, "http://www.example.org/ns/things#document", "document", Pho::Analyzers::DUTCH)
|
264
|
+
assert_not_nil(mapping)
|
265
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1#document", mapping.uri)
|
266
|
+
assert_equal("http://www.example.org/ns/things#document", mapping.property_uri)
|
267
|
+
assert_equal("document", mapping.name)
|
268
|
+
assert_equal(Pho::Analyzers::DUTCH, mapping.analyzer)
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_create_mapping_with_invalid_name
|
272
|
+
assert_raise RuntimeError do
|
273
|
+
Pho::FieldPredicateMap.create_mapping(nil, "http://www.example.org/ns/things#document", "12345")
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_to_rdf
|
278
|
+
rdf = @fpmap.to_rdf
|
279
|
+
|
280
|
+
assert_equal(true, rdf != nil)
|
281
|
+
|
282
|
+
#Check it parses
|
283
|
+
doc = nil
|
284
|
+
assert_nothing_raised {
|
285
|
+
doc = REXML::Document.new(rdf)
|
286
|
+
}
|
287
|
+
|
288
|
+
root = doc.root
|
289
|
+
|
290
|
+
children = root.get_elements("rdf:Description")
|
291
|
+
#fpmap + 3 mappings
|
292
|
+
assert_equal(4, children.length)
|
293
|
+
|
294
|
+
fpmap = children[0]
|
295
|
+
assert_has_single_property_with_literal(fpmap, "rdfs:label", "Test FieldPredicate Map")
|
296
|
+
assert_has_single_property_with_resource(fpmap, "rdf:type", "http://schemas.talis.com/2006/bigfoot/configuration#FieldPredicateMap")
|
297
|
+
end
|
298
|
+
|
299
|
+
end
|
data/tests/tc_rdf_collection.rb
CHANGED
@@ -91,13 +91,18 @@ class RDFCollectionTest < Test::Unit::TestCase
|
|
91
91
|
def test_store()
|
92
92
|
mc = mock()
|
93
93
|
mc.stub_everything()
|
94
|
-
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF7", {"Content-Type" => "application/rdf+xml"})
|
95
|
-
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF8", {"Content-Type" => "application/rdf+xml"})
|
96
|
-
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF9", {"Content-Type" => "application/rdf+xml"})
|
94
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF7", {"Content-Type" => "application/rdf+xml"}).returns( HTTP::Message.new_response("OK"))
|
95
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF8", {"Content-Type" => "application/rdf+xml"}).returns( HTTP::Message.new_response("OK"))
|
96
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF9", {"Content-Type" => "application/rdf+xml"}).returns( HTTP::Message.new_response("OK"))
|
97
97
|
|
98
98
|
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
99
99
|
collection = Pho::RDFCollection.new(store, "/tmp")
|
100
|
-
collection.store()
|
100
|
+
collection.store()
|
101
|
+
|
102
|
+
assert_equal(true, File.exists?("/tmp/7.ok") )
|
103
|
+
assert_equal(true, File.exists?("/tmp/8.ok") )
|
104
|
+
assert_equal(true, File.exists?("/tmp/9.ok") )
|
105
|
+
|
101
106
|
end
|
102
107
|
|
103
108
|
def test_reset()
|
data/tests/ts_pho.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.2"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leigh Dodds
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-25 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -53,6 +53,16 @@ extra_rdoc_files:
|
|
53
53
|
files:
|
54
54
|
- README
|
55
55
|
- Rakefile
|
56
|
+
- doc/rdoc
|
57
|
+
- doc/rdoc/fr_method_index.html
|
58
|
+
- doc/rdoc/rdoc-style.css
|
59
|
+
- doc/rdoc/fr_file_index.html
|
60
|
+
- doc/rdoc/fr_class_index.html
|
61
|
+
- doc/rdoc/classes
|
62
|
+
- doc/rdoc/files
|
63
|
+
- doc/rdoc/files/README.html
|
64
|
+
- doc/rdoc/index.html
|
65
|
+
- doc/rdoc/created.rid
|
56
66
|
- tests/tc_metabox.rb
|
57
67
|
- tests/tc_store_util.rb
|
58
68
|
- tests/tc_contentbox.rb
|
@@ -63,6 +73,7 @@ files:
|
|
63
73
|
- tests/tc_snapshots.rb
|
64
74
|
- tests/tc_search.rb
|
65
75
|
- tests/tc_etags.rb
|
76
|
+
- tests/tc_field_predicate_map.rb
|
66
77
|
- examples/status.rb
|
67
78
|
- examples/sparql.rb
|
68
79
|
- examples/contentbox.rb
|
@@ -71,6 +82,7 @@ files:
|
|
71
82
|
- lib/pho/etags.rb
|
72
83
|
- lib/pho/rdf_collection.rb
|
73
84
|
- lib/pho/store.rb
|
85
|
+
- lib/pho/field_predicate_map.rb
|
74
86
|
- lib/pho/job.rb
|
75
87
|
- lib/pho/snapshot.rb
|
76
88
|
has_rdoc: true
|