example-2.rb 471 B

123456789101112131415161718
  1. # example-2
  2. # Illustrates setting up and running an instance of uhferret in one block.
  3. require "uhferret"
  4. UHFerret::Ferret.new do
  5. # Add some documents to ferret and run calculations.
  6. add "text-eg/ruby.txt"
  7. add "text-eg/cobra.txt"
  8. add "text-eg/fantom.txt"
  9. run
  10. # Print the resemblance results formatted to 4 decimal places.
  11. each_pair do |i, j|
  12. puts "#{"%10s" % self[i].filename} #{"%10s" % self[j].filename} #{"%1.4f" % resemblance(i, j)}"
  13. end
  14. end