function porterstemmer_step1b in Porter-Stemmer 6.2
Same name and namespace in other branches
- 7 includes/standard-stemmer.inc \porterstemmer_step1b()
Step 1b of algorithm: eed, eedly, ed, edly, ing, ingly
Parameters
$word: Word to stem, modified in place if successful.
$r1: Position of start of R1 region in word.
Return value
TRUE if it is time to stop stemming, FALSE to continue.
3 calls to porterstemmer_step1b()
- PorterStemmerInternalsUnitTest::testAdministered in ./
porterstemmer.test - Test internal steps on the word "administered".
- PorterStemmerInternalsUnitTest::testBaked in ./
porterstemmer.test - Test internal steps on the word "baked".
- porterstemmer_stem in ./
porterstemmer.module - Stems a word, using the Porter Stemmer 2 algorithm.
File
- ./
porterstemmer.module, line 479 - 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_step1b(&$word, $r1) {
$tmp = $word;
$didit = FALSE;
// Replace these endings if in R1 region
$done = (porterstemmer_suffix($tmp, 'eedly', 'ee', $didit, NULL, $r1 + 5) or porterstemmer_suffix($tmp, 'eed', 'ee', $didit, NULL, $r1 + 3));
// Delete these endings if there's a vowel before the ending
$didit = FALSE;
if (!$done) {
porterstemmer_suffix($tmp, 'edly', '', $didit, '/' . PORTERSTEMMER_VOWEL . '.*edly$/') or porterstemmer_suffix($tmp, 'ed', '', $didit, '/' . PORTERSTEMMER_VOWEL . '.*ed$/') or porterstemmer_suffix($tmp, 'ingly', '', $didit, '/' . PORTERSTEMMER_VOWEL . '.*ingly$/') or porterstemmer_suffix($tmp, 'ing', '', $didit, '/' . PORTERSTEMMER_VOWEL . '.*ing$/');
}
// If we did one of these replacements, post-process...
if ($didit) {
$done = porterstemmer_suffix($tmp, 'at', 'ate', $didit) or porterstemmer_suffix($tmp, 'bl', 'ble', $didit) or porterstemmer_suffix($tmp, 'iz', 'ize', $didit);
if (!$done && preg_match('/' . PORTERSTEMMER_DOUBLE . '$/', $tmp)) {
// drop last letter if it's a double-letter ending
$tmp = drupal_substr($tmp, 0, -1);
$done = TRUE;
}
if (!$done && porterstemmer_short_word($tmp, $r1)) {
$tmp = $tmp . 'e';
}
}
return porterstemmer_step_ending($word, $tmp);
}