Skip to content

Commit

Permalink
more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismael Hery committed Apr 15, 2014
1 parent 5939a37 commit ff4c0a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
14 changes: 6 additions & 8 deletions lib/natural/stemmers/porter_stemmer_fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,13 @@ function stem(token) {
token = token.slice(0, -suf.length); // delete
else
token = token.slice(0, -suf.length) + 'iqU'; // replace by iqU
} else if ((suf = endsinArr(token, ['ité', 'ités'])) != '') {
pref2 = token.slice(token.length - suf.length - 3, suf.length - 1);
pref3 = token.slice(token.length - suf.length - 4, suf.length - 1);

if ((suf = endsinArr(r2_txt, ['ité', 'ités'])) != '') {
token = token.slice(0, -suf.length); // delete if in R2
} else if (pref3 === 'abil') {
} else if ((suf = endsinArr(token, ['abilité', 'abilités'])) != '') {
if (endsinArr(r2_txt, ['abilité', 'abilités']) != '')
token = token.slice(0, -suf.length); // delete
else
token = token.slice(0, -suf.length) + 'abl'; // replace by abl
}
} else if ((suf = endsinArr(r2_txt, ['ité', 'ités'])) != '') {
token = token.slice(0, -suf.length); // delete if in R2
} else if ((suf = endsinArr(token, ['icatif', 'icative', 'icatifs', 'icatives'])) != '') {
if ((suf = endsinArr(r2_txt, ['icatif', 'icative', 'icatifs', 'icatives'])) != '') {
token = token.slice(0, -suf.length); // delete
Expand Down
12 changes: 4 additions & 8 deletions spec/wrong
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{ word: 'supplications',
expected: 'suppliqu',
actual: 'iqu',
regions: { r1: 'plications', r2: 'ations', rv: 'pplications' }
{ word: 'prédications',
expected: 'prédiqu',
actual: 'iqu',
regions: { r1: 'ications', r2: 'ations', rv: 'dications' } },
{ word: 'affabilité',
expected: 'affabl',
actual: 'affabil',
regions: { r1: 'fabilité', r2: 'ilité', rv: 'bilité' } },

0 comments on commit ff4c0a8

Please sign in to comment.