Created
November 24, 2011 09:41
-
-
Save takatoh/1390978 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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