/** * @param string $string * @return string */ public function prepareDataIndex($string) { $string = strip_tags($string); $expressions = $this->config->getLongTailExpressions(); foreach ($expressions as $expr) { $matches = null; preg_match_all($expr['match_expr'], $string, $matches); foreach ($matches[0] as $math) { $math = preg_replace($expr['replace_expr'], $expr['replace_char'], $math); $string .= ' ' . $math; } } return ' ' . $string . ' '; }
/** * Apply long tail expression for word * * @param string $word * * @return string */ public function longTail($word) { $expressions = $this->config->getLongTailExpressions(); foreach ($expressions as $expr) { $matches = null; preg_match_all($expr['match_expr'], $word, $matches); foreach ($matches[0] as $math) { $math = preg_replace($expr['replace_expr'], $expr['replace_char'], $math); if ($math) { $word = $math; } } } return $word; }