[Groonga-commit] groonga/groonga at f92889c [master] Add snippet_full() function

Back to archive index

naoa null+****@clear*****
Thu Feb 18 16:26:32 JST 2016


naoa	2016-02-18 16:26:32 +0900 (Thu, 18 Feb 2016)

  New Revision: f92889cf2fc1d0529f95629a98913f497ebe554a
  https://github.com/groonga/groonga/commit/f92889cf2fc1d0529f95629a98913f497ebe554a

  Merged 4c9518d: Merge pull request #481 from naoa/snippet-full

  Message:
    Add snippet_full() function

  Added files:
    test/command/suite/select/function/snippet_full/cache.expected
    test/command/suite/select/function/snippet_full/cache.test
    test/command/suite/select/function/snippet_full/default.expected
    test/command/suite/select/function/snippet_full/default.test
    test/command/suite/select/function/snippet_full/default_tag.expected
    test/command/suite/select/function/snippet_full/default_tag.test
    test/command/suite/select/function/snippet_full/html_escape.expected
    test/command/suite/select/function/snippet_full/html_escape.test
    test/command/suite/select/function/snippet_full/leading_space.expected
    test/command/suite/select/function/snippet_full/leading_space.test
    test/command/suite/select/function/snippet_full/max_results.expected
    test/command/suite/select/function/snippet_full/max_results.test
    test/command/suite/select/function/snippet_full/normalizer.expected
    test/command/suite/select/function/snippet_full/normalizer.test
    test/command/suite/select/function/snippet_full/prefix.expected
    test/command/suite/select/function/snippet_full/prefix.test
    test/command/suite/select/function/snippet_full/suffix.expected
    test/command/suite/select/function/snippet_full/suffix.test
    test/command/suite/select/function/snippet_full/twice_keyword.expected
    test/command/suite/select/function/snippet_full/twice_keyword.test
  Modified files:
    lib/grn_proc.h
    lib/proc.c
    lib/proc/proc_snippet.c

  Modified: lib/grn_proc.h (+1 -0)
===================================================================
--- lib/grn_proc.h    2016-02-18 16:24:04 +0900 (1a37909)
+++ lib/grn_proc.h    2016-02-18 16:26:32 +0900 (0693510)
@@ -44,6 +44,7 @@ void grn_proc_init_lock_release(grn_ctx *ctx);
 void grn_proc_init_object_exist(grn_ctx *ctx);
 void grn_proc_init_object_remove(grn_ctx *ctx);
 void grn_proc_init_schema(grn_ctx *ctx);
+void grn_proc_init_snippet_full(grn_ctx *ctx);
 void grn_proc_init_snippet_html(grn_ctx *ctx);
 void grn_proc_init_table_create(grn_ctx *ctx);
 void grn_proc_init_table_list(grn_ctx *ctx);

  Modified: lib/proc.c (+2 -0)
===================================================================
--- lib/proc.c    2016-02-18 16:24:04 +0900 (5da13ac)
+++ lib/proc.c    2016-02-18 16:26:32 +0900 (b2bcc0d)
@@ -6659,4 +6659,6 @@ grn_db_init_builtin_query(grn_ctx *ctx)
   grn_proc_init_fuzzy_search(ctx);
 
   grn_proc_init_object_remove(ctx);
+
+  grn_proc_init_snippet_full(ctx);
 }

  Modified: lib/proc/proc_snippet.c (+184 -0)
===================================================================
--- lib/proc/proc_snippet.c    2016-02-18 16:24:04 +0900 (cf21987)
+++ lib/proc/proc_snippet.c    2016-02-18 16:26:32 +0900 (ac153ed)
@@ -20,6 +20,7 @@
 #include <string.h>
 
 #define GRN_FUNC_SNIPPET_HTML_CACHE_NAME      "$snippet_html"
