[Groonga-commit] groonga/groonga-command [master] Add suggest

Back to archive index

Haruka Yoshihara null+****@clear*****
Mon Nov 26 14:29:36 JST 2012


Haruka Yoshihara	2012-11-26 14:29:36 +0900 (Mon, 26 Nov 2012)

  New Revision: 656c2784ab54a25d706aace9eafc16394e4002be
  https://github.com/groonga/groonga-command/commit/656c2784ab54a25d706aace9eafc16394e4002be

  Log:
    Add suggest

  Added files:
    lib/groonga/command/suggest.rb
    test/command/test-suggest.rb
  Modified files:
    lib/groonga/command/parser.rb

  Modified: lib/groonga/command/parser.rb (+1 -0)
===================================================================
--- lib/groonga/command/parser.rb    2012-11-25 22:45:22 +0900 (f353fbe)
+++ lib/groonga/command/parser.rb    2012-11-26 14:29:36 +0900 (235d821)
@@ -21,6 +21,7 @@ require "cgi"
 
 require "groonga/command/base"
 require "groonga/command/select"
+require "groonga/command/suggest"
 require "groonga/command/load"
 require "groonga/command/table-create"
 require "groonga/command/table-remove"

  Added: lib/groonga/command/suggest.rb (+47 -0) 100644
===================================================================
--- /dev/null
+++ lib/groonga/command/suggest.rb    2012-11-26 14:29:36 +0900 (5690c61)
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012  Haruka Yoshihara <yoshihara �� 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+require "groonga/command/base"
+
+module Groonga
+  module Command
+    class Suggest < Base
+      Command.register("suggest", self)
+
+      class << self
+        def parameter_names
+          [
+            :types,
+            :table,
+            :column,
+            :query,
+            :sortby,
+            :output_columns,
+            :offset,
+            :limit,
+            :frequency_threshold,
+            :conditional_probability_threshold,
+            :prefix_search,
+            :similar_search
+          ]
+        end
+      end
+    end
+  end
+end
+

  Added: test/command/test-suggest.rb (+68 -0) 100644
===================================================================
--- /dev/null
+++ test/command/test-suggest.rb    2012-11-26 14:29:36 +0900 (4491671)
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012  Haruka Yoshihara <yoshihara �� 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+class SuggestCommandTest < Test::Unit::TestCase
+  class CommandLineTest < self
+    include GroongaCommandTestUtils::CommandLineCommandParser
+
+    def test_ordered_arguments
+      types = "complete"
+      table = "Users"
+      column = "name"
+      query = "name:@ Ali"
+      sortby = "_score"
+      output_columns = "name"
+      offset = "0"
+      limit = "5"
+      frequency_threshold = "120"
+      conditional_probability_threshold = "0.3"
+      prefix_search = "yes"
+      similar_search = "yes"
+
+      arguments = [
+        types, table, column, query, sortby, output_columns,
+        offset, limit, frequency_threshold,
+        conditional_probability_threshold,
+        prefix_search, similar_search
+      ]
+      command = parse(*arguments)
+      assert_instance_of(Groonga::Command::Suggest, command)
+
+      expected_arguments = {
+        :types => types,
+        :table => table,
+        :column => column,
+        :query => query,
+        :sortby => sortby,
+        :output_columns => output_columns,
+        :offset => offset,
+        :limit => limit,
+        :frequency_threshold => frequency_threshold,
+        :conditional_probability_threshold => conditional_probability_threshold,
+        :prefix_search => prefix_search,
+        :similar_search => similar_search
+      }
+      assert_equal(expected_arguments, command.arguments)
+    end
+
+    private
+    def parse(*arguments)
+      super("suggest", arguments, :output_type => false)
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index