<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>5.5. 提案 — groonga v3.0.5ドキュメント</title> <link rel="stylesheet" href="../_static/groonga.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '3.0.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/translations.js"></script> <link rel="shortcut icon" href="../_static/favicon.ico"/> <link rel="top" title="groonga v3.0.5ドキュメント" href="../index.html" /> <link rel="up" title="5. サジェスト" href="../suggest.html" /> <link rel="next" title="6. 位置情報検索" href="../geolocation_search.html" /> <link rel="prev" title="5.4. 補正" href="correction.html" /> </head> <body> <div class="header"> <h1 class="title"> <a id="top-link" href="../index.html"> <span class="project">groonga</span> <span class="separator">-</span> <span class="description">オープンソースのカラムストア機能付き全文検索エンジン</span> </a> </h1> <div class="other-language-links"> <ul> <li><a href="../../../en/html/suggest/suggestion.html"><img src="../_static/us.png" alt="English">English page</a></li> </ul> </div> </div> <div class="related"> <h3>ナビゲーション</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="総合索引" accesskey="I">索引</a></li> <li class="right" > <a href="../geolocation_search.html" title="6. 位置情報検索" accesskey="N">次へ</a> |</li> <li class="right" > <a href="correction.html" title="5.4. 補正" accesskey="P">前へ</a> |</li> <li><a href="../index.html">groonga v3.0.5ドキュメント</a> »</li> <li><a href="../suggest.html" accesskey="U">5. サジェスト</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="suggestion"> <h1>5.5. 提案<a class="headerlink" href="#suggestion" title="このヘッドラインへのパーマリンク">¶</a></h1> <p>このセクションでは以下の補完機能について説明します。:</p> <ul class="simple"> <li><p class="first">どのように動作するか</p> </li> <li><p class="first">使い方</p> </li> <li><p class="first">学習方法</p> </li> </ul> <div class="section" id="how-it-works"> <h2>5.5.1. どのように動作するか<a class="headerlink" href="#how-it-works" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>提案機能は提案する語を計算するために1種類の検索を使います。:</p> <blockquote> <div><ol class="arabic simple"> <li><p class="first">学習したデータを共起検索。</p> </li> </ol> </div></blockquote> <div class="section" id="cooccurrence-search"> <h3>5.5.1.1. 共起検索<a class="headerlink" href="#cooccurrence-search" title="このヘッドラインへのパーマリンク">¶</a></h3> <p>共起検索はユーザの入力と関連する語を検索します。共起検索ではユーザの実行したときの検索クエリを使います。このデータはクエリログやアクセスログなどから学習します。</p> <p>例えば、ユーザが以下のように検索を実行したとします。:</p> <table border="1" class="docutils"> <colgroup> <col width="100%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head"><p class="first last">クエリ</p> </th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>search engine</td> </tr> <tr class="row-odd"><td>web search realtime</td> </tr> </tbody> </table> <p>groongaは以下のような提案ペアを作成します。</p> <table border="1" class="docutils"> <colgroup> <col width="22%" /> <col width="78%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head"><p class="first last">入力</p> </th> <th class="head"><p class="first last">提案される語</p> </th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>search</td> <td>search engine</td> </tr> <tr class="row-odd"><td>engine</td> <td>search engine</td> </tr> <tr class="row-even"><td>web</td> <td>web search realtime</td> </tr> <tr class="row-odd"><td>search</td> <td>web search realtime</td> </tr> <tr class="row-even"><td>realtime</td> <td>web search realtime</td> </tr> </tbody> </table> <p>これらのペアは以下の手順で作成します。:</p> <blockquote> <div><ol class="arabic simple"> <li><p class="first">ユーザの入力をTokenDelimitトークナイザーでトークナイズします。TokenDelimitは空白をトークンの区切りに使います。(例えば、"search engine"は"search"トークンと"engine"トークンの2つのトークンにトークナイズされます。)</p> </li> <li><p class="first">各トークンについて、トークンと元のクエリからなるペアを作成する。</p> </li> </ol> </div></blockquote> <p>ユーザが"search"と入力したとき、共起検索は"search engine"と"web search raltime"を返します。これは、"search"が2つの「入力」カラムに含まれていて、対応するそれぞれの「提案される語」カラムの値が"search engine"と"web search realtime"だからです。</p> </div> </div> <div class="section" id="how-to-use"> <h2>5.5.2. 使い方<a class="headerlink" href="#how-to-use" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>groongaは提案機能を使うために <a class="reference internal" href="../reference/commands/suggest.html"><em>suggest</em></a> コマンドを用意しています。 <cite>--type suggest</cite> オプションを使うと提案機能を利用できます。</p> <p>例えば、"search"と入力した時の提案結果を取得するコマンドは以下の通りです。:</p> <p>実行例:</p> <div class="highlight-none"><div class="highlight"><pre>suggest --table item_query --column kana --types suggest --frequency_threshold 1 --query search # [ # [ # 0, # 1337566253.89858, # 0.000355720520019531 # ], # { # "suggest": [ # [ # 2 # ], # [ # [ # "_key", # "ShortText" # ], # [ # "_score", # "Int32" # ] # ], # [ # "search engine", # 1 # ], # [ # "web search realtime", # 1 # ] # ] # } # ] </pre></div> </div> </div> <div class="section" id="how-it-learns"> <h2>5.5.3. 学習方法<a class="headerlink" href="#how-it-learns" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>共起検索は学習データを使います。学習データはクエリログやアクセスログなどを元に作成します。学習データを作成するには、タイムスタンプ付きの入力シーケンスと、タイムスタンプ付きの検索実行時の入力内容が必要です。</p> <p>例えば、ユーザが"engine"で検索したいとします。ユーザが以下のようなシーケンスで検索クエリを入力したとします。:</p> <blockquote> <div><ol class="arabic simple"> <li><p class="first">2011-08-10T13:33:25+09:00: search engine (検索実行)</p> </li> <li><p class="first">2011-08-10T13:33:28+09:00: web search realtime (検索実行)</p> </li> </ol> </div></blockquote> <p>以下のコマンドで上記の検索実行結果から学習します。:</p> <div class="highlight-none"><div class="highlight"><pre>load --table event_query --each 'suggest_preparer(_id, type, item, sequence, time, pair_query)' [ {"sequence": "1", "time": 1312950803.86057, "item": "search engine", "type": "submit"}, {"sequence": "1", "time": 1312950808.86057, "item": "web search realtime", "type": "submit"} ] </pre></div> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">目次</a></h3> <ul> <li><a class="reference internal" href="#">5.5. 提案</a><ul> <li><a class="reference internal" href="#how-it-works">5.5.1. どのように動作するか</a><ul> <li><a class="reference internal" href="#cooccurrence-search">5.5.1.1. 共起検索</a></li> </ul> </li> <li><a class="reference internal" href="#how-to-use">5.5.2. 使い方</a></li> <li><a class="reference internal" href="#how-it-learns">5.5.3. 学習方法</a></li> </ul> </li> </ul> <h4>前のトピックへ</h4> <p class="topless"><a href="correction.html" title="前の章へ">5.4. 補正</a></p> <h4>次のトピックへ</h4> <p class="topless"><a href="../geolocation_search.html" title="次の章へ">6. 位置情報検索</a></p> <h3>このページ</h3> <ul class="this-page-menu"> <li><a href="../_sources/suggest/suggestion.txt" rel="nofollow">ソースコードを表示</a></li> </ul> <div id="searchbox" style="display: none"> <h3>クイック検索</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="検索" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> モジュール、クラス、または関数名を入力してください </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>ナビゲーション</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="総合索引" >索引</a></li> <li class="right" > <a href="../geolocation_search.html" title="6. 位置情報検索" >次へ</a> |</li> <li class="right" > <a href="correction.html" title="5.4. 補正" >前へ</a> |</li> <li><a href="../index.html">groonga v3.0.5ドキュメント</a> »</li> <li><a href="../suggest.html" >5. サジェスト</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009-2013, Brazil, Inc. </div> </body> </html>