Lazarus

Programming => General => Topic started by: RedOctober on January 20, 2021, 01:18:57 am

Title: "ASpell" spell checker
Post by: RedOctober on January 20, 2021, 01:18:57 am
Thaddy was helping me in a separate thread, where he states:

Quote
Suggest to do what Avra suggests: use hunspell instead. That makes it also cross platform.
FPC comes also with ASpell in the default packages in the distribution. That is also cross platform.
There are already FPC sources and demo's for both.

I found the source files, but have no idea where to find the demos on how to use ASpell to check the spelling of words in a TMemo for example.  I need help with that.

I am still struggling with hunspell.  I found the demo project, but it it refuses to load the dictionaries, even though they exist and the full pathname is being provided.  I'll keep working on hunspell while waiting for an answer to this post.
Title: Re: "ASpell" spell checker
Post by: bobonwhidbey on January 20, 2021, 07:25:34 pm
I too am trying to get hunspell working. I've put the .dic file in the same folder as my test project. Like yourself, the FindLibrary() procedure fails. I am using 32-bit version of Laz on Win10.

Code: Pascal  [Select][+][-]
  1. var
  2.   Dic: THunspell;
  3. begin
  4.   Dic := THunSpell.Create(True, 'c:\Users\Bob\Documents\FPC\hunspell4\en_US.dic');  
Title: Re: "ASpell" spell checker
Post by: dbannon on January 21, 2021, 03:14:46 am
Did you see the wiki page https://wiki.freepascal.org/spelling  ?

It has a lot of info based on Hunspell.

> I am using 32-bit version of Laz on Win10.

Thats interesting.  Forum user rvk compiled a 64bit DLL for me some time ago, I could not cope with the Windows stuff !  If you are using a 32bit version of Lazarus, (and making a 32bit windows app) my guess is that the 64bit DLL will not work for you. I may well be wrong.  Unless of course, you have built or otherwise acquired a 32bit DLL ?

Anyway, looks like you are using my code, FindLibrary() drops some debug lines that may tell you just what failed or you can use the debugger to step through the code. It really does not do anything much in Windows, just looks for the dll in same directory as the executable.  So, either the DLL is there and the code cannot find it (sorry, sounds like me) or its not there and, quite rightly fails.

Davo



Title: Re: "ASpell" spell checker
Post by: bobonwhidbey on January 21, 2021, 03:55:08 am
The .dic file is, of  course, a text file. Mine has just under 50,000 lines/words so not a small dictionary. What .dll do I need to have in the EXE folder?
Title: Re: "ASpell" spell checker
Post by: dbannon on January 21, 2021, 04:24:07 am

Again, Did you see the wiki page https://wiki.freepascal.org/spelling  ?

The library contains the Hunspell code. If the function, FindLibrary() fails, its possible your problem is the library, not the dictionary.

Please read the wiki page https://wiki.freepascal.org/spelling

Davo
Title: Re: "ASpell" spell checker
Post by: Raf20076 on January 21, 2021, 04:35:42 pm
Hi there

You can check your hunspell.dll (what functions are inside .dll) with free dll_export_viewer from https://www.nirsoft.net/utils/dll_export_viewer.html. If the name of the functions in .dll differ (not the same like in hunspell wrapper (unit) you use, it could not work.

Use hunspell wrapper from https://github.com/davidbannon/hunspell4pas and hunspell.dll (64bit) https://github.com/davidbannon/hunspell4pas/tree/main/DLL
or from my example https://github.com/Raf20076/Lazspell (hunspell.dll is 32bit)

If you create 32bit application you must use 32bit hunspell.dll
If you create 64bit application you must use 64bit hunspell.dll

Dictionaries must be coded in UTF8
TinyPortal © 2005-2018