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: estraier.rb</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>estraier.rb</h1> |
51 |
<table class="header-table"> |
52 |
<tr class="top-aligned-row"> |
53 |
<td><strong>Path:</strong></td> |
54 |
<td>estraier.rb |
55 |
</td> |
56 |
</tr> |
57 |
<tr class="top-aligned-row"> |
58 |
<td><strong>Last Update:</strong></td> |
59 |
<td>Mon Aug 01 00:39:15 JST 2005</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 |
<h1>Hyper Estraier</h1> |
73 |
<p> |
74 |
a full-text search system for communities. |
75 |
</p> |
76 |
<h2>Introduction</h2> |
77 |
<p> |
78 |
This is a package implementing the node API of <a |
79 |
href="http://hyperestraier.sourceforge.net/">Hyper Estraier</a>. This is a |
80 |
pure ruby package. So, it works on Linux, Mac OS X, Windows, and so on. It |
81 |
does not depend on the core library of Hyper Estraier. Applications are |
82 |
implemented as clients of node servers running on local or remote machines. |
83 |
</p> |
84 |
<p> |
85 |
Though Hyper Estraier itself is released under the terms of the GNU LGPL, |
86 |
this package is released under the terms of a BSD-style license. |
87 |
</p> |
88 |
<h2>Setting</h2> |
89 |
<p> |
90 |
Put the module file `<a |
91 |
href="http://hyperestraier.sourceforge.net/rb/">estraier.rb</a>’ in a |
92 |
directory in the library search path. |
93 |
</p> |
94 |
<p> |
95 |
The package `estraier’ should be required in each source file of |
96 |
application programs and include the module `Estraier’ at pleasure. |
97 |
</p> |
98 |
<h2>Example of Gatherer</h2> |
99 |
<p> |
100 |
The following is the simplest implementation of a gatherer. |
101 |
</p> |
102 |
<pre> |
103 |
require "estraier" |
104 |
include Estraier |
105 |
|
106 |
# create and configure the node connecton object |
107 |
node = Node.new |
108 |
node.set_url("http://localhost:1978/node/test1") |
109 |
node.set_auth("admin", "admin") |
110 |
# create a document object |
111 |
doc = Document.new |
112 |
# add attributes to the document object |
113 |
doc.add_attr("@uri", "http://estraier.gov/example.txt") |
114 |
doc.add_attr("@title", "Over the Rainbow") |
115 |
# add the body text to the document object |
116 |
doc.add_text("Somewhere over the rainbow. Way up high.") |
117 |
doc.add_text("There's a land that I heard of once in a lullaby.") |
118 |
# register the document object to the node |
119 |
if(!node.put_doc(doc)) |
120 |
STDERR.printf("error: %d\n", node.status) |
121 |
end |
122 |
</pre> |
123 |
<h2>Example of Searcher</h2> |
124 |
<p> |
125 |
The following is the simplest implementation of a searcher. |
126 |
</p> |
127 |
<pre> |
128 |
require "estraier" |
129 |
include Estraier |
130 |
|
131 |
# create and configure the node connecton object |
132 |
node = Node.new |
133 |
node.set_url("http://localhost:1978/node/test1") |
134 |
# create a search condition object |
135 |
cond = Condition.new() |
136 |
# set the search phrase to the search condition object |
137 |
cond.set_phrase("rainbow AND lullaby") |
138 |
# get the result of search |
139 |
nres = node.search(cond, 0); |
140 |
if(nres) |
141 |
# for each document in the result |
142 |
for i in 0...nres.doc_num |
143 |
# get a result document object |
144 |
rdoc = nres.get_doc(i) |
145 |
# display attributes |
146 |
value = rdoc.attr("@uri") |
147 |
printf("URI: %s\n", value) if value |
148 |
value = rdoc.attr("@title") |
149 |
printf("Title: %s\n", value) if value |
150 |
# display the snippet text */ |
151 |
printf("%s", rdoc.snippet) |
152 |
end |
153 |
else |
154 |
STDERR.printf("error: %d\n", node.status) |
155 |
end |
156 |
</pre> |
157 |
<h2>License</h2> |
158 |
<pre> |
159 |
Copyright (C) 2004-2005 Mikio Hirabayashi |
160 |
All rights reserved. |
161 |
</pre> |
162 |
<p> |
163 |
Redistribution and use in source and binary forms, with or without |
164 |
modification, are permitted provided that the following conditions are met: |
165 |
</p> |
166 |
<ul> |
167 |
<li>Redistributions of source code must retain the above copyright notice, this |
168 |
list of conditions and the following disclaimer. |
169 |
|
170 |
</li> |
171 |
<li>Redistributions in binary form must reproduce the above copyright notice, |
172 |
this list of conditions and the following disclaimer in the documentation |
173 |
and/or other materials provided with the distribution. |
174 |
|
175 |
</li> |
176 |
<li>Neither the name of Mikio Hirabayashi nor the names of its contributors may |
177 |
be used to endorse or promote products derived from this software without |
178 |
specific prior written permission. |
179 |
|
180 |
</li> |
181 |
</ul> |
182 |
<p> |
183 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
184 |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
185 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
186 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
187 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
188 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
189 |
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
190 |
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
191 |
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
192 |
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
193 |
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
194 |
</p> |
195 |
|
196 |
</div> |
197 |
|
198 |
<div id="requires-list"> |
199 |
<h3 class="section-bar">Required files</h3> |
200 |
|
201 |
<div class="name-list"> |
202 |
uri |
203 |
socket |
204 |
stringio |
205 |
</div> |
206 |
</div> |
207 |
|
208 |
</div> |
209 |
|
210 |
|
211 |
</div> |
212 |
|
213 |
|
214 |
<!-- if includes --> |
215 |
|
216 |
<div id="section"> |
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
<!-- if method_list --> |
226 |
|
227 |
|
228 |
</div> |
229 |
|
230 |
|
231 |
<div id="validator-badges"> |
232 |
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> |
233 |
</div> |
234 |
|
235 |
</body> |
236 |
</html> |