Bugs: Browse | Submit New | Admin

[#2880] case insensitive word-search

Date:
2005-11-25 10:54
Priority:
3
Submitted By:
Nobody
Assigned To:
Mathieu Blondel (mblondel)
Category:
Interface (example)
State:
Open
Summary:
case insensitive word-search

Detailed description
word-search is currently case sensitive. case insensitive would be nicer.

thanks. :)

Add A Comment: Notepad

Please login


Followup

Message
Date: 2005-12-22 20:54
Sender: Mathieu Blondel

Hi,

Thank you for the bug submission and the patch.

SQLite is case-sensitive so like in the patch, we should compare
two upper case strings to make the search case-insensitive. The
only problem of the submitted patch is it requires SQLite to
transform every entry one by one to compare it with the searched
word. It really decreases the search speed.

Currently, the table "translations" contains whole
expressions, say "Christmas tree" for example. Currently,
if a user enters the word "tree", he/she won't get
this result.   And he/she won't get it with "christmas"
either.

So I was planning to create a table "translation_words"
which would contain words (already in upper case) of each translation.
This way, we would solve the two problems without loosing
efficiency.

I'll close this bug when this is done.
Date: 2005-11-25 12:01
Sender: Nobody

Got a bit bored. This works, though I don't know if its good
code... Also, string.upcase only treats ascii-letters (a-z),
no language-specific characters like the german ä,ö,ü

--- nihongobenkyo-0.3.old/lib/nihongobenkyo/database.rb 2005-11-15
21:56:22.000000000 +0100
+++ nihongobenkyo-0.3/lib/nihongobenkyo/database.rb     2005-11-25
13:06:24.000000000 +0100
@@ -52,18 +52,20 @@
     end

     def search_result_list(word, search_type)
        if word.latin?
+           wordUpper = word.upcase();
             # from romaji or translation
             subquery = "SELECT entry_id FROM readings WHERE
reading = '#{word.to_kana}' "
             subquery += "UNION "
-            subquery += "SELECT entry_id FROM translations
WHERE translation = '#{word}' "
+            subquery += "SELECT entry_id FROM translations
WHERE UPPER(translation) = '#{wordUpper}' "
         elsif word.kana?
             subquery = "SELECT entry_id FROM readings WHERE
reading = '#{word}'"
         elsif word.japanese?
             subquery = "SELECT entry_id FROM kanji WHERE
kanji = '#{word}'"
         else
+           wordUpper = word.upcase();
             # everything because language has not been detected
-            subquery = "SELECT entry_id FROM translations
WHERE translation = '#{word}' "
+            subquery = "SELECT entry_id FROM translations
WHERE UPPER(translation) = '#{wordUpper}' "
             subquery += "UNION "
             subquery += "SELECT entry_id FROM readings
WHERE reading = '#{word}' "
             subquery += "UNION "

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_tonone2005-12-22 20:54mblondel