Skip to content

Instantly share code, notes, and snippets.

@akhenakh
Created July 30, 2013 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhenakh/6112663 to your computer and use it in GitHub Desktop.
Save akhenakh/6112663 to your computer and use it in GitHub Desktop.
test libstemmer on Mac using macports: clang -I/opt/local/include -L/opt/local/lib -lstemmer test.c -o test on Linux gcc -o test test.c -lstemmer (apt-get install libstemmer-dev See associated code in Golang http://play.golang.org/p/1QnkCZtuYr
#include <stdlib.h>
#include <stdio.h>
#include <libstemmer.h>
int main () {
struct sb_stemmer* sb;
sb_symbol* res;
int size;
sb = sb_stemmer_new("english", "UTF_8");
if (sb == NULL) {
printf("init error\n");
exit(1);
}
const sb_symbol * stemmed = sb_stemmer_stem(sb, "eating", 6);
if (stemmed == NULL)
{
printf("Out of memory\n");
exit(1);
}
size = sb_stemmer_length(sb);
if (size > 0) {
printf("%s\n", stemmed);
} else {
printf("no stem\n");
}
sb_stemmer_delete(sb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment