3 namespace Drupal\Tests\porterstemmer\Unit;
6 * Provides a common method for testing the stemmer.
11 * Load an associative array of known input/output pairs.
13 * This list comes from
14 * http://snowball.tartarus.org/algorithms/english/stemmer.html
15 * The array count is determined by parameters, below.
18 * Line of file to start on (count starts at 0), not counting short ones.
20 * Number of lines to test, not counting short ones.
23 * An associative array of word=stem pairs where element [0] is the word
24 * and element [1] is the expected stem.
26 public function retrieveStemWords($skipto = 0, $runto = 5000) {
27 $file = __DIR__ . '/testwords.txt';
28 $handle = @fopen($file, "r");
33 while (!feof($handle) && $ran < $runto) {
34 // Read a line of the file, and split into words.
35 $line = trim(fgets($handle, 4096));
36 $words = preg_split("/=/", $line, -1, PREG_SPLIT_NO_EMPTY);
37 if (count($words) < 2) {
41 if ($skipped < $skipto) {