I'm using the Snowball compiler to generate a Rust implementation of our stemmer. This involves copying a couple of modules into my project. Unfortunately Clippy is not happy with one of the modules, and I don't feel confident modifying it. I've corralled the Snowball code into its own module structure and have this snowball.rs file:
mod among;
#[allow(unused)]
#[allow(clippy::all)]
mod snowball_env;
mod pali;
#[must_use]
pub fn pali_stem(input: &str) -> String {
let mut env = snowball_env::SnowballEnv::create(input);
pali::stem(&mut env);
env.get_current().to_string()
}
The #[allow(unused)] suppresses the compiler warnings, but the clippy errors remain.
The nuclear option is allow(warnings). I don't know exactly what Snowball is doing... obviously the ideal answer would be to actually fix the warnings (possibly by improving the codegen tool)... but if you're not that comfortable with Rust, I suppose that's not an option.
clippy::all is, unfortunately, misnamed; it does not refer to every lint that clippy can emit, but every lint that clippy emits by default. If your crate or Cargo.toml lint configuration has enabled non-default lints, you will need to turn those off too, by individual name or by group — for example, #[allow(clippy::pedantic)].
The rust-stemmers crate might expose the same modules? I'm not sure. The way I ended up here was adapting the tantivy-czech-stemmer approach. I asked the ParadeDB folk about dictionary stemmers and was pointed at this PR of their tantivy fork.
Why do you think this is not the same code? It seems to be the same at a glance. It’s true that any GitHub repository could have an arbitrary package name which is unrelated to what’s found on crates.io, but in this case they seem to be the same.
As far as I can tell, the code on the snowball project is not available on crates.io and rust_stemmers does not expose the copied code for users of the crate.
Oh, actually I've missed something. Tantivy uses the tantivy-stemmers crate. It depends on rust-stemmers:
As its default Stemmer tokenizer depends on a less then alive library rust-stemmers, there are only a very few languages available by default. Nevertheless, Tantivy provides an easy way to build our own custom tokenizers (see the tantivy-tokenizer-api for details).
Which is my main task. I didn't write the snowball Pali stemmer, I'm just experimenting with integration into Tantivy. Now, again from tantivy-stemmers:
All the raw algorithms in this library are written in the Snowball language, then complied into a Rust code using the Snowball compiler - all these generated algorithms are located at src/snowball/algorithms/*. A Snowball environment is then needed to execute the generated algorithm. This environment is comprised of files src/snowball/among.rs and src/snowball/env.rs - both files have been provided (ie. copied) from the official Snowball repository: rust/src/snowball.
So my role in all this is supporting the work of a fellow monk:
I have investigated both a dictionary stemmer, where we read all the terms and their stems from a file and use a HashMap, and an algorithmic stemmer using the algorithm above. Full disclosure: I don't actually know Pali.
Well, I know a lot of the vocabulary, but nothing much about grammar.
Snowball is very niche, but supported by most of the full-text search engines, including Elastic:
It seems a crate that easily allows new algorithms to be created and tested, along with documentation of the whole process, would be an excellent contribution to the Rust ecosystem.