Example #1
0
 /**
  * Method to get the base word of a token. This method uses the public
  * {@link FinderIndexerHelper::$stemmer} object if it is set. If no stemmer is set,
  * the original token is returned.
  *
  * @param   string  $token  The token to stem.
  * @param   string  $lang   The language of the token.
  *
  * @return  string  The root token.
  *
  * @since   2.5
  */
 public static function stem($token, $lang)
 {
     // Trim apostrophes at either end of the token.
     $token = StringHelper::trim($token, '\'');
     // Trim everything after any apostrophe in the token.
     if (($pos = StringHelper::strpos($token, '\'')) !== false) {
         $token = StringHelper::substr($token, 0, $pos);
     }
     // Stem the token if we have a valid stemmer to use.
     if (static::$stemmer instanceof FinderIndexerStemmer) {
         return static::$stemmer->stem($token, $lang);
     }
     return $token;
 }