[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pspell] c-API question
From: |
Troels Arvin |
Subject: |
[pspell] c-API question |
Date: |
Sun, 11 Jun 2000 21:30:07 +0200 |
Hello pspell developers,
I just installed pspell .11.0.1, and my previously reported problem
("Assertion 'h !=0' failed") is gone.
Nice.
I plan to add pspell support to PHP 4, in stead of PHP 4's aspell-module
which doesn't work with newer versions of aspell.
However, I'm still not that familiar with the pspell c-API, so I'll be
happy if someone looks over the code pasted below to see if I'm using
the API in a proper way. Note the questions included as comments in the
code.
Thanks in advance.
/Troels Arvin, Copenhagen, Denmark
/*
spellcheck.c
Is compiled by entering
gcc -Wall -o spellcheck -lpspell spellcheck.c
*/
#include <stdio.h>
#include "/usr/local/include/pspell/pspell.h"
int main()
{
PspellConfig * pcon;
PspellCanHaveError * perr;
PspellManager * pman;
PspellStringEmulation * psemu;
const PspellWordList * wlist;
char myWord[20]="dentistt";
char myLang[10]="en-US";
int result;
printf("myWord is `%s`; myLang is `%s`\n",myWord,myLang);
pcon=new_pspell_config();
pspell_config_replace(pcon, "language-tag",myLang);
perr=new_pspell_manager(pcon);
pman=to_pspell_manager(perr);
result = pspell_manager_check(pman,myWord);
if (result)
{
printf("The word '%s' is OK\n",myWord);
} else {
printf("The word '%s' is misspelled\n",myWord);
wlist = pspell_manager_suggest(pman,myWord);
if (!pspell_word_list_empty(wlist))
{
printf("List of suggestions:\n");
psemu = pspell_word_list_elements(wlist);
while (!pspell_string_emulation_at_end(psemu))
{
printf
(
"\t%s\n",
pspell_string_emulation_next(psemu)
);
}
delete_pspell_string_emulation(psemu);
}
/*
delete_pspell_wordlist(wlist); // Do I need to somehow
// destroy the wordlist?
*/
/*
delete_pspell_manager(pman); // If I do this, the
// program will core-dump.
// Not needed?
*/
delete_pspell_can_have_error(perr);
delete_pspell_config(pcon);
}
return(0);
}
- [pspell] c-API question,
Troels Arvin <=