Skip to content

Instantly share code, notes, and snippets.

@takatoh
Created November 24, 2011 09:41
Show Gist options
  • Save takatoh/1390978 to your computer and use it in GitHub Desktop.
Save takatoh/1390978 to your computer and use it in GitHub Desktop.
# encoding: utf-8
def make_similar_html(db, orig, idx)
html = "s#{idx.to_s}.html"
$stderr.puts html
system("simimg search --html #{db} #{orig} > #{html}")
html
end
def make_index_html(index)
print "<html>\n"
print " <body>\n"
index.each do |i|
print " <a href=\"#{i[:html]}\"><img src=\"#{i[:orig]}\"/></a>\n"
end
print " </body>\n"
print "</html>\n"
end
def main
db_file = ARGV.shift
origs = File.readlines(ARGV.shift).map{|l| l.chomp}
index = []
origs.each_with_index do |orig, idx|
html = make_similar_html(db_file, orig, idx)
index << {:html => html, :orig => orig}
end
make_index_html(index)
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment