[Groonga-commit] groonga/groonga [master] [test][taiyaki] add a test for query expansion.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 9月 11日 (日) 17:47:53 JST


Kouhei Sutou	2011-09-11 08:47:53 +0000 (Sun, 11 Sep 2011)

  New Revision: e1af44c5b2fe83a5853641629a6fee1bf7996bc1

  Log:
    [test][taiyaki] add a test for query expansion.

  Added files:
    test/unit/fixtures/story/taiyaki/synonyms.grn
  Modified files:
    test/unit/fixtures/story/taiyaki/Makefile.am
    test/unit/fixtures/story/taiyaki/ddl.grn
    test/unit/story/test-taiyaki.c

  Modified: test/unit/fixtures/story/taiyaki/Makefile.am (+2 -1)
===================================================================
--- test/unit/fixtures/story/taiyaki/Makefile.am    2011-09-11 08:35:45 +0000 (e1790d9)
+++ test/unit/fixtures/story/taiyaki/Makefile.am    2011-09-11 08:47:53 +0000 (e9993ef)
@@ -2,4 +2,5 @@ EXTRA_DIST =					\
 	ddl.grn					\
 	shops.grn				\
 	areas.grn				\
-	categories.grn
+	categories.grn				\
+	synoyms.grn

  Modified: test/unit/fixtures/story/taiyaki/ddl.grn (+3 -0)
===================================================================
--- test/unit/fixtures/story/taiyaki/ddl.grn    2011-09-11 08:35:45 +0000 (a39ee74)
+++ test/unit/fixtures/story/taiyaki/ddl.grn    2011-09-11 08:47:53 +0000 (bb373b8)
@@ -25,6 +25,9 @@ column_create Shops longitude_in_degree COLUMN_SCALAR Float
 column_create Shops categories COLUMN_VECTOR Categories
 column_create Shops area COLUMN_SCALAR Areas
 
+table_create Synonyms TABLE_HASH_KEY ShortText
+column_create Synonyms words COLUMN_SCALAR ShortText
+
 column_create Tags index COLUMN_INDEX Shops tags
 column_create Locations shop COLUMN_INDEX Shops location
 column_create Locations shop1 COLUMN_INDEX Shops location1

  Added: test/unit/fixtures/story/taiyaki/synonyms.grn (+5 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/fixtures/story/taiyaki/synonyms.grn    2011-09-11 08:47:53 +0000 (c5e6fc3)
@@ -0,0 +1,5 @@
+load --table Synonyms
+[
+{"_key":"たいやき",
+ "words":"(たいやき OR たい焼 OR 鯛焼き)"}
+]

  Modified: test/unit/story/test-taiyaki.c (+23 -1)
===================================================================
--- test/unit/story/test-taiyaki.c    2011-09-11 08:35:45 +0000 (80167c6)
+++ test/unit/story/test-taiyaki.c    2011-09-11 08:47:53 +0000 (f0623a6)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
 /*
-  Copyright (C) 2010  Kouhei Sutou <kou****@clear*****>
+  Copyright (C) 2010-2011  Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -37,6 +37,7 @@ void test_but_white(void);
 void test_drilldown(void);
 void test_drilldown_with_broken_reference(void);
 void test_weight_match(void);
+void test_query_expansion(void);
 
 static gchar *tmp_directory;
 
@@ -87,6 +88,7 @@ cut_setup(void)
   assert_send_command(cut_get_fixture_data_string("areas.grn", NULL));
   assert_send_command(cut_get_fixture_data_string("categories.grn", NULL));
   assert_send_command(cut_get_fixture_data_string("shops.grn", NULL));
+  assert_send_command(cut_get_fixture_data_string("synonyms.grn", NULL));
 }
 
 void
@@ -601,3 +603,23 @@ test_multi_geo_in_circle(void)
         distance,
         grn_test_location_string(yurakucho_latitude, yurakucho_longitude))));
 }
+
+void
+test_query_expansion(void)
+{
+  cut_assert_equal_string(
+    "[[[16],"
+    "[[\"name\",\"ShortText\"]],"
+    "[\"おめで鯛焼き本舗錦糸町東急店\"],"
+    "[\"そばたいやき空\"],"
+    "[\"たいやきひいらぎ\"]"
+    "]]",
+    send_command(
+      "select Shops "
+      "--sortby '+name' "
+      "--output_columns 'name' "
+      "--limit 3 "
+      "--match_columns name "
+      "--query たいやき "
+      "--query_expand Synonyms.words"));
+}




Groonga-commit メーリングリストの案内
Back to archive index