Esempio n. 1
0
 /**
  * Suggest
  *
  * @param string $text
  * @return string
  */
 public function suggest($text)
 {
     $result = false;
     $model = $this->suggestFactory->create()->load($text);
     $suggest = $model->getSuggest();
     if ($this->text->strtolower($text) != $this->text->strtolower($suggest)) {
         $result = $suggest;
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Convert $str to same register with $base
  *
  * @param string $str
  * @param string $base
  * @return string
  */
 protected function toSameRegister($str, $base)
 {
     $minLen = min($this->text->strlen($base), $this->text->strlen($str));
     for ($i = 0; $i < $minLen; $i++) {
         $chr = $this->text->substr($base, $i, 1);
         if ($chr != $this->text->strtolower($chr)) {
             $chrN = $this->text->substr($str, $i, 1);
             $chrN = strtoupper($chrN);
             $str = substr_replace($str, $chrN, $i, 1);
         }
     }
     return $str;
 }
Esempio n. 3
0
 /**
  * Split string to words
  *
  * @param string $string
  * @param array  &$results
  * @param int    $increment
  * @return void
  */
 protected function split($string, &$results, $increment = 1)
 {
     $string = $this->text->cleanString($string);
     $words = $this->text->splitWords($string);
     foreach ($words as $word) {
         if ($this->text->strlen($word) >= $this->text->getGram() && !is_numeric($word) && $this->text->strlen($word) <= 10) {
             $word = $this->text->strtolower($word);
             if (!isset($results[$word])) {
                 $results[$word] = $increment;
             } else {
                 $results[$word] += $increment;
             }
         }
     }
 }
Esempio n. 4
0
 /**
  * Case insensitive version of similarity()
  *
  * @param string $strA
  * @param string $strB
  *
  * @return int distance from 0 to 100
  */
 public function similarity($strA, $strB)
 {
     return $this->_similarity($this->text->strtolower($strA), $this->text->strtolower($strB));
 }