You are here

function porterstemmer_short_word in Porter-Stemmer 6.2

Same name and namespace in other branches
  1. 7 includes/standard-stemmer.inc \porterstemmer_short_word()

Checks to see if a word is considered "short" in Porter Stemmer 2.

A word is "short" if region R1 doesn't exist, and if it ends in a short syllable. A short syllable is consonant, followed by vowel, followed by consonant not w, x, Y; or else vowel starting a word, followed by a non-vowel.

Parameters

$word: Word to check.

$r1: Start position of R1 region in word.

Return value

TRUE if the word is short, false if not.

2 calls to porterstemmer_short_word()
PorterStemmerInternalsUnitTest::testShortWord in ./porterstemmer.test
Tests the function that determines if a word is "short".
porterstemmer_step1b in ./porterstemmer.module
Step 1b of algorithm: eed, eedly, ed, edly, ing, ingly

File

./porterstemmer.module, line 306
This is an implementation of the Porter 2 Stemming algorithm from http://snowball.tartarus.org/algorithms/english/stemmer.html by Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Code

function porterstemmer_short_word($word, $r1) {
  if (drupal_strlen($word) > $r1) {

    // R1 region exists, so this is not a short word
    return FALSE;
  }

  // Does it end in one type of short syllable?
  if (preg_match('/^' . PORTERSTEMMER_VOWEL . PORTERSTEMMER_NOT_VOWEL . '$/', $word)) {
    return TRUE;
  }

  // Does it end in the other type of short syllable?
  if (preg_match('/' . PORTERSTEMMER_NOT_VOWEL . PORTERSTEMMER_VOWEL . PORTERSTEMMER_NOT_VOWEL_WXY . '$/', $word)) {
    return TRUE;
  }
  return FALSE;
}