Recent

Author Topic: Lazspell - spellcheker  (Read 2502 times)

Raf20076

  • Full Member
  • ***
  • Posts: 173
    • https://github.com/Raf20076
Lazspell - spellcheker
« on: September 25, 2020, 03:49:30 pm »
Hello guys.

I was working on hunspell spellchecker and I managed to do a nice example using hunspell.dll and memo component.

In this example; Lazspell you can use a few dictionaries coded in UTF8 like de_De, en_GB, es_ES, fr_FR, it_IT, pl_PL,
pt_PT and ru_RU (dicts are included and hunspell.dll everything you need it)

At the moment lazspell is kept on my google drive but feel free if you want to improve it and keep it online anywhere.

Lazspell is based on my example in https://wiki.lazarus.freepascal.org/spelling#Demo_3_-_Spellchecker_-_non_characters.2C_carriage_return.2C_split_string but of course is more advanced

Lazspell finds errors and list them in errors box - click the error in errorsbox, the error will be highlighted in text, then click a word in suggestionsbox if you want to change the error.

Link to Lazspell https://drive.google.com/file/d/1vE-Rd5a20y2IjMsq-c3V2Fo3IBaEfU0k/view?usp=sharing


AlexTP

  • Hero Member
  • *****
  • Posts: 2365
    • UVviewsoft
Re: Lazspell - spellcheker
« Reply #1 on: September 25, 2020, 07:01:10 pm »
 You can
-create account on GitHub
-create new repo there
-don't install git! Go to your repo, and use web site to Make new file (button "Add file" above file list), to Edit it later, etc. All via browser!

Raf20076

  • Full Member
  • ***
  • Posts: 173
    • https://github.com/Raf20076
Re: Lazspell - spellcheker
« Reply #2 on: September 26, 2020, 09:15:16 am »
Ok Lazspell is available on github https://github.com/Raf20076/Lazspell

To use dictionaries create dict folder in Lazspell folder and put there all dictionaries.

QEnnay

  • Full Member
  • ***
  • Posts: 115
Re: Lazspell - spellcheker
« Reply #3 on: September 27, 2020, 10:23:28 pm »
Ok Lazspell is available on github https://github.com/Raf20076/Lazspell

To use dictionaries create dict folder in Lazspell folder and put there all dictionaries.

Sounds good, what do I have to do to use this with Linux Mint? Did you make any changes to Hunspell.dll? If so, what files do I need to make those changes to for Linux?
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

Raf20076

  • Full Member
  • ***
  • Posts: 173
    • https://github.com/Raf20076
Re: Lazspell - spellcheker
« Reply #4 on: September 28, 2020, 01:34:06 pm »
No changes were made to libhunspell.dll

If you want use it in any Linux see this topic https://wiki.lazarus.freepascal.org/spelling and https://wiki.lazarus.freepascal.org/spelling#Linux

In Linux usually you have to install hunspell in your system. So Lazspell doesnt use hunspell.dll

This part of code check in Linux if you have hunspell installed in '/usr/share/hunspell/';

Code: Pascal  [Select][+][-]
  1. procedure TForm1.SetDefaultDicPath();
  2. begin
  3.     {$ifdef LINUX}
  4.     DictPath := '/usr/share/hunspell/';
  5.     {$ENDIF}
  6.     {$ifdef WINDOWS}
  7.     DictPath := ExtractFilePath(Application.ExeName);
  8.     //DictPath := 'C:\Program Files\LibreOffice 5\share\extensions\dict-en\';
  9.     {$ENDIF}
  10.     {$ifdef DARWIN}
  11.     DictPath := '/Applications/Firefox.app/Contents/Resources/dictionaries/';
  12.     //DictPathAlt := ExtractFilePath(Application.ExeName);
  13.     {$endif}
  14. end;
  15.  
« Last Edit: September 28, 2020, 01:38:40 pm by Raf20076 »

QEnnay

  • Full Member
  • ***
  • Posts: 115
Re: Lazspell - spellcheker
« Reply #5 on: September 28, 2020, 08:31:28 pm »
In Linux usually you have to install hunspell in your system. So Lazspell doesnt use hunspell.dll

Thanks for that, I should have mentioned I know the .dll is not a Linux file, I just wondered if changes had been made to the source for windows and recompiled. If so, I would need to make those changes to the counterpart files in Linux.

I am already using Hunspell checker in my own email client, but it is cumbersome to manage at times so thought I'd check this out for Linux.

Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Lazspell - spellcheker
« Reply #6 on: November 14, 2020, 02:12:33 am »
Raf20076, great work, love what you have added to the wiki spelling page. I wrote the original including most/some of the "hunspell wrapper" and, knowing what I know now, did a bad job of it !

