Kouhei Sutou
null+****@clear*****
Tue Aug 2 19:22:55 JST 2016
Kouhei Sutou 2016-08-02 19:22:55 +0900 (Tue, 02 Aug 2016) New Revision: 0384457ad9128270de449e9f7b3aecf1a17682d3 https://github.com/groonga/groonga-command/commit/0384457ad9128270de449e9f7b3aecf1a17682d3 Message: table_create: support token_filters Modified files: lib/groonga/command/table-create.rb test/command/test-table-create.rb Modified: lib/groonga/command/table-create.rb (+8 -3) =================================================================== --- lib/groonga/command/table-create.rb 2016-06-17 09:49:17 +0900 (6dcf50a) +++ lib/groonga/command/table-create.rb 2016-08-02 19:22:55 +0900 (d845c4e) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2012-2016 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -32,6 +30,7 @@ module Groonga :value_type, :default_tokenizer, :normalizer, + :token_filters, ] end end @@ -92,6 +91,12 @@ module Groonga def normalizer self[:normalizer] end + + # @return [::Array<String>] Token filter names. + # @since 1.2.1 + def token_filters + @token_filters ||= (self[:token_filters] || "").split(/\s*\|\s*/) + end end end end Modified: test/command/test-table-create.rb (+29 -3) =================================================================== --- test/command/test-table-create.rb 2016-06-17 09:49:17 +0900 (6666a94) +++ test/command/test-table-create.rb 2016-08-02 19:22:55 +0900 (c90c9fb) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012-2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2012-2016 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -32,6 +30,7 @@ class TableCreateCommandTest < Test::Unit::TestCase value_type = "UInt32" default_tokenizer = "TokenBigram" normalizer = "NormalizerAuto" + token_filters = "TokenFilterStopWord|TokenFilterStem" ordered_arguments = [ name, @@ -40,6 +39,7 @@ class TableCreateCommandTest < Test::Unit::TestCase value_type, default_tokenizer, normalizer, + token_filters, ] command = table_create_command({}, ordered_arguments) assert_equal({ @@ -49,6 +49,7 @@ class TableCreateCommandTest < Test::Unit::TestCase :value_type => value_type, :default_tokenizer => default_tokenizer, :normalizer => normalizer, + :token_filters => token_filters, }, command.arguments) end @@ -185,4 +186,29 @@ class TableCreateCommandTest < Test::Unit::TestCase assert_nil(command.normalizer) end end + + class TokenFiltersTest < self + def test_multiple + arguments = { + "token_filters" => "TokenFilterStopWord|TokenFilterStem", + } + command = table_create_command(arguments) + assert_equal(["TokenFilterStopWord", "TokenFilterStem"], + command.token_filters) + end + + def test_one + arguments = { + "token_filters" => "TokenFilterStopWord", + } + command = table_create_command(arguments) + assert_equal(["TokenFilterStopWord"], + command.token_filters) + end + + def test_no_flags + command = table_create_command + assert_equal([], command.token_filters) + end + end end -------------- next part -------------- HTML����������������������������... 下載