Struct stemmer::Stemmer [] [src]

pub struct Stemmer { /* fields omitted */ }

Methods

impl Stemmer
[src]

Lists all existing algorithms, returning a vector of valid algorithms that can be used as argument for Stemmer::new

Creates a new stemmer, provided algorithm is a valid one.

Arguments

  • algorithm: the name of a stemming algorithm. A list of supported algorithms can be obtained with Stemmer::list()

Returns

  • Some(Stemmer) if algorithm exists;
  • None otherwise.

Examples

use stemmer::Stemmer;
let stemmer = Stemmer::new("english");
assert!(stemmer.is_some());
use stemmer::Stemmer;
let stemmer = Stemmer::new("foobar");
assert!(stemmer.is_none());

Stems the word.

Returns an owned string containing the stemmed version of the word.

Example

use stemmer::Stemmer;
let mut stemmer = Stemmer::new("french").unwrap();
assert_eq!("éternu", &stemmer.stem("éternuerai"));

Stems the word and returns a str

The str reference it returns is only valid as long as you don't call stem or stem_str` again; thus, Rust's borrowchecker won't let call one of them function if you have such a reference in scope.

Example

use stemmer::Stemmer;
let mut stemmer = Stemmer::new("english").unwrap();
println!("{}", stemmer.stem_str("foo"));
println!("{}", stemmer.stem_str("bar")); // ok
println!("{}", stemmer.stem("baz")); // ok too
let foo: &str = stemmer.stem_str("foo");
// stemmer.stem("bar"); -> Compiler error because `stemmer` is already borrowed by `foo`

Trait Implementations

impl Drop for Stemmer
[src]

A method called when the value goes out of scope. Read more