Its a licensing issue and for many users, people who write code for their own use, may not matter. But I am trying to get my code into Debian and their legal people are really, really strict. Its possible I have mislead a lot of people !

So, the issue ? The wrapper contains the bindings to the hunspell library and it is subject to copyright.  I copied the bindings from a 2013 post to the forum and who ever made that also neglected to comply with copyright. At Debian's insistence, I have made a totally new binding file, that is included in what we call the Wrapper.

I have just posted it at https://github.com/davidbannon/hunspell4pas

I suggest you base you stuff on that rather than the Wrapper on the wiki. I will remove that shortly referring people to the 'correct one'.

Sorry to mess you  (and anyone else) around.

(From now on, anything I post more that a handful of line will, absolutely, have a license. Not claiming a copyright and not putting a license on DOES NOT MAKE IT FREE TO USE - gee ! )

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Raf20076

  • Full Member
  • ***
  • Posts: 173
    • https://github.com/Raf20076
Re: Lazspell - spellcheker
« Reply #7 on: November 15, 2020, 10:48:51 am »
You are welcome.

I hope that in the future maybe someone will write checkspelling component for Lazarus, using hunspell wrapper and hunspell.dll.

I created chapter https://wiki.lazarus.freepascal.org/spelling#Note_about_dictionaries because I've noticed that many people didn't realise that dictionaries must be encoded in UTF-8. Also I wrote example https://wiki.lazarus.freepascal.org/spelling#Demo_3_-_Spellchecker_-_non_characters.2C_carriage_return.2C_split_string

Those examples are not clean and nice but can give an idea.

If you want more examples visit my github https://github.com/Raf20076 I will be updating them from time to time.

Once again hopefully one day we will have checkspelling component for Lazarus

Thank you to Dbannon for starting https://wiki.freepascal.org/spelling on Lazarus wiki






dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Lazspell - spellcheker
« Reply #8 on: November 16, 2020, 12:03:22 am »
OK, I have now removed my badly licensed "hunspell wrapper" and demo 1 from the spelling page. Almost exactly the same content is available from https://github.com/davidbannon/hunspell4pas

I would urge anyone using this unit to 'update' and stay legal !

Raf20076, you should put a license, any license or CC0 on your code at https://github.com/Raf20076

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Raf20076

  • Full Member
  • ***
  • Posts: 173
    • https://github.com/Raf20076
Re: Lazspell - spellcheker
« Reply #9 on: November 18, 2020, 12:52:08 pm »
OK Everything was updated

The license for Lazspell (Unit Main and Unit Functions) is https://creativecommons.org/publicdomain/zero/1.0/deed.en
The license for dictionaries see https://github.com/wooorm/dictionaries/blob/master/license
The license for hunspell.pas hunspell.inc is here https://github.com/davidbannon/hunspell4pas
https://wiki.freepascal.org/spelling updated

I hope so that it will be helpful.


« Last Edit: November 18, 2020, 12:54:28 pm by Raf20076 »

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Lazspell - spellcheker
« Reply #10 on: November 18, 2020, 11:42:46 pm »
OH, good. But I am afraid I messed the uses claues up for Windows, only just got around to testing under Windows.

Code: Pascal  [Select][+][-]
  1. dbannon@dell:~/Pascal$ sdiff -sb Hunspell/hunspell.pas tomboy-ng/source/hunspell.pas
  2. uses LazUTF8, SysUtils, {$ifdef linux}Process,{$endif} LazFil | uses LazUTF8, SysUtils,
  3. // LazUTF8 requires lazutils be added to dependencies         |     {$ifdef linux}Process,{$endif}          // Because we go
  4. // Forms needed so we can call Application.~   , add LCLBase  |     {$ifdef WINDOWS}Forms,{$endif}          // Forms needed s
  5. // lazlogger for the debug lines.                             |     LazFileUtils,                           // Requires we ad
  6.                                                               >     lazlogger;                              // lazlogger for

Its only the implementation uses clause. If you replicate that code in your git hub repo, suggest you update it or Windows users will get an error.

I have also moved the Windows DLL into the hunspell4pas github repo. makes sense for it to live there too.  Its difficult to download as is, so, when I get some time, I will make it look like a 'release'.

Davo

EDIT:  Thats a nice collection of dictionaries you are building up there, I have pointed my users to it ! Thanks.
« Last Edit: November 19, 2020, 12:04:46 am by dbannon »
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018