Skip to content

Commit

Permalink
fixed stemming words ending with letter 'y' according to Porter2 algo…
Browse files Browse the repository at this point in the history
…rithm (step 1c)
  • Loading branch information
MihaiValentin committed Apr 15, 2014
1 parent 1489c02 commit a5268cc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions lib/stemmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,12 @@ lunr.stemmer = (function(){
}
}

// Step 1c
re = /^(.+?)y$/;
// Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say)
re = /^(.+?[^aeiou])y$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(s_v);
if (re.test(stem)) { w = stem + "i"; }
w = stem + "i";
}

// Step 2
Expand Down
7 changes: 3 additions & 4 deletions lunr.js
Original file line number Diff line number Diff line change
Expand Up @@ -1400,13 +1400,12 @@ lunr.stemmer = (function(){
}
}

// Step 1c
re = /^(.+?)y$/;
// Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say)
re = /^(.+?[^aeiou])y$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(s_v);
if (re.test(stem)) { w = stem + "i"; }
w = stem + "i";
}

// Step 2
Expand Down
Loading

0 comments on commit a5268cc

Please sign in to comment.