nltk-porter 0.1.0

NLTK's Porter stemmer ported to Rust, with the ORIGINAL / MARTIN / NLTK extension modes
Documentation
  • Coverage
  • 100%
    8 out of 8 items documented1 out of 5 items with examples
  • Size
  • Source code size: 18.39 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 388.45 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • VoiceLessQ/nltk-porter
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • VoiceLessQ

nltk-porter

crates.io

A faithful Rust port of NLTK's Porter stemmer (nltk.stem.porter.PorterStemmer), dependency-free and verified against NLTK.

NLTK ships its own Porter implementation with three selectable modes; this port reproduces all three exactly (unlike rust-stemmers, which wraps Snowball's Porter).

use nltk_porter::{PorterStemmer, Mode};

let p = PorterStemmer::new(Mode::Nltk);
assert_eq!(p.stem("caresses"), "caress");
assert_eq!(p.stem("happy"), "happi");
assert_eq!(p.stem("skies"), "sky");

Modes

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

Verification

Differential-tested against Python nltk's PorterStemmer: 68,000+ words (the NLTK words corpus plus tricky cases and random fuzz tokens) in each of the three modes, zero mismatches. Words are processed by Unicode scalar value, matching Python's str.

Ported from NLTK (Apache-2.0).