diff options
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Suggest')
6 files changed, 195 insertions, 124 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php index e5f5e01c..00f21e44 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php @@ -1,13 +1,10 @@ <?php - namespace Elastica\Suggest; - use Elastica\Param; /** - * Class AbstractSuggestion - * @package Elastica\Suggest + * Class AbstractSuggestion. */ abstract class AbstractSuggest extends Param { @@ -32,45 +29,52 @@ abstract class AbstractSuggest extends Param } /** - * Suggest text must be set either globally or per suggestion + * Suggest text must be set either globally or per suggestion. + * * @param string $text - * @return \Elastica\Suggest\AbstractSuggest + * + * @return $this */ public function setText($text) { $this->_text = $text; + return $this; } /** * @param string $field - * @return \Elastica\Suggest\AbstractSuggest + * + * @return $this */ public function setField($field) { - return $this->setParam("field", $field); + return $this->setParam('field', $field); } /** * @param int $size - * @return \Elastica\Suggest\AbstractSuggest + * + * @return $this */ public function setSize($size) { - return $this->setParam("size", $size); + return $this->setParam('size', $size); } /** * @param int $size maximum number of suggestions to be retrieved from each shard - * @return \Elastica\Suggest\AbstractSuggest + * + * @return $this */ public function setShardSize($size) { - return $this->setParam("shard_size", $size); + return $this->setParam('shard_size', $size); } /** - * Retrieve the name of this suggestion + * Retrieve the name of this suggestion. + * * @return string */ public function getName() @@ -87,6 +91,7 @@ abstract class AbstractSuggest extends Param if (isset($this->_text)) { $array['text'] = $this->_text; } + return $array; } -}
\ No newline at end of file +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php index d9e6ac7c..6fba49db 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php @@ -1,11 +1,8 @@ <?php - namespace Elastica\Suggest\CandidateGenerator; - use Elastica\Param; class AbstractCandidateGenerator extends Param { - -}
\ No newline at end of file +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php index 0277a5ac..54ac7649 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php @@ -1,12 +1,10 @@ <?php - namespace Elastica\Suggest\CandidateGenerator; - /** - * Class DirectGenerator - * @package Elastica\Suggest\Phrase - * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html#_direct_generators + * Class DirectGenerator. + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html#_direct_generators */ class DirectGenerator extends AbstractCandidateGenerator { @@ -23,105 +21,120 @@ class DirectGenerator extends AbstractCandidateGenerator } /** - * Set the field name from which to fetch candidate suggestions + * Set the field name from which to fetch candidate suggestions. + * * @param string $field - * @return DirectGenerator + * + * @return $this */ public function setField($field) { - return $this->setParam("field", $field); + return $this->setParam('field', $field); } /** - * Set the maximum corrections to be returned per suggest text token + * Set the maximum corrections to be returned per suggest text token. + * * @param int $size - * @return DirectGenerator + * + * @return $this */ public function setSize($size) { - return $this->setParam("size", $size); + return $this->setParam('size', $size); } /** * @param string $mode see SUGGEST_MODE_* constants for options - * @return DirectGenerator + * + * @return $this */ public function setSuggestMode($mode) { - return $this->setParam("suggest_mode", $mode); + return $this->setParam('suggest_mode', $mode); } /** * @param int $max can only be a value between 1 and 2. Defaults to 2. - * @return DirectGenerator + * + * @return $this */ public function setMaxEdits($max) { - return $this->setParam("max_edits", $max); + return $this->setParam('max_edits', $max); } /** * @param int $length defaults to 1 - * @return DirectGenerator + * + * @return $this */ public function setPrefixLength($length) { - return $this->setParam("prefix_len", $length); + return $this->setParam('prefix_len', $length); } /** * @param int $min defaults to 4 - * @return DirectGenerator + * + * @return $this */ public function setMinWordLength($min) { - return $this->setParam("min_word_len", $min); + return $this->setParam('min_word_len', $min); } /** * @param int $max - * @return DirectGenerator + * + * @return $this */ public function setMaxInspections($max) { - return $this->setParam("max_inspections", $max); + return $this->setParam('max_inspections', $max); } /** * @param float $min - * @return DirectGenerator + * + * @return $this */ public function setMinDocFrequency($min) { - return $this->setParam("min_doc_freq", $min); + return $this->setParam('min_doc_freq', $min); } /** * @param float $max - * @return DirectGenerator + * + * @return $this */ public function setMaxTermFrequency($max) { - return $this->setParam("max_term_freq", $max); + return $this->setParam('max_term_freq', $max); } /** - * Set an analyzer to be applied to the original token prior to candidate generation + * Set an analyzer to be applied to the original token prior to candidate generation. + * * @param string $pre an analyzer - * @return DirectGenerator + * + * @return $this */ public function setPreFilter($pre) { - return $this->setParam("pre_filter", $pre); + return $this->setParam('pre_filter', $pre); } /** - * Set an analyzer to be applied to generated tokens before they are passed to the phrase scorer + * Set an analyzer to be applied to generated tokens before they are passed to the phrase scorer. + * * @param string $post - * @return DirectGenerator + * + * @return $this */ public function setPostFilter($post) { - return $this->setParam("post_filter", $post); + return $this->setParam('post_filter', $post); } -}
\ No newline at end of file +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/Completion.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/Completion.php new file mode 100644 index 00000000..0f0b3e61 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/Completion.php @@ -0,0 +1,26 @@ +<?php +namespace Elastica\Suggest; + +/** + * Comletion suggester. + * + * @author Igor Denisenko <im.denisenko@yahoo.com> + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html + */ +class Completion extends AbstractSuggest +{ + /** + * Set fuzzy parameter. + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html#fuzzy + * + * @param array $fuzzy + * + * @return $this + */ + public function setFuzzy(array $fuzzy) + { + return $this->setParam('fuzzy', $fuzzy); + } +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/Phrase.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/Phrase.php index 14630dc1..544f3678 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Suggest/Phrase.php +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/Phrase.php @@ -1,109 +1,121 @@ <?php - namespace Elastica\Suggest; use Elastica\Suggest\CandidateGenerator\AbstractCandidateGenerator; - /** - * Class Phrase - * @package Elastica\Suggest - * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html + * Class Phrase. + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html */ class Phrase extends AbstractSuggest { /** * @param string $analyzer - * @return \Elastica\Suggest\Phrase + * + * @return $this */ public function setAnalyzer($analyzer) { - return $this->setParam("analyzer", $analyzer); + return $this->setParam('analyzer', $analyzer); } /** - * Set the max size of the n-grams (shingles) in the field + * Set the max size of the n-grams (shingles) in the field. + * * @param int $size - * @return \Elastica\Suggest\Phrase + * + * @return $this */ public function setGramSize($size) { - return $this->setParam("gram_size", $size); + return $this->setParam('gram_size', $size); } /** - * Set the likelihood of a term being misspelled even if the term exists in the dictionary + * Set the likelihood of a term being misspelled even if the term exists in the dictionary. + * * @param float $likelihood Defaults to 0.95, meaning 5% of the words are misspelled. - * @return \Elastica\Suggest\Phrase + * + * @return $this */ - public function setRealWorldErrorLikelihood($likelihood) + public function setRealWordErrorLikelihood($likelihood) { - return $this->setParam("real_world_error_likelihood", $likelihood); + return $this->setParam('real_word_error_likelihood', $likelihood); } /** * Set the factor applied to the input phrases score to be used as a threshold for other suggestion candidates. * Only candidates which score higher than this threshold will be included in the result. + * * @param float $confidence Defaults to 1.0. - * @return \Elastica\Suggest\Phrase + * + * @return $this */ public function setConfidence($confidence) { - return $this->setParam("confidence", $confidence); + return $this->setParam('confidence', $confidence); } /** - * Set the maximum percentage of the terms considered to be misspellings in order to form a correction + * Set the maximum percentage of the terms considered to be misspellings in order to form a correction. + * * @param float $max - * @return \Elastica\Suggest\Phrase + * + * @return $this */ public function setMaxErrors($max) { - return $this->setParam("max_errors", $max); + return $this->setParam('max_errors', $max); } /** * @param string $separator - * @return \Elastica\Param + * + * @return $this */ public function setSeparator($separator) { - return $this->setParam("separator", $separator); + return $this->setParam('separator', $separator); } /** - * Set suggestion highlighting + * Set suggestion highlighting. + * * @param string $preTag * @param string $postTag - * @return \Elastica\Suggest\Phrase + * + * @return $this */ public function setHighlight($preTag, $postTag) { - return $this->setParam("highlight", array( + return $this->setParam('highlight', array( 'pre_tag' => $preTag, - 'post_tag' => $postTag + 'post_tag' => $postTag, )); } /** * @param float $discount - * @return \Elastica\Suggest\Phrase + * + * @return $this */ public function setStupidBackoffSmoothing($discount = 0.4) { - return $this->setSmoothingModel("stupid_backoff", array( - "discount" => $discount + return $this->setSmoothingModel('stupid_backoff', array( + 'discount' => $discount, )); } /** * @param float $alpha - * @return \Elastica\Suggest\Phrase + * + * @return $this */ public function setLaplaceSmoothing($alpha = 0.5) { - return $this->setSmoothingModel("laplace", array( - "alpha" => $alpha + return $this->setSmoothingModel('laplace', array( + 'alpha' => $alpha, )); } @@ -111,38 +123,42 @@ class Phrase extends AbstractSuggest * @param float $trigramLambda * @param float $bigramLambda * @param float $unigramLambda - * @return \Elastica\Suggest\Phrase + * + * @return $this */ public function setLinearInterpolationSmoothing($trigramLambda, $bigramLambda, $unigramLambda) { - return $this->setSmoothingModel("linear_interpolation", array( - "trigram_lambda" => $trigramLambda, - "bigram_lambda" => $bigramLambda, - "unigram_lambda" => $unigramLambda + return $this->setSmoothingModel('linear_interpolation', array( + 'trigram_lambda' => $trigramLambda, + 'bigram_lambda' => $bigramLambda, + 'unigram_lambda' => $unigramLambda, )); } /** - * @param string $model the name of the smoothing model - * @param array $params - * @return \Elastica\Suggest\Phrase + * @param string $model the name of the smoothing model + * @param array $params + * + * @return $this */ public function setSmoothingModel($model, array $params) { - return $this->setParam("smoothing", array( - $model => $params + return $this->setParam('smoothing', array( + $model => $params, )); } /** * @param AbstractCandidateGenerator $generator - * @return \Elastica\Suggest\Phrase + * + * @return $this */ public function addCandidateGenerator(AbstractCandidateGenerator $generator) { $generator = $generator->toArray(); $keys = array_keys($generator); $values = array_values($generator); + return $this->addParam($keys[0], $values[0]); } -}
\ No newline at end of file +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php index 3fca1731..9f082873 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php @@ -1,12 +1,10 @@ <?php - namespace Elastica\Suggest; - /** - * Class Term - * @package Elastica\Suggest - * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-term.html + * Class Term. + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-term.html */ class Term extends AbstractSuggest { @@ -19,97 +17,113 @@ class Term extends AbstractSuggest /** * @param string $analyzer - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setAnalyzer($analyzer) { - return $this->setParam("analyzer", $analyzer); + return $this->setParam('analyzer', $analyzer); } /** * @param string $sort see SORT_* constants for options - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setSort($sort) { - return $this->setParam("sort", $sort); + return $this->setParam('sort', $sort); } /** * @param string $mode see SUGGEST_MODE_* constants for options - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setSuggestMode($mode) { - return $this->setParam("suggest_mode", $mode); + return $this->setParam('suggest_mode', $mode); } /** - * If true, suggest terms will be lower cased after text analysis + * If true, suggest terms will be lower cased after text analysis. + * * @param bool $lowercase - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setLowercaseTerms($lowercase = true) { - return $this->setParam("lowercase_terms", (bool)$lowercase); + return $this->setParam('lowercase_terms', (bool) $lowercase); } /** - * Set the maximum edit distance candidate suggestions can have in order to be considered as a suggestion + * Set the maximum edit distance candidate suggestions can have in order to be considered as a suggestion. + * * @param int $max Either 1 or 2. Any other value will result in an error. - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setMaxEdits($max) { - return $this->setParam("max_edits", (int)$max); + return $this->setParam('max_edits', (int) $max); } /** - * The number of minimum prefix characters that must match in order to be a suggestion candidate + * The number of minimum prefix characters that must match in order to be a suggestion candidate. + * * @param int $length Defaults to 1. - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setPrefixLength($length) { - return $this->setParam("prefix_len", (int)$length); + return $this->setParam('prefix_len', (int) $length); } /** * The minimum length a suggest text term must have in order to be included. + * * @param int $length Defaults to 4. - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setMinWordLength($length) { - return $this->setParam("min_word_len", (int)$length); + return $this->setParam('min_word_len', (int) $length); } /** * @param int $max Defaults to 5. - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setMaxInspections($max) { - return $this->setParam("max_inspections", $max); + return $this->setParam('max_inspections', $max); } /** - * Set the minimum number of documents in which a suggestion should appear + * Set the minimum number of documents in which a suggestion should appear. + * * @param int|float $min Defaults to 0. If the value is greater than 1, it must be a whole number. - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setMinDocFrequency($min) { - return $this->setParam("min_doc_freq", $min); + return $this->setParam('min_doc_freq', $min); } /** - * Set the maximum number of documents in which a suggest text token can exist in order to be included + * Set the maximum number of documents in which a suggest text token can exist in order to be included. + * * @param float $max - * @return \Elastica\Suggest\Term + * + * @return $this */ public function setMaxTermFrequency($max) { - return $this->setParam("max_term_freq", $max); + return $this->setParam('max_term_freq', $max); } -}
\ No newline at end of file +} |