+#define GRN_FUNC_SNIPPET_FULL_CACHE_NAME      "$snippet_full"
 
 static grn_obj *
 snippet_exec(grn_ctx *ctx, grn_obj *snip, grn_obj *text,
@@ -144,6 +145,189 @@ func_snippet_html(grn_ctx *ctx, int nargs, grn_obj **args,
   return snippets;
 }
 
+static grn_obj *
+func_snippet_full(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
+{
+  grn_obj *snippets = NULL;
+
+#define N_REQUIRED_ARGS 2
+#define KEYWORD_SET_SIZE 3
+  if (nargs > N_REQUIRED_ARGS) {
+    grn_obj *text = args[0];
+    grn_obj *hash_args_ptr = args[1];
+    grn_obj *expression = NULL;
+    grn_obj *snip = NULL;
+    grn_obj *snip_ptr;
+    unsigned int width = 200;
+    unsigned int max_n_results = 3;
+    grn_snip_mapping *mapping = NULL;
+    int flags = GRN_SNIP_SKIP_LEADING_SPACES;
+    const char *prefix = NULL;
+    int prefix_length = 0;
+    const char *suffix = NULL;
+    int suffix_length = 0;
+    const char *normalizer_name = NULL;
+    int normalizer_name_length = 0;
+    const char *default_open_tag = NULL;
+    int default_open_tag_length = 0;
+    const char *default_close_tag = NULL;
+    int default_close_tag_length = 0;
+    grn_obj *hash;
+
+    if (hash_args_ptr->header.type == GRN_PTR) {
+      hash = GRN_PTR_VALUE(hash_args_ptr);
+    }
+
+    if (hash) {
+      grn_hash_cursor *cursor;
+      void *key, *value;
+      int key_size;
+      if (hash_args_ptr->header.type == GRN_PTR) {
+        hash = GRN_PTR_VALUE(hash_args_ptr);
+      }
+      if (hash->header.type != GRN_TABLE_HASH_KEY) {
+        GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
+                         "snippet_full(): 2nd argument must be object literal: <%.*s>",
+                         (int)GRN_TEXT_LEN(args[1]), GRN_TEXT_VALUE(args[1]));
+        goto exit;
+      }
+      hash = GRN_PTR_VALUE(hash_args_ptr);
+
+      if (!(cursor = grn_hash_cursor_open(ctx, (grn_hash *)hash, NULL, 0, NULL, 0, 0, -1, 0))) {
+        GRN_PLUGIN_ERROR(ctx, GRN_NO_MEMORY_AVAILABLE,
+                         "snippet_full(): couldn't open cursor");
+        goto exit;
+      }
+      while (grn_hash_cursor_next(ctx, cursor) != GRN_ID_NIL) {
+        grn_hash_cursor_get_key_value(ctx, cursor, &key, &key_size, &value);
+        if (key_size == 5 && !memcmp(key, "width", 5)) {
+          width = *(unsigned int *)value;
+        } else if (key_size == 13 && !memcmp(key, "max_n_results", 13)) {
+          max_n_results = *(unsigned int *)value;
+        } else if (key_size == 19 && !memcmp(key, "skip_leading_spaces", 19)) {
+          if (!*(grn_bool *)value) {
+            flags &= ~GRN_SNIP_SKIP_LEADING_SPACES;
+          }
+        } else if (key_size == 11 && !memcmp(key, "html_escape", 11)) {
+          mapping = GRN_SNIP_MAPPING_HTML_ESCAPE;
+        } else if (key_size == 6 && !memcmp(key, "prefix", 6)) {
+          prefix = (const char *)value;
+          prefix_length = strlen(prefix);
+        } else if (key_size == 6 && !memcmp(key, "suffix", 6)) {
+          suffix = (const char *)value;
+          suffix_length = strlen(suffix);
+        } else if (key_size == 10 && !memcmp(key, "normalizer", 10)) {
+          normalizer_name = (const char *)value;
+          normalizer_name_length = strlen(normalizer_name);
+        } else if (key_size == 16 && !memcmp(key, "default_open_tag", 16)) {
+          default_open_tag = (const char *)value;
+          default_open_tag_length = strlen(default_open_tag);
+        } else if (key_size == 17 && !memcmp(key, "default_close_tag", 17)) {
+          default_close_tag = (const char *)value;
+          default_close_tag_length = strlen(default_close_tag);
+        } else {
+          GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT, "invalid option name: %.*s",
+                           key_size, (char *)key);
+          grn_hash_cursor_close(ctx, cursor);
+          goto exit;
+        }
+      }
+      grn_hash_cursor_close(ctx, cursor);
+    }
+
+    grn_proc_get_info(ctx, user_data, NULL, NULL, &expression);
+
+    snip_ptr = grn_expr_get_var(ctx, expression,
+                                GRN_FUNC_SNIPPET_FULL_CACHE_NAME,
+                                strlen(GRN_FUNC_SNIPPET_FULL_CACHE_NAME));
+    if (snip_ptr) {
+      snip = GRN_PTR_VALUE(snip_ptr);
+    } else {
+      snip_ptr =
+        grn_expr_get_or_add_var(ctx, expression,
+                                GRN_FUNC_SNIPPET_FULL_CACHE_NAME,
+                                strlen(GRN_FUNC_SNIPPET_FULL_CACHE_NAME));
+      GRN_OBJ_FIN(ctx, snip_ptr);
+      GRN_PTR_INIT(snip_ptr, GRN_OBJ_OWN, GRN_DB_OBJECT);
+
+      snip = grn_snip_open(ctx, flags, width, max_n_results,
+                           default_open_tag, default_open_tag_length,
+                           default_close_tag, default_close_tag_length, mapping);
+
+      if (snip) {
+        grn_rc rc;
+        unsigned int i;
+        if (!normalizer_name_length) {
+          grn_snip_set_normalizer(ctx, snip, GRN_NORMALIZER_AUTO);
+        } else {
+          grn_obj *normalizer;
+          normalizer = grn_ctx_get(ctx, normalizer_name, normalizer_name_length);
+          if (!grn_obj_is_normalizer_proc(ctx, normalizer)) {
+            grn_obj inspected;
+            GRN_TEXT_INIT(&inspected, 0);
+            grn_inspect(ctx, &inspected, normalizer);
+            ERR(GRN_INVALID_ARGUMENT,
+                "[snippet_full] not normalizer: %.*s",
+                (int)GRN_TEXT_LEN(&inspected),
+                GRN_TEXT_VALUE(&inspected));
+                GRN_OBJ_FIN(ctx, &inspected);
+                grn_obj_unlink(ctx, normalizer);
+            goto exit;
+          }
+          grn_snip_set_normalizer(ctx, snip, normalizer);
+          grn_obj_unlink(ctx, normalizer);
+        }
+        if (!default_open_tag_length && !default_close_tag_length) {
+          unsigned int n_keyword_sets = (nargs - N_REQUIRED_ARGS) / KEYWORD_SET_SIZE;
+          grn_obj **keyword_set_args = args + N_REQUIRED_ARGS;
+          for (i = 0; i < n_keyword_sets; i++) {
+            rc = grn_snip_add_cond(ctx, snip,
+                                   GRN_TEXT_VALUE(keyword_set_args[i * KEYWORD_SET_SIZE]),
+                                   GRN_TEXT_LEN(keyword_set_args[i * KEYWORD_SET_SIZE]),
+                                   GRN_TEXT_VALUE(keyword_set_args[i * KEYWORD_SET_SIZE + 1]),
+                                   GRN_TEXT_LEN(keyword_set_args[i * KEYWORD_SET_SIZE + 1]),
+                                   GRN_TEXT_VALUE(keyword_set_args[i * KEYWORD_SET_SIZE + 2]),
+                                   GRN_TEXT_LEN(keyword_set_args[i * KEYWORD_SET_SIZE + 2]));
+          }
+        } else {
+          unsigned int n_keywords = nargs - N_REQUIRED_ARGS;
+          grn_obj **keyword_args = args + N_REQUIRED_ARGS;
+          for (i = 0; i < n_keywords; i++) {
+            rc = grn_snip_add_cond(ctx, snip,
+                                   GRN_TEXT_VALUE(keyword_args[i]),
+                                   GRN_TEXT_LEN(keyword_args[i]),
+                                   NULL, 0,
+                                   NULL, 0);
+          }
+        }
+        GRN_PTR_SET(ctx, snip_ptr, snip);
+      }
+    }
+    if (snip) {
+      snippets = snippet_exec(ctx, snip, text, user_data,
+                              prefix, prefix_length,
+                              suffix, suffix_length);
+    }
+  }
+#undef N_REQUIRED_ARGS
+#undef KEYWORD_SET_SIZE
+
+exit :
+  if (!snippets) {
+    snippets = grn_plugin_proc_alloc(ctx, user_data, GRN_DB_VOID, 0);
+  }
+
+  return snippets;
+}
+
+
+void
+grn_proc_init_snippet_full(grn_ctx *ctx)
+{
+  grn_proc_create(ctx, "snippet_full", -1, GRN_PROC_FUNCTION,
+                  func_snippet_full, NULL, NULL, 0, NULL);
+}
+
 void
 grn_proc_init_snippet_html(grn_ctx *ctx)
 {

  Added: test/command/suite/select/function/snippet_full/cache.expected (+41 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/cache.expected    2016-02-18 16:26:32 +0900 (74e6c80)
@@ -0,0 +1,41 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "<p>mroonga and MySQL</p>"},
+{"content": "<p>pgroonga and PostgreSQL</p>"}
+]
+[[0,0.0,0.0],2]
+select Entries   --output_columns '   snippet_full(content, {},   "SQL", "<span class=\\"keyword\\">", "</span>"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "<p>mroonga and My<span class=\"keyword\">SQL</span></p>"
+        ]
+      ],
+      [
+        [
+          "<p>pgroonga and Postgre<span class=\"keyword\">SQL</span></p>"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/cache.test (+15 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/cache.test    2016-02-18 16:26:32 +0900 (f5b8f0d)
@@ -0,0 +1,15 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "<p>mroonga and MySQL</p>"},
+{"content": "<p>pgroonga and PostgreSQL</p>"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {}, \
+  "SQL", "<span class=\\"keyword\\">", "</span>" \
+  )' \
+  --command_version 2

  Added: test/command/suite/select/function/snippet_full/default.expected (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/default.expected    2016-02-18 16:26:32 +0900 (e6cafad)
@@ -0,0 +1,35 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "<p>groonga and MySQL</p>"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '   snippet_full(content, {},   "Groonga", "<span class=\\"keyword\\">", "</span>"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "<p><span class=\"keyword\">groonga</span> and MySQL</p>"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/default.test (+14 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/default.test    2016-02-18 16:26:32 +0900 (023e41b)
@@ -0,0 +1,14 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "<p>groonga and MySQL</p>"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {}, \
+  "Groonga", "<span class=\\"keyword\\">", "</span>" \
+  )' \
+  --command_version 2

  Added: test/command/suite/select/function/snippet_full/default_tag.expected (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/default_tag.expected    2016-02-18 16:26:32 +0900 (1f1d883)
@@ -0,0 +1,35 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "<p>groonga and MySQL</p>"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '   snippet_full(content, {"default_open_tag": "<span>", "default_close_tag": "</span>"},   "Groonga", "MySQL"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "<p><span>groonga</span> and <span>MySQL</span></p>"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/default_tag.test (+14 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/default_tag.test    2016-02-18 16:26:32 +0900 (de75b85)
@@ -0,0 +1,14 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "<p>groonga and MySQL</p>"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {"default_open_tag": "<span>", "default_close_tag": "</span>"}, \
+  "Groonga", "MySQL" \
+  )' \
+  --command_version 2

  Added: test/command/suite/select/function/snippet_full/html_escape.expected (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/html_escape.expected    2016-02-18 16:26:32 +0900 (d85b461)
@@ -0,0 +1,35 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "<p>groonga and MySQL</p>"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '   snippet_full(content, {"html_escape": true},   "groonga", "<span class=\\"keyword\\">", "</span>"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "&lt;p&gt;<span class=\"keyword\">groonga</span> and MySQL&lt;/p&gt;"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/html_escape.test (+14 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/html_escape.test    2016-02-18 16:26:32 +0900 (710f75b)
@@ -0,0 +1,14 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "<p>groonga and MySQL</p>"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {"html_escape": true}, \
+  "groonga", "<span class=\\"keyword\\">", "</span>" \
+  )' \
+  --command_version 2

  Added: test/command/suite/select/function/snippet_full/leading_space.expected (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/leading_space.expected    2016-02-18 16:26:32 +0900 (772d836)
@@ -0,0 +1,35 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "groonga and MySQL"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '   snippet_full(content, {"skip_leading_spaces": false},   "MySQL", "<span class=\\"keyword\\">", "</span>"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "groonga and<span class=\"keyword\"> MySQL</span>"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/leading_space.test (+14 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/leading_space.test    2016-02-18 16:26:32 +0900 (40ef33a)
@@ -0,0 +1,14 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "groonga and MySQL"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {"skip_leading_spaces": false}, \
+  "MySQL", "<span class=\\"keyword\\">", "</span>" \
+  )' \
+  --command_version 2

  Added: test/command/suite/select/function/snippet_full/max_results.expected (+36 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/max_results.expected    2016-02-18 16:26:32 +0900 (006689c)
@@ -0,0 +1,36 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '   snippet_full(content, {"width": 10, "max_n_results": 2},   "SQL", "<span class=\\"keyword\\">", "</span>"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "d My<span class=\"keyword\">SQL</span> an",
+          "Posrgre<span class=\"keyword\">SQL</span>"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/max_results.test (+14 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/max_results.test    2016-02-18 16:26:32 +0900 (9f52068)
@@ -0,0 +1,14 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {"width": 10, "max_n_results": 2}, \
+  "SQL", "<span class=\\"keyword\\">", "</span>" \
+  )' \
+  --command_version 2

  Added: test/command/suite/select/function/snippet_full/normalizer.expected (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/normalizer.expected    2016-02-18 16:26:32 +0900 (41602f7)
@@ -0,0 +1,35 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '   snippet_full(content, {"normalizer": "NormalizerAuto"},   "sql", "<span class=\\"keyword\\">", "</span>"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "groonga and My<span class=\"keyword\">SQL</span> and Posrgre<span class=\"keyword\">SQL</span>"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/normalizer.test (+14 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/normalizer.test    2016-02-18 16:26:32 +0900 (c8c8f93)
@@ -0,0 +1,14 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {"normalizer": "NormalizerAuto"}, \
+  "sql", "<span class=\\"keyword\\">", "</span>" \
+  )' \
+  --command_version 2

  Added: test/command/suite/select/function/snippet_full/prefix.expected (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/prefix.expected    2016-02-18 16:26:32 +0900 (94bb678)
@@ -0,0 +1,35 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '   snippet_full(content, {"prefix": "..."},   "SQL", "<span class=\\"w1\\">", "</span>"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "...groonga and My<span class=\"w1\">SQL</span> and Posrgre<span class=\"w1\">SQL</span>"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/prefix.test (+14 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/prefix.test    2016-02-18 16:26:32 +0900 (5792b33)
@@ -0,0 +1,14 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {"prefix": "..."}, \
+  "SQL", "<span class=\\"w1\\">", "</span>" \
+  )' \
+  --command_version 2

  Added: test/command/suite/select/function/snippet_full/suffix.expected (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/suffix.expected    2016-02-18 16:26:32 +0900 (b3fbf7b)
@@ -0,0 +1,35 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '   snippet_full(content, {"suffix": "..."},   "SQL", "<span class=\\"keyword\\">", "</span>"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "groonga and My<span class=\"keyword\">SQL</span> and Posrgre<span class=\"keyword\">SQL</span>..."
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/suffix.test (+14 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/suffix.test    2016-02-18 16:26:32 +0900 (fecc16c)
@@ -0,0 +1,14 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {"suffix": "..."}, \
+  "SQL", "<span class=\\"keyword\\">", "</span>" \
+  )' \
+  --command_version 2

  Added: test/command/suite/select/function/snippet_full/twice_keyword.expected (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/twice_keyword.expected    2016-02-18 16:26:32 +0900 (cce84de)
@@ -0,0 +1,35 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '   snippet_full(content, {"prefix": "..."},   "SQL", "<span class=\\"keyword1\\">", "</span>",   "groonga", "<span class=\\"keyword2\\">", "</span>"   )'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "snippet_full",
+          "null"
+        ]
+      ],
+      [
+        [
+          "...<span class=\"keyword2\">groonga</span> and My<span class=\"keyword1\">SQL</span> and Posrgre<span class=\"keyword1\">SQL</span>"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_full/twice_keyword.test (+15 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_full/twice_keyword.test    2016-02-18 16:26:32 +0900 (4ccb4e0)
@@ -0,0 +1,15 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries content COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"content": "groonga and MySQL and PosrgreSQL"}
+]
+
+select Entries \
+  --output_columns ' \
+  snippet_full(content, {"prefix": "..."}, \
+  "SQL", "<span class=\\"keyword1\\">", "</span>", \
+  "groonga", "<span class=\\"keyword2\\">", "</span>" \
+  )' \
+  --command_version 2
-------------- next part --------------
HTML����������������������������...
下載 



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