Skip to content

fix: match Snowball in the Italian Porter stemmer - #830

Open
bardrop wants to merge 1 commit into
NaturalNode:masterfrom
bardrop-oss:fix-italian-stemmer-snowball
Open

bardrop wants to merge 1 commit into
NaturalNode:masterfrom
bardrop-oss:fix-italian-stemmer-snowball

Conversation

@bardrop

@bardrop bardrop commented Nov 19, 2026

Copy link
Copy Markdown

Fixes #829

PorterStemmerIt now gives the same stem as Snowball for all 37,426 words in snowball-data italian/voc.txt (12 differed before, checked against snowballstemmer 2.2.0).

Changes in lib/natural/stemmers/porter_stemmer_it.js:

  • Step 1: take the longest standard suffix of the word first, then check its region, like Snowball. Before, a shorter suffix was tried when the longest one was outside its region, so giocatrici lost ici (giocatr instead of giocatric). The amente, ità, ivo/iva and azione follow-up removals (iv, at, ic, abil, os) are done as Snowball does them.
  • Vowel marking: i/u between vowels is also marked when a vowel is accented (gioià → gioi, sdraiò → sdrai). A lookahead lets a vowel close one match and open the next.
  • Short words: words shorter than 3 letters are lowercased before return, so qu no longer comes back as qU.

Tests: new cases in spec/porter_stemmer_it_spec.ts fail on master (6 expectations) and pass now. Full suite: 901 specs, 0 failures. standard is clean on the changed file.

- Step 1 now takes the longest suffix first and only then checks its
  region, so giocatrici keeps 'ic' when 'atrici' is outside R2.
- Mark i/u between accented vowels too (gioià, sdraiò).
- Lowercase the U marker in words shorter than 3 letters (qu).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Italian stemmer differs from Snowball (step 1 region check, accented vowels, 'qu')

1 participant