1 |
#!/usr/bin/ruby |
2 |
""" |
3 |
simplest implementation of a searcher |
4 |
""" |
5 |
|
6 |
require 'HyperEstraier' |
7 |
|
8 |
# open the database |
9 |
db = HyperEstraier::Database.new() |
10 |
db.open('casket', HyperEstraier::Database::DBREADER) |
11 |
|
12 |
# create a search condition object |
13 |
cond = HyperEstraier::Condition.new() |
14 |
|
15 |
# set the search phrase to the search condition object |
16 |
cond.set_phrase('somewhere') |
17 |
|
18 |
# get the result of search |
19 |
result = db.search(cond, 0) |
20 |
|
21 |
# for each document in result |
22 |
result.each {|id| |
23 |
# get the document object |
24 |
doc = db.get_doc(id, 0) |
25 |
|
26 |
# display attributes |
27 |
puts "URI: #{doc.attr('@uri')}" |
28 |
puts "Title: #{doc.attr('@title')}" |
29 |
|
30 |
# display the body text |
31 |
puts doc.cat_texts() |
32 |
} |
33 |
|