Sha256: 677a7db6cb052b359f84737f7348ee7d63197e7c5ff5fcba5fcd4923a99fc3fa

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

# 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

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
rwdfoldeditor-0.05 lib/oothesaurus.rb
rwdeliza-0.04 lib/oothesaurus.rb
rwdfoldeditor-0.03 lib/oothesaurus.rb
rwdeliza-0.05 lib/oothesaurus.rb
rwdlanguage-0.01 lib/oothesaurus.rb