You are here

protected function SnowballStemmer::process in Snowball Stemmer 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/search_api/processor/SnowballStemmer.php \Drupal\snowball_stemmer\Plugin\search_api\processor\SnowballStemmer::process()

File

src/Plugin/search_api/processor/SnowballStemmer.php, line 143

Class

SnowballStemmer
Stems search terms.

Namespace

Drupal\snowball_stemmer\Plugin\search_api\processor

Code

protected function process(&$value) {

  // In the absence of the tokenizer, and/or HTML processor, this ensures
  // split words for stemming. Leaves strings in much the same state as
  // search api will for storage.
  $words = preg_split('/[^\\p{L}\\p{N}]+/u', strip_tags($value), -1, PREG_SPLIT_NO_EMPTY);
  $stemmed = [];
  foreach ($words as $word) {
    $stemmed[] = $this
      ->stem($word);
  }
  $value = implode(' ', $stemmed);
}