Debian Codegraph @

doc/source/reference/suggest/correction.rst

raw
1 .. -*- rst -*-
2
3 .. groonga-command
4 .. database: correction
5 .. $ groonga-suggest-create-dataset ${DB_PATH} query
6
7 Correction
8 ==========
9
10 This section describes about the following correction
11 features:
12
13 * How it works
14 * How to use
15 * How to learn
16
17 How it works
18 ------------
19
20 The correction feature uses three searches to compute corrected
21 words:
22
23 1. Cooccurrence search against learned data.
24 2. Similar search against registered words. (optional)
25
26 Cooccurrence search
27 ^^^^^^^^^^^^^^^^^^^
28
29 Cooccurrence search can find registered words from user's
30 wrong input. It uses user submit sequences that will be
31 learned from query logs, access logs and so on.
32
33 For example, there are the following user submissions:
34
35 +-------------------+---------------------------+
36 | query | time |
37 +===================+===========================+
38 | serach (typo!) | 2011-08-10T22:20:50+09:00 |
39 +-------------------+---------------------------+
40 | search (fixed!) | 2011-08-10T22:20:52+09:00 |
41 +-------------------+---------------------------+
42
43 Groonga creates the following correction pair from the above
44 submissions:
45
46 +----------+--------------------+
47 | input | corrected word |
48 +==========+====================+
49 |serach |search |
50 +----------+--------------------+
51
52 Groonga treats continuous submissions within a minute as
53 input correction by user. Not submitted user input sequence
54 between two submissions isn't used as learned data for
55 correction.
56
57 If an user inputs "serach" and cooccurrence search returns
58 "search" because "serach" is in input column and
59 corresponding corrected word column value is "search".
60
61 Similar search
62 ^^^^^^^^^^^^^^
63
64 Similar search can find registered words that has one or
65 more the same tokens as user input. TokenBigram tokenizer is
66 used for tokenization because suggest dataset schema
67 created by :doc:`/reference/executables/groonga-suggest-create-dataset`
68 uses TokenBigram tokenizer as the default tokenizer.
69
70 For example, there is a registered query "search engine". An
71 user can find "search engine" by "web search service",
72 "sound engine" and so on. Because "search engine" and "web
73 search engine" have the same token "search" and "search
74 engine" and "sound engine" have the same token "engine".
75
76 "search engine" is tokenized to "search" and "engine"
77 tokens. (Groonga's TokenBigram tokenizer doesn't tokenize
78 two characters for continuous alphabets and continuous
79 digits for reducing search
80 noise. TokenBigramSplitSymbolAlphaDigit tokenizer should be
81 used to ensure tokenizing to two characters.) "web search
82 service" is tokenized to "web", "search" and
83 "service". "sound engine" is tokenized to "sound" and
84 "engine".
85
86 How to use
87 ----------
88
89 .. groonga-command
90 .. load --table event_query --each 'suggest_preparer(_id, type, item, sequence, time, pair_query)'
91 .. [
92 .. {"sequence": "1", "time": 1312950803.86057, "item": "s"},
93 .. {"sequence": "1", "time": 1312950803.96857, "item": "sa"},
94 .. {"sequence": "1", "time": 1312950804.26057, "item": "sae"},
95 .. {"sequence": "1", "time": 1312950804.56057, "item": "saer"},
96 .. {"sequence": "1", "time": 1312950804.76057, "item": "saerc"},
97 .. {"sequence": "1", "time": 1312950805.76057, "item": "saerch", "type": "submit"},
98 .. {"sequence": "1", "time": 1312950809.76057, "item": "serch"},
99 .. {"sequence": "1", "time": 1312950810.86057, "item": "search", "type": "submit"}
100 .. ]
101
102 Groonga provides :doc:`/reference/commands/suggest` command to use
103 correction. `--type correct` option requests corrections.
104
105 For example, here is an command to get correction results by
106 "saerch":
107
108 .. groonga-command
109 .. include:: ../../example/reference/suggest/correction/select.log
110 .. suggest --table item_query --column kana --types correction --frequency_threshold 1 --query saerch
111
112 How it learns
113 -------------
114
115 Cooccurrence search uses learned data. They are based on
116 query logs, access logs and so on. To create learned data,
117 groonga needs user submit inputs with time stamp.
118
119 For example, an user wants to search by "search" but the
120 user has typo "saerch" before inputs the correct query. The
121 user inputs the query with the following sequence:
122
123 1. 2011-08-10T13:33:23+09:00: s
124 2. 2011-08-10T13:33:23+09:00: sa
125 3. 2011-08-10T13:33:24+09:00: sae
126 4. 2011-08-10T13:33:24+09:00: saer
127 5. 2011-08-10T13:33:24+09:00: saerc
128 6. 2011-08-10T13:33:25+09:00: saerch (submit!)
129 7. 2011-08-10T13:33:29+09:00: serch (correcting...)
130 8. 2011-08-10T13:33:30+09:00: search (submit!)
131
132 Groonga can be learned from the input sequence by the
133 following command::
134
135 load --table event_query --each 'suggest_preparer(_id, type, item, sequence, time, pair_query)'
136 [
137 {"sequence": "1", "time": 1312950803.86057, "item": "s"},
138 {"sequence": "1", "time": 1312950803.96857, "item": "sa"},
139 {"sequence": "1", "time": 1312950804.26057, "item": "sae"},
140 {"sequence": "1", "time": 1312950804.56057, "item": "saer"},
141 {"sequence": "1", "time": 1312950804.76057, "item": "saerc"},
142 {"sequence": "1", "time": 1312950805.76057, "item": "saerch", "type": "submit"},
143 {"sequence": "1", "time": 1312950809.76057, "item": "serch"},
144 {"sequence": "1", "time": 1312950810.86057, "item": "search", "type": "submit"}
145 ]
146