咳といいます。

> 拡張モジュールではありませんが、Rubyのみでnamazuのインデックスの内容
> を読み出し、スコアの計算をおこなうrbnamazuを書いています。
> 
> 以下のURLに、といあえず、おいておきます。
> http://shinoda-www.jaist.ac.jp/Projects/hige/src/namazu.rb

rbnamazuをrequireして動く分散namazuを書いてみました。
rbnamazuをライブラリ風にしているのでちょっと大きくなってしまいました。
今はスコアをクライアントに返さないのですが、もうちょっと頑張ってみます。

こんな風に使います。もうちょっといい例をそのうち書きたいです。

-- client --
require 'drb/drb'

there = ARGV.shift
unless there
  $stderr.puts("usage: #{$0} <server_uri> <keyword...>")
  exit 1
end

DRb.start_service()
ro = DRbObject.new(nil, there)

docs, hits, ref_hits = ro.query(ARGV)
p docs						# Array of Hash

ro.search(ARGV, "late") do |r|			# GC safe!
  p r.result(%w(uri))
  r.result(%w(uri summary), nil).each do |rec|	# Array of Array
    puts rec[0]
    puts rec[1]
  end
  nil
end


# namadu-0.0 - distributed namazu # # $Id: namadu.rb,v 1.2 2000/05/26 17:48:59 mas Exp $ # Copyright (c) 2000 Masatoshi SEKI # # namadu.rb is copyrighted free software by Masatoshi SEKI. # You can redistribute it and/or modify it under the same term as Ruby. require 'rbnamazu' class NamazuFieldAll def gets_as_array(docid, fieldnames = nil) unless fieldnames fieldnames = @fieldnames end fieldnames.collect do |fieldname| field = @nmzfieldall[fieldname].gets(docid) field.chomp!() field end end end class Namadu class Result def initialize(namadu, order, words) @namadu = namadu result, times, references = @namadu.finder.get_scores(words) @references = ref_hits(words, references) @docids = sort(result, times, order) @docids.freeze @num_docs = @docids.size end attr_reader(:references, :num_docs) private def ref_hits(words, counts) hash = {} words.each_with_index do |w, i| hash[w] = counts[i] end hash.freeze end private def sort(scores, times, order='score') docids = scores.keys case order when 'score' docids.sort { |a, b| scores[a] <=> scores[b] } when 'early' docids.sort { |a, b| times[a] <=> times[b] } when 'late' docids.sort { |a, b| times[b] <=> times[a] } else docids end end private def check_fields(fields) return unless fields all = @namadu.fieldnames for f in fields raise "Unknown field: #{f}" unless all.include? f end end public def result(fields=nil, max=20, whence=0) check_fields(fields) docids = @docids docids = docids[whence, max] if max if fields docids.collect do |docid| @namadu.fields_loader.gets_as_array(docid, fields) end else docids.collect do |docid| @namadu.fields_loader.gets(docid, fields) end end end end def initialize(index) @index = index.dup.freeze @finder = NamazuScores.new(@index) @fields_loader = NamazuFieldAll.new(@index) end attr_reader(:finder, :fields_loader) public def fieldnames @fields_loader.fieldnames end public def search(words, order='score') words = words.collect { |w| w.downcase } r = Result.new(self, order, words) yield(r) if iterator? # GC trick r end public def query(words, order='score', fields=nil, max=20, whence=0) r = search(words, order) list = r.result(fields, max, whence) [list, r.num_docs, r.references] end end require 'drb/drb' class Namadu include DRbUndumped class Result include DRbUndumped end end if __FILE__ == $0 index = ARGV.shift nmd = Namadu.new(index) DRb.start_service('druby://:7952', nmd) puts DRb.uri if $DEBUG gets else DRb.thread.join end end