-
-
Save yoshinari-nomura/1297328 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
# Please add INDEX to speedup the SQL queries which use LIKE clauses: | |
# | |
# sqlite3 "#{DICT_FILE}" 'CREATE INDEX dict_key ON dict (key COLLATE NOCASE);' | |
SQLITE = "sqlite3" | |
DICT_FILE = "'#{ENV['HOME']}/sys/lib/Dic/EDP/mouseoverdictionary.sqlite'" | |
word = ARGV.shift | |
## XXX: sanitizing is required for WORD. | |
sql = "SELECT * FROM dict WHERE key COLLATE NOCASE LIKE '#{word}%' LIMIT 100;" | |
IO.popen "#{SQLITE} #{DICT_FILE} \"#{sql}\"" do |f| | |
while line = f.gets | |
line.sub!('|', "\n") | |
line.gsub!(' \ ', "\n") | |
print line | |
print "\n" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment