naoa
null+****@clear*****
Mon Aug 11 04:28:32 JST 2014
naoa 2014-08-11 04:28:32 +0900 (Mon, 11 Aug 2014) New Revision: 8091d1f342bfa35a991e1ee9d15a7eaaae80be77 https://github.com/groonga/groonga/commit/8091d1f342bfa35a991e1ee9d15a7eaaae80be77 Merged 1c5df3c: Merge pull request #186 from naoa/doc-highlight-function Message: doc: add highlight_html() Added files: doc/source/example/reference/functions/highlight_html/usage_basic.log doc/source/example/reference/functions/highlight_html/usage_setup.log doc/source/example/reference/functions/highlight_html/usage_string_literal.log doc/source/reference/functions/highlight_html.rst Modified files: doc/locale/en/LC_MESSAGES/reference.po doc/locale/ja/LC_MESSAGES/reference.po Modified: doc/locale/en/LC_MESSAGES/reference.po (+68 -0) =================================================================== --- doc/locale/en/LC_MESSAGES/reference.po 2014-08-10 22:50:22 +0900 (45846d2) +++ doc/locale/en/LC_MESSAGES/reference.po 2014-08-11 04:28:32 +0900 (d2dd710) @@ -9871,6 +9871,74 @@ msgid "pointに指定した座標が矩形の範囲内にあるかどうかをBo msgstr "" "pointに指定した座標が矩形の範囲内にあるかどうかをBool型の値で返します。" +msgid "highlight_html" +msgstr "" + +msgid "" +"``highlight_html`` tags target text. It can use to highlight the search " +"keywords. The tagged text are prepared for embedding HTML. Special " +"characters such as ``<`` and ``>`` are escapsed as ``<`` and ``>``. " +"Keyword is surrounded with ``<span class=\"keyword\">`` and ``</span>``. " +"For example, a tagged text of ``I am a groonga user. <3`` for keyword " +"``groonga`` is ``I am a <span class=\"keyword\">groonga</span> user. <3``." +msgstr "" +"``highlight_html`` tags target text. It can use to highlight the search " +"keywords. The tagged text are prepared for embedding HTML. Special " +"characters such as ``<`` and ``>`` are escapsed as ``<`` and ``>``. " +"Keyword is surrounded with ``<span class=\"keyword\">`` and ``</span>``. " +"For example, a tagged text of ``I am a groonga user. <3`` for keyword " +"``groonga`` is ``I am a <span class=\"keyword\">groonga</span> user. <3``." + +msgid "``highlight_html`` has only one parameter::" +msgstr "``highlight_html`` has only one parameter::" + +msgid "" +"``highlight_html`` can be used in only ``--output_columns`` in :doc:`/" +"reference/commands/select`." +msgstr "" +"``highlight_html`` can be used in only ``--output_columns`` in :doc:`/" +"reference/commands/select`." + +msgid "``highlight_html`` requires Groonga 4.0.5 or later." +msgstr "``highlight_html`` requires Groonga 4.0.5 or later." + +msgid "" +"``highlight_html`` requires :doc:`/reference/command/command_version` 2 " +"or later." +msgstr "" +"``highlight_html`` requires :doc:`/reference/command/command_version` 2 " +"or later." + +msgid "" +"The following example uses ``--query \"groonga mysql\"``. In this case, " +"``groonga`` and ``mysql`` are used as keywords." +msgstr "" +"The following example uses ``--query \"groonga mysql\"``. In this case, " +"``groonga`` and ``mysql`` are used as keywords." + +msgid "" +"The text are scanned by the keywords for tagging after they are normalized " +"by ``NormalizerAuto`` normalizer." +msgstr "" +"The text are scanned by the keywords for tagging after they are normalized " +"by ``NormalizerAuto`` normalizer." + +msgid "" +"``--query \"groonga mysql\"`` matches to only the first record's body. " +"``highlight_html(body)`` surrounds the keywords ``groonga`` or ``mysql`` " +"contained in the text with ``<span class=\"keyword\">`` and ``</span>``." +msgstr "" +"``--query \"groonga mysql\"`` matches to only the first record's body. " +"``highlight_html(body)`` surrounds the keywords ``groonga`` or ``mysql`` " +"contained in the text with ``<span class=\"keyword\">`` and ``</span>``." + +msgid "" +"``highlight_html`` returns a tagged string or ``null``. If " +"``highlight_html`` can't find any keywords, it returns ``null``." +msgstr "" +"``highlight_html`` returns a tagged string or ``null``. If " +"``highlight_html`` can't find any keywords, it returns ``null``." + msgid "html_untag" msgstr "html_untag" Modified: doc/locale/ja/LC_MESSAGES/reference.po (+69 -0) =================================================================== --- doc/locale/ja/LC_MESSAGES/reference.po 2014-08-10 22:50:22 +0900 (e825fb0) +++ doc/locale/ja/LC_MESSAGES/reference.po 2014-08-11 04:28:32 +0900 (892bc9e) @@ -8998,6 +8998,75 @@ msgstr "" msgid "pointに指定した座標が矩形の範囲内にあるかどうかをBool型の値で返します。" msgstr "" +msgid "highlight_html" +msgstr "" + +msgid "" +"``highlight_html`` tags target text. It can use to highlight the search " +"keywords. The tagged text are prepared for embedding HTML. Special " +"characters such as ``<`` and ``>`` are escapsed as ``<`` and ``>``. " +"Keyword is surrounded with ``<span class=\"keyword\">`` and ``</span>``. " +"For example, a tagged text of ``I am a groonga user. <3`` for keyword " +"``groonga`` is ``I am a <span class=\"keyword\">groonga</span> user. <3``." +msgstr "" +"``highlight_html`` は対象テキストをタグ付けします。検索文字列をハイライトさせ" +"るために利用することができます。タグ付けされたテキストはHTML中に埋め込みやすい" +"ように処理されています。``<`` や ``>`` などの特殊文字は < や > にエスケー" +"プされています。キーワードは ``<span class=\"keyword\">`` と ``</span>`` で囲ま" +"れています。たとえば、 ``I am a groonga user. <3`` という対象テキストのキーワー" +"ド ``groonga`` でタグ付けされたテキストは ``I am a <span class=\"keyword\">" +"groonga</span> user. <3`` となります。" + +msgid "``highlight_html`` has only one parameter::" +msgstr "``highlight_html`` の引数は1つだけです::" + +msgid "" +"``highlight_html`` can be used in only ``--output_columns`` in :doc:`/" +"reference/commands/select`." +msgstr "" +"``highlight_html`` は :doc:`/reference/commands/select` コマンドの ``--" +"output_columns`` 内でのみ指定できます。" + +msgid "``highlight_html`` requires Groonga 4.0.5 or later." +msgstr "``highlight_html`` を使うにはGroonga 4.0.5以降が必要です。" + +msgid "" +"``highlight_html`` requires :doc:`/reference/command/command_version` 2 " +"or later." +msgstr "" +"``highlight_html`` を使うには コマンドバージョン 2以降を使う必要がありま" +"す。" + +msgid "" +"The following example uses ``--query \"groonga mysql\"``. In this case, " +"``groonga`` and ``mysql`` are used as keywords." +msgstr "" +"以下の例は ``--query \"groonga mysql\"`` を使っています。この場合は、" +"キーワードとして ``groonga`` と ``mysql`` を使います。" + +msgid "" +"The text are scanned by the keywords for tagging after they are normalized " +"by ``NormalizerAuto`` normalizer." +msgstr "" +"キーワードとテキストは ``NormalizerAuto`` ノーマライザーで正規化されて" +"タグ付けのためにスキャンされます。" + +msgid "" +"``--query \"groonga mysql\"`` matches to only the first record's body. " +"``highlight_html(body)`` surrounds the keywords ``groonga`` or ``mysql`` " +"contained in the text with ``<span class=\"keyword\">`` and ``</span>``." +msgstr "" +"``--query \"groonga mysql\"`` は最初のレコードにマッチします。" +"``highlight_html(body)`` は、テキスト中に含まれるキーワード ``groonga`` と " +"``mysql`` を ``<span class=\"keyword\">`` と ``</span>`` で囲みます。" + +msgid "" +"``highlight_html`` returns a tagged string or ``null``. If " +"``highlight_html`` can't find any keywords, it returns ``null``." +msgstr "" +"``highlight_html`` はタグ付の文字列もしくは null を返します。" +"``highlight_html`` は該当するキーワードがない場合に null を返します。" + msgid "html_untag" msgstr "" Added: doc/source/example/reference/functions/highlight_html/usage_basic.log (+26 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/functions/highlight_html/usage_basic.log 2014-08-11 04:28:32 +0900 (b25a310) @@ -0,0 +1,26 @@ +Execution example:: + + select Entries --output_columns --match_columns body --query 'groonga mysql' --output_columns 'highlight_html(body)' --command_version 2 + # [ + # [ + # 0, + # 1407692444.86092, + # 0.00188779830932617 + # ], + # [ + # [ + # [ + # 1 + # ], + # [ + # [ + # "highlight_html", + # "null" + # ] + # ], + # [ + # "Mroonga is a <span class=\"keyword\">MySQL</span> storage engine based on <span class=\"keyword\">Groonga</span>. <b>Rroonga</b> is a Ruby binding of <span class=\"keyword\">Groonga</span>." + # ] + # ] + # ] + # ] Added: doc/source/example/reference/functions/highlight_html/usage_setup.log (+15 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/functions/highlight_html/usage_setup.log 2014-08-11 04:28:32 +0900 (c85ece9) @@ -0,0 +1,15 @@ +Execution example:: + + table_create Entries TABLE_NO_KEY + # [[0,1407692435.35498,0.0364797115325928],true] + column_create Entries body COLUMN_SCALAR ShortText + # [[0,1407692435.39156,0.0256640911102295],true] + table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto + # [[0,1407692435.423,0.0274741649627686],true] + column_create Terms document_index COLUMN_INDEX|WITH_POSITION Entries body + # [[0,1407692435.45051,0.0534985065460205],true] + load --table Entries + [ + {"body": "Mroonga is a MySQL storage engine based on Groonga. <b>Rroonga</b> is a Ruby binding of Groonga."} + ] + # [[0,1407692435.50406,0.378907442092896],1] Added: doc/source/example/reference/functions/highlight_html/usage_string_literal.log (+26 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/functions/highlight_html/usage_string_literal.log 2014-08-11 04:28:32 +0900 (7ae635f) @@ -0,0 +1,26 @@ +Execution example:: + + select Entries --output_columns 'highlight_html("Groonga is very fast fulltext search engine.")' --command_version 2 --match_columns body --query "groonga" + # [ + # [ + # 0, + # 1407693081.99183, + # 0.000126123428344727 + # ], + # [ + # [ + # [ + # 1 + # ], + # [ + # [ + # "highlight_html", + # "null" + # ] + # ], + # [ + # "<span class=\"keyword\">Groonga</span> is very fast fulltext search engine." + # ] + # ] + # ] + # ] Added: doc/source/reference/functions/highlight_html.rst (+90 -0) 100644 =================================================================== --- /dev/null +++ doc/source/reference/functions/highlight_html.rst 2014-08-11 04:28:32 +0900 (f600c09) @@ -0,0 +1,90 @@ +.. -*- rst -*- + +.. highlightlang:: none + +.. groonga-command +.. database: functions_highlight_html + +highlight_html +============== + +.. caution:: + + This feature is experimental. API will be changed. + +Summary +------- + +``highlight_html`` tags target text. It can use to highlight the search +keywords. The tagged text are prepared for embedding HTML. Special +characters such as ``<`` and ``>`` are escapsed as ``<`` and ``>``. +Keyword is surrounded with ``<span class="keyword">`` and ``</span>``. +For example, a tagged text of ``I am a groonga user. <3`` for keyword +``groonga`` is ``I am a <span class="keyword">groonga</span> user. <3``. + +Syntax +------ + +``highlight_html`` has only one parameter:: + + highlight_html(column) + +Usage +----- + +Here are a schema definition and sample data to show usage. + +.. groonga-command +.. include:: ../../example/reference/functions/highlight_html/usage_setup.log +.. table_create Entries TABLE_NO_KEY +.. column_create Entries body COLUMN_SCALAR ShortText +.. table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto +.. column_create Terms document_index COLUMN_INDEX|WITH_POSITION Entries body +.. load --table Entries +.. [ +.. ["content"], +.. {"body": "Mroonga is a MySQL storage engine based on Groonga. <b>Rroonga</b> is a Ruby binding of Groonga."} +.. ] + +``highlight_html`` can be used in only ``--output_columns`` in +:doc:`/reference/commands/select`. + +``highlight_html`` requires Groonga 4.0.5 or later. + +``highlight_html`` requires :doc:`/reference/command/command_version` 2 +or later. + +You also need to specify ``--query`` and/or ``--filter``. Keywords are +extracted from ``--query`` and ``--filter`` arguments. + +The following example uses ``--query "groonga mysql"``. In this case, +``groonga`` and ``mysql`` are used as keywords. + +.. groonga-command +.. include:: ../../example/reference/functions/highlight_html/usage_basic.log +.. select Entries --output_columns --match_columns body --query 'groonga mysql' --output_columns 'highlight_html(body)' --command_version 2 + +The text are scanned by the keywords for tagging after they are normalized +by ``NormalizerAuto`` normalizer. + +``--query "groonga mysql"`` matches to only the first record's body. +``highlight_html(body)`` surrounds the keywords ``groonga`` or ``mysql`` +contained in the text with ``<span class="keyword">`` and ``</span>``. + +You can specify string literal instead of column. + +.. groonga-command +.. include:: ../../example/reference/functions/highlight_html/usage_string_literal.log +.. select Entries --output_columns 'highlight_html("Groonga is very fast fulltext search engine.")' --command_version 2 --match_columns body --query "groonga" + +Return value +------------ + +``highlight_html`` returns a tagged string or ``null``. If +``highlight_html`` can't find any keywords, it returns ``null``. + +See also +-------- + +* :doc:`/reference/commands/select` +* :doc:`/reference/functions/highlight_full` -------------- next part -------------- HTML����������������������������...下载