You are here

function porterstemmer_too_short in Porter-Stemmer 7

Same name and namespace in other branches
  1. 6.2 porterstemmer.module \porterstemmer_too_short()

Returns TRUE if word is too short to continue stemming.

10 calls to porterstemmer_too_short()
PorterStemmerInternalsUnitTest::testAdministered in ./porterstemmer.test
Test internal steps on the word "administered".
PorterStemmerInternalsUnitTest::testBaked in ./porterstemmer.test
Test internal steps on the word "baked".
PorterStemmerInternalsUnitTest::testGeology in ./porterstemmer.test
Test internal steps on the word "geology".
PorterStemmerInternalsUnitTest::testIesIed in ./porterstemmer.test
Test internal steps on the words "ies" and "ied".
PorterStemmerInternalsUnitTest::testShortWord in ./porterstemmer.test
Tests the function that determines if a word is "short".

... See full list

File

includes/standard-stemmer.inc, line 72
This is an implementation of the Porter 2 Stemming algorithm.

Code

function porterstemmer_too_short($word, $reset = FALSE) {
  static $min_chars = 0;
  if (!$min_chars || $reset) {

    // Get Search module's idea of minimum characters.
    $min_chars = intval(variable_get('minimum_word_size', 3));

    // Porter algorithm cannot handle less than 2 characters.
    if ($min_chars < 2) {
      $min_chars = 2;
    }
  }
  if (drupal_strlen($word) < $min_chars) {
    return TRUE;
  }
  return FALSE;
}