1 | <?php |
||
10 | class DirectGenerator extends AbstractCandidateGenerator |
||
11 | { |
||
12 | public const SUGGEST_MODE_MISSING = 'missing'; |
||
13 | public const SUGGEST_MODE_POPULAR = 'popular'; |
||
14 | public const SUGGEST_MODE_ALWAYS = 'always'; |
||
15 | |||
16 | public const DEFAULT_SIZE = 5; |
||
17 | public const DEFAULT_SUGGEST_MODE = self::SUGGEST_MODE_MISSING; |
||
18 | public const DEFAULT_MAX_EDITS = 2; |
||
19 | public const DEFAULT_PREFIX_LENGTH = 1; |
||
20 | public const DEFAULT_MIN_WORD_LENGTH = 4; |
||
21 | public const DEFAULT_MAX_INSPECTIONS = 5; |
||
22 | public const DEFAULT_MIN_DOC_FREQ = 0.0; |
||
23 | public const DEFAULT_MAX_TERM_FREQ = 0.01; |
||
24 | |||
25 | public function __construct(string $field) |
||
29 | |||
30 | /** |
||
31 | * Set the field name from which to fetch candidate suggestions. |
||
32 | * |
||
33 | * @return $this |
||
34 | */ |
||
35 | public function setField(string $field) |
||
39 | |||
40 | /** |
||
41 | * Set the maximum corrections to be returned per suggest text token. |
||
42 | * |
||
43 | * @return $this |
||
44 | */ |
||
45 | public function setSize(int $size) |
||
49 | |||
50 | /** |
||
51 | * @param string $mode see SUGGEST_MODE_* constants for options |
||
52 | * |
||
53 | * @return $this |
||
54 | */ |
||
55 | public function setSuggestMode(string $mode) |
||
59 | |||
60 | /** |
||
61 | * @param int $max can only be a value between 1 and 2. Defaults to 2. |
||
62 | * |
||
63 | * @return $this |
||
64 | */ |
||
65 | public function setMaxEdits(int $max) |
||
69 | |||
70 | /** |
||
71 | * @param int $length defaults to 1 |
||
72 | * |
||
73 | * @return $this |
||
74 | */ |
||
75 | public function setPrefixLength(int $length) |
||
79 | |||
80 | /** |
||
81 | * @param int $min defaults to 4 |
||
82 | * |
||
83 | * @return $this |
||
84 | */ |
||
85 | public function setMinWordLength(int $min) |
||
89 | |||
90 | /** |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function setMaxInspections(int $max) |
||
97 | |||
98 | /** |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function setMinDocFrequency(float $min) |
||
105 | |||
106 | /** |
||
107 | * @return $this |
||
108 | */ |
||
109 | public function setMaxTermFrequency(float $max) |
||
113 | |||
114 | /** |
||
115 | * Set an analyzer to be applied to the original token prior to candidate generation. |
||
116 | * |
||
117 | * @param string $pre an analyzer |
||
118 | * |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function setPreFilter(string $pre) |
||
125 | |||
126 | /** |
||
127 | * Set an analyzer to be applied to generated tokens before they are passed to the phrase scorer. |
||
128 | * |
||
129 | * @return $this |
||
130 | */ |
||
131 | public function setPostFilter(string $post) |
||
135 | |||
136 | /** |
||
137 | * Convert to array so the generator can be included in a direct_generator list. |
||
138 | * |
||
139 | * @return array |
||
140 | */ |
||
141 | public function toArray() |
||
151 | } |
||
152 |