Skip to main content

Crate nltk_porter

Crate nltk_porter 

Source
Expand description

NLTK’s Porter stemmer, ported to Rust.

A faithful port of nltk.stem.porter.PorterStemmer (Porter 1980, plus the extensions NLTK ships). The word is processed by Unicode scalar value (char), matching Python’s str indexing.

Three modes, selectable like NLTK:

  • Mode::Nltk (default): NLTK contributors’ improvements.
  • Mode::Martin: only the extensions on Martin Porter’s website.
  • Mode::Original: faithful to the 1980 paper (Porter deprecates this).

Ported from NLTK (Apache-2.0).

use nltk_porter::{PorterStemmer, Mode};
let p = PorterStemmer::new(Mode::Nltk);
assert_eq!(p.stem("caresses"), "caress");
assert_eq!(p.stem("happy"), "happi");

Structs§

PorterStemmer
A Porter stemmer in a fixed Mode.

Enums§

Mode
Which variant of the algorithm to run.