example-3.rb 437 B

123456789101112131415161718
  1. # example-3
  2. # Illustrates working with code.
  3. require "uhferret"
  4. ferret = UHFerret::Ferret.new do
  5. # note, we need to specify if the document is code rather than text
  6. add("code-eg/tupleset.cpp", UHFerret::CodeDocument)
  7. add("code-eg/tokenset.cpp", UHFerret::CodeDocument)
  8. end
  9. ferret.run
  10. ferret.each_pair do |i, j|
  11. puts "#{"%10s" % ferret[i].filename} #{"%10s" % ferret[j].filename} #{"%1.4f" % ferret.resemblance(i, j)}"
  12. end