| 1 |
<?php |
<?php |
| 2 |
// $Id: porterstemmer.module,v 1.2.2.1 2009/08/26 19:22:49 jhodgdon Exp $ |
// $Id: porterstemmer.module,v 1.2.2.2 2009/09/10 14:50:28 jhodgdon Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 80 |
$newmatch = array(); |
$newmatch = array(); |
| 81 |
foreach ( $match as $item ) { |
foreach ( $match as $item ) { |
| 82 |
$pos = $match[0][1]; |
$pos = $match[0][1]; |
| 83 |
|
// Note: Do not use drupal_strlen/drupal_substr here! Need the real PHP |
| 84 |
|
// string lengths/pos. |
| 85 |
if (preg_match('/' . $boundary . '/iu', $text, $newmatch, |
if (preg_match('/' . $boundary . '/iu', $text, $newmatch, |
| 86 |
PREG_OFFSET_CAPTURE, $pos + strlen($key))) { |
PREG_OFFSET_CAPTURE, $pos + strlen($key))) { |
| 87 |
$keyfound = substr($text, $pos, $newmatch[0][1] - $pos); |
$keyfound = substr($text, $pos, $newmatch[0][1] - $pos); |
| 322 |
|
|
| 323 |
// y -> Y if we should treat it as consonant |
// y -> Y if we should treat it as consonant |
| 324 |
$tmp = preg_replace('/^y/', 'Y', $tmp); |
$tmp = preg_replace('/^y/', 'Y', $tmp); |
| 325 |
$count = 1; |
$before = 'not going to match'; |
| 326 |
while ( $count ) { |
while ( $before != $tmp ) { |
| 327 |
// Do this replacement one by one, to avoid unlikely yyyy issues |
// Do this replacement one by one, to avoid unlikely yyyy issues |
| 328 |
|
$before = $tmp; |
| 329 |
|
// Note: do not use count param to preg_replace - added in 5.10!! |
| 330 |
$tmp = preg_replace('/(' . PORTERSTEMMER_VOWEL . ')y/', '$1Y', |
$tmp = preg_replace('/(' . PORTERSTEMMER_VOWEL . ')y/', '$1Y', |
| 331 |
$tmp, 1, $count); |
$tmp, 1); |
| 332 |
} |
} |
| 333 |
|
|
| 334 |
// This y/Y step should not have changed the word length |
// This y/Y step should not have changed the word length |