NOTE: this is a work in progress, and not yet ready for use.
- zig >= 0.14
Add this package to your zig project:
$ zig fetch --save=snowballstem git+https://github.com/thekorn/snowballstem.zig.git#main
Add dependency and import to the build.zig
file:
...
const snowballstem = b.dependency("snowballstem", .{
.target = target,
.optimize = optimize,
});
...
exe.root_module.addImport("snowballstem", snowballstem.module("snowballstem"));
And then, just use it in the code:
const std = @import("std");
const Stemmer = @import("snowballstem");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer std.debug.assert(gpa.deinit() == .ok);
const alloc = gpa.allocator();
const stemmer = try Stemmer.list(alloc);
defer alloc.free(stemmer);
std.debug.print(">>> {s}\n", .{stemmer});
}
Using nix
tests can be run like
$ nix develop -c zig build test --summary all
- the build is not correct, first build sometimes fails
- implement the stemmer
- make wasm buildable
- how to handle german umlauts?
- write test for german stemmer to check against the upstream test suite
- add other languages to tests (esp english)