/** * Constructor loads the ruleset into memory * @param array $ruleSet the set of rules that will be used by the lancaster algorithm. if empty * this will use the default ruleset embedded in the LancasterStemmer */ public function __construct($ruleSet = array()) { //setup the default rule set if (empty($ruleSet)) { $ruleSet = LancasterStemmer::getDefaultRuleSet(); } $this->indexRules($ruleSet); //only get the english vowel checker $this->vowelChecker = VowelsAbstractFactory::factory("English"); }
public function testLancasterStemmper() { $stemmer = new LancasterStemmer(); $this->assertEquals('maxim', $stemmer->stem('maximum')); $this->assertEquals('presum', $stemmer->stem('presumably')); $this->assertEquals('multiply', $stemmer->stem('multiply')); $this->assertEquals('provid', $stemmer->stem('provision')); $this->assertEquals('ow', $stemmer->stem('owed')); $this->assertEquals('ear', $stemmer->stem('ear')); $this->assertEquals('say', $stemmer->stem('saying')); $this->assertEquals('cry', $stemmer->stem('crying')); $this->assertEquals('string', $stemmer->stem('string')); $this->assertEquals('meant', $stemmer->stem('meant')); $this->assertEquals('cem', $stemmer->stem('cement')); $this->assertEquals(null, $stemmer->stem(' ')); }