Skip to content

Instantly share code, notes, and snippets.

@agasiev
Last active December 27, 2015 01:59
Show Gist options
  • Save agasiev/7248800 to your computer and use it in GitHub Desktop.
Save agasiev/7248800 to your computer and use it in GitHub Desktop.
Hunspell spelling test.
#include <stdlib.h>
#include <stdio.h>
#include <hunspell/hunspell.h>
int main() {
Hunhandle *spellObj = Hunspell_create("/home/artem/rude/ru_RU.aff", "/home/artem/rude/ru_RU.dic");
char str[60];
scanf("%s", str);
int result = Hunspell_spell(spellObj, str);
if(result == 0) {
printf("Spelling error!\n");
char **s = NULL;
int r = Hunspell_suggest(spellObj, &s, str);
printf("r = %d\n", r);
for (int i = 0; i < r; i++) {
printf("%d) %s\n", i+1, s[i]);
}
Hunspell_free_list(spellObj, &s, r);
}
else {
printf("Correct Spelling!");
int r = Hunspell_stem(spellObj, &s, str);
printf("Correct Spelling!\n");
printf("Stems = %d\n", r);
for (int i = 0; i < r; i++) {
printf("%d - %d) %s\n", c, i+1, s[i]);
}
Hunspell_free_list(spellObj, &s, r);
}
Hunspell_destroy(spellObj);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment