[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[aspell-devel] Aspell DLL
From: |
Per-Erik Kristensson |
Subject: |
[aspell-devel] Aspell DLL |
Date: |
Fri, 21 May 2004 17:16:09 +0200 |
(I'm sorry if this is getting posted twice. I used wrong email address as
sender before, so I guessed it would be ignored)
Hi
I have been reading this list for over a year, but it wasn't until yesterday
I started to make what I have wanted for a long time. I would like to add
spell checking in one of my programs. My idea is that the user should
install Aspell separately to get spell checking in the program, otherwise
will this feature be disabled. So I want to use the Aspell dll in someway. I
have tested some code and now I have lot of questions :-).
First, how do I find the dll-file? I have found the path in
HKEY_LOCAL_MACHINE\SOFTWARE\Aspell\Path, but where is the actual file name?
Currently it is named aspell-15.dll, is it possible that this will change in
the future?
Second, I have been looking a lot on the GUI library that was posted for a
while ago
(http://mail.gnu.org/archive/html/aspell-devel/2004-04/msg00009.html). In
the wrapper class AspellWrapper I miss some functions:
aspell_speller_config
aspell_speller_error_message
aspell_config_error
aspell_config_error_message
aspell_config_error
aspell_document_checker_error_number
aspell_document_checker_error_message
aspell_document_checker_error
I have started to do my own wrapper class, which is basically the same but
it will not need wxwindows (so it will only works in Windows). In this I
have added these functions.
Third, I have tested my own wrapper class and it seems to work OK. It loads
the dll and sets up some public pointers to the functions just like the
AspellWrapper do. Then I tried to test some functions in the sample files
(list-dicts.c and example-c.c). I set up the configuration to use Swedish
directory, no problem. I can create an AspellSpeller object and check if a
word is correct. I can get a list of suggestions without any problem. But
when I try to check a document it will crash. First, I create
AspellDocumentChecker, it works ok. Then I call
aspell_document_checker_process, and then I check if there is error messages
with aspell_document_checker_error_message but there is none. But when I
call aspell_document_checker_next_misspelling the DLL crash with an
unhandled exception (0xC0000005: Access Violation). It looks like some
pointer is wrong, but where? Here is my code:
//First: Load DLL. All functions is accessed by m_aspell
//Config for using Swedish spell checking.
AspellConfig * config = m_aspell.NewAspellConfig();
m_aspell.AspellConfigReplace(config, "lang", "sv");
AspellCanHaveError * ret = m_aspell.NewAspellSpeller(config);
m_aspell.DeleteAspellConfig(config);
if (m_aspell.AspellError(ret) != 0)
{
//Something bad happen, end this
return;
}
else
{
//Create speller and check config.
AspellSpeller * myspeller = m_aspell.ToAspellSpeller(ret);
config = m_aspell.AspellSpellerConfig(myspeller);
if (m_aspell.AspellConfigError(config) != 0)
{
TRACE("Error: %s\n", m_aspell.AspellConfigErrorMessage(config));
}
//Check if "hello" is a legal word.
int have = m_aspell.AspellSpellerCheck(myspeller, "hello", -1);
if (have == 1)
{
TRACE("correct\n");
}
else if (have == 0)
{
TRACE("incorrect\n");
}
else
{
TRACE("Error: %s\n", m_aspell.AspellSpellerErrorMessage(myspeller));
}
//Find suggestions to the word "hjello"
CString list="Suggestions to \"hjello\":\r\n";
const AspellWordList * suggestions =
m_aspell.AspellSpellerSuggest(myspeller, "hjello", -1);
AspellStringEnumeration * elements =
m_aspell.AspellWordListElements(suggestions);
const char * word;
while ( (word = m_aspell.AspellStringEnumerationNext(elements)) != NULL )
{
// add to suggestion list
list += word;
list += "\r\n";
}
m_aspell.DeleteAspellStringEnumeration(elements);
MessageBox(list);
//Now will we check a document
AspellCanHaveError * ret=NULL;
AspellDocumentChecker * checker=NULL;
AspellToken token;
char text[] = "Helo wolrd";
//Create document checker
ret = m_aspell.NewAspellDocumentChecker(myspeller);
if (m_aspell.AspellError(ret) != 0)
{
//Something bad happen, stop
return;
}
checker = m_aspell.ToAspellDocumentChecker(ret);
m_aspell.AspellDocumentCheckerProcess(checker, text, -1);
int s = m_aspell.AspellDocumentCheckerErrorNumber(checker);
//This line will crash:
token = m_aspell.AspellDocumentCheckerNextMisspelling(checker);
}
Per-Erik Kristensson
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [aspell-devel] Aspell DLL,
Per-Erik Kristensson <=