# The Open Office Thesaurus object. Create a new object with idx file and # main database file name and search words with "lookup". # Works with OO Thesaurus files 2.x # by kesiev at http://www.kesiev.com/ class OOThesaurus def dosearch(the,history,word,add,filepathidx,filepathdat) a = [] if add then history.push(word) end word=word #$itemslist.clear rt=the.lookup(word,filepathidx,filepathdat) if rt.length>0 rt.each { |ent| ent.each_with_index { |line,i| # a=itemslist.append a[0]=(i!=0 ? "\t" : "" )+ line } } else # a=$itemslist.append a[0]="No hits." end end def lookup(word,idxfile,datfile) Dir.chdir($progdir) if $DEBUG $stderr.puts "in lookup\n" $stderr.puts idxfile.to_s end seek=-1 ret=[] if File::exist?(idxfile) && File::exist?(datfile) open(idxfile,"r").each { |f| f.each { |line| line=line.split("|") if line[0]==word seek=line[1].to_i break end } } ret=[] ret2 = [] if seek!=-1 open(datfile,"r") { |a| a.seek(seek) data=a.gets.split("|") data[1].to_i.times { ret << a.gets.strip.split("|") } } end end ret end end def back(history) if word=history.pop then #$box.text=word dosearch(false) end end