* RandomNote : NOT検索
適当にNOT検索ができるようにしてみる。
Rubyはまだよく分からんので変なことしているかも。
どなたかうまいこと実装してくれないかなぁ。
検索語が「-」で始まる場合はNOT検索をします。
update : 2006-02-19 (Sun) 21:41:33
Rubyはまだよく分からんので変なことしているかも。
どなたかうまいこと実装してくれないかなぁ。
検索語が「-」で始まる場合はNOT検索をします。
--- index.rb.org 2006-02-19 06:35:28.630000000 -0500 +++ index.rb 2006-02-19 06:52:42.100000000 -0500 @@ -11,7 +11,7 @@ def initialize(word) @word = word - @qword = Regexp::quote(@word) + @qword = (@word.index("-") != 0) ? Regexp::quote(@word) : Regexp::quote(@word[1 .. -1]) @search_time = Time.now.to_i @files = [] @count = 0 @@ -20,7 +20,11 @@ def make_files Dir[CGI_frame::LEAFS_DIR + '*.txt'].each do |fname| mes = File.open(fname) {|f| f.read} - @files << fname if /#{@qword}/i =~ mes + if @word.index("-") != 0 + @files << fname if /#{@qword}/i =~ mes + else + @files << fname unless /#{@qword}/i =~ mes + end end self end @@ -37,7 +41,7 @@ def check_text(fname) mes = File.open(fname) {|f| f.read} - if /#{@qword}/i =~ mes + if (@word.index("-") != 0 && /#{@qword}/i =~ mes)||(@word.index("-") == 0 && !(/#{@qword}/i =~ mes)) @files.unshift(fname).uniq! else @files.delete(fname) if @files.index(fname)
update : 2006-02-19 (Sun) 21:41:33