morit****@razil*****
morit****@razil*****
2010年 4月 23日 (金) 09:58:45 JST
森です。
ご指摘ありがとうございます。
groongaのNグラムトークナイザの現状の挙動では、
複数の連続する記号列は一つのトークンとして扱っています。
この場合、
...)
という文字列が、ひとつのトークンとして扱われてしまい、
結果として ")" や ")は" でヒットしなくなっています。
groongaのlib/token.c:340のところを
token->uni_symbol = 0;
とすると、連続する記号列もバイグラムを作るようになるので
この問題は回避できるのですが、デフォルトの挙動を切り替えると
インデックスの互換性がなくなってしまうのでちょっと躊躇しています。
近い将来にインデックス作成時にそれを指定するインタフェースを準備しようと
考えています。
以上どうぞ宜しくお願いします。
>>> SHIDARA Yoji さんは書きました:
> しだらです。
>
> :key_normalize => true 時に、検索の漏れが発生することがあるようです。
> 以前にも似ている現象がありましたが、今回は(複数の?)記号が絡む場合のようです。
>
> ruby-groonga のテストを以下のようにすると確認できます。
> #必要でしたらコミットしておきます
>
> Index: test/test-table-select-normalize.rb
> ===================================================================
> --- test/test-table-select-normalize.rb (revision 1046)
> +++ test/test-table-select-normalize.rb (working copy)
> @@ -32,7 +32,7 @@
> :with_section => true,
> :source => "Comments.content")
> @japanese_comment =
> - @comments.add(:content => "うちのボロTVはまだ現役です",
> + @comments.add(:content => "うちのボロTV(アナログ...)はまだ現役です",
> :created_at => Time.parse("2009-06-09"))
> end
>
> @@ -41,6 +41,11 @@
> assert_equal_select_result([@japanese_comment], result)
> end
>
> + def test_select_query_with_japanese_parenthesis
> + result =****@comme*****("content:@)は")
> + assert_equal_select_result([@japanese_comment], result)
> + end
> +
> def test_select_query_only_in_japanese
> result =****@comme*****("content:@うちの")
> assert_equal_select_result([@japanese_comment], result)
>
> 実行結果は以下のとおりです:
>
> garlic:~/local/src/ruby-groonga/test% ./run-test.rb -n /parenthesis/
> Loaded suite ./run-test
> Started
> F
>
> 1) Failure:
> test_select_query_with_japanese_parenthesis(TableSelectNormalizeTest)
> [/home/dara/local/src/ruby-groonga/test/groonga-test-utils.rb:102:in
> `assert_equal_select_result'
> /home/dara/local/src/ruby-groonga/test/test-table-select-normalize.rb:46:in
> `test_select_query_with_japanese_parenthesis']:
> #<Groonga::Expression noname(?0:0){2content GET_VALUE,0")は",0MATCH}>
> <[#<Groonga::Record:0x7fbef61679b8
> @id=1,
> @table=
> #<Groonga::Array id: <256>, name: <Comments>, path:
> </home/dara/local/src/ruby-groonga/test/tmp/database.0000100>, domain:
> (nil), range: (nil), flags: <>, size: <1>>>]> expected but was
> <[]>
>
> diff:
> ? [#<Groonga::Record:0x7fbef61679b8
> ? ]
> - @id=1,
> - @table=
> - #<Groonga::Array id: <256>, name: <Comments>, path:
> </home/dara/local/src/ruby-groonga/test/tmp/database.0000100>, domain:
> (nil), range: (nil), flags: <>, size: <1>>>]
>
> Finished in 0.430873 seconds.
>
> 1 tests, 1 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions,
> 0 notifications
> 0% passed
>
> --
> SHIDARA Yoji
> 本を書きました! http://www.amazon.co.jp/dp/4798119881
>
> _______________________________________________
> groonga-dev mailing list
> groon****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/groonga-dev
>
--
morita