Page 1 of 1

Spelling checker

PostPosted: Fri Jan 09, 2009 12:16 pm
by Gintaras
Spelling checker using Aspell.
Requires QM 2.3.0 or later.

Download Aspell and one or more dictionaries from
http://aspell.net/win32/

Macro     ?
;Spelling checker using Aspell.
;Requires QM 2.3.0 or later.

;SETUP

;Download Aspell and one or more dictionaries from http://aspell.net/win32/.
;Install Aspell and dictionaries.
;After installing a new dictionary, restart QM.
;It is possible to use Aspell on computers where it is not installed. Copy Aspell folder from computer where it is installed to computer where it is not installed, to QM folder (or to your exe folder). Before #compile Caspell insert: SetEnvVar "aspell.dll" "$qm$\aspell\bin\aspell-15.dll". Or use some other folder.

;EXAMPLE

str w
inp- w "some misspelled or correct word" "" "mispeled"

#compile Caspell
Caspell k.Init("" "" "$my qm$\Aspell") ;;use "en_US" language, default Aspell options, and set folder of wordlists
;Caspell k.Init("" "ignore=2[]sug-mode=bad-spellers") ;;example of setting Aspell options
;Caspell k.Init("ru") ;;Russian
;out k.GetOption("repl") ;;you can see Aspell options

if(k.Check(w))
,mes "Correct." "" "i"
else
,ARRAY(str) a
,k.Suggest(w a)
,str s=a
,s-"[]"; s-"<it is correct word>"
,int i=list(s _s.format("%s is incorrect.[]Suggestions:" w))
,if(i=1)
,,k.AddWord(w)
,,k.SaveWordLists
,else if(i)
,,k.AddReplacement(w a[i-2])
,,k.SaveWordLists


Re: Spelling checker

PostPosted: Sat Jan 10, 2009 2:01 am
by TheVig
awesome...I can't wait to start working with this. It will allow me to do a lot with the database. I haven't gotten any chance to break it down, but can you build your own dictionaries with this?

thanks so much,
Jimmy Vig

Re: Spelling checker

PostPosted: Sat Jan 10, 2009 7:34 am
by Gintaras
Yes, I'll add functions to simplify it.

Re: Spelling checker

PostPosted: Sat Jan 10, 2009 3:42 pm
by TheVig
Wow. I look forward to working with this, I can't wait.

I plan to put the words in a database into the dictionary so the spell checker can grab suggestions. This is going to be so neat to add the my queries!

Re: Spelling checker

PostPosted: Sat Jan 10, 2009 5:28 pm
by Gintaras
Now personal word list and replacements word list can be used.

Re: Spelling checker

PostPosted: Sat Jan 10, 2009 6:37 pm
by TheVig
That's really great!

Been reading the aSpell manual...this is some really neat stuff!
I'm gonna be working with building my own custom dictionary, probably building some macros to automate the process so I don't have to edit the dictionary files directly. Still have a lot to learn and read before I'll be able to get anything to work right.

Thanks so much again...and if you whip up an example of a custom dictionary I would love to see it!
Jimmy Vig

Re: Spelling checker

PostPosted: Thu Jan 15, 2009 4:14 am
by TheVig
Wow...haven't made any progress on this. So much to understand. Seems so complicated to build custom dictionary. Lots to consider and then to learn the format so it all works...holy cow!

So if anyone else has experience building custom dictionaries that work with spell check programs, I would love to see some examples that will help me build one on my own. Or if anyone else wants to just help figure this out with me...That would be super sweet.

So I've also played around with some of the settings...Could you give more examples of setting different options. I can seem to get any of them to work. Like Munch and expand...or what ever else there is.
Also sug-mode=slow crashes...

Thanks,
Jimmy Vig

Re: Spelling checker

PostPosted: Thu Jan 15, 2009 7:56 am
by Gintaras
I don't have experience with custom dictionaries.
I tried to set several options, and it worked. Please post your code where does not work.
I also noticed that Aspell shuts down its process when values of some options are incorrect.
Aspell does not have Munch and expand options. Also does not have sug-mode slow.
Aspell options are in Aspell manual, 4.2.

Re: Spelling checker

PostPosted: Thu Jan 15, 2009 9:39 am
by TheVig
I checked into it a bit more and read the manual to get a better understanding. I had just misunderstood some parts on the first skim through. Building custom dictionaries looks pretty out there. I'm working on it slowly, but I don't expect to have anything done for quite a while.

Thanks for all your help.
Jimmy Vig

Re: Spelling checker

PostPosted: Tue Jun 23, 2009 6:55 pm
by poemcity
I followed the steps to use this program but I believe that I must have missed something. I can't get it to work.
I would like to use this program in conjunction with a program that doesn't have a spell check function.

Re: Spelling checker

PostPosted: Tue Jun 23, 2009 7:17 pm
by Gintaras
This thing only tells you is a word correctly spelled, and gives suggestions if incorrect.

Download and install Aspell and a dictionary. Download the attached file and import into Quick Macros. Run the first macro to see how it works. Use the imported functions in your macros where you want to check spelling of text. You can get the text from any source QM can get. Eg from a dialog, from a file, or copy from a window, etc. But it will not highlight misspelled words in programs.

Re: Spelling checker

PostPosted: Sun Oct 02, 2016 1:16 pm
by ssimop
Gintaras, Congrats, it is an excellent work!

If you do not mind, I have two questions, after having used it :

1. To shift between two languages (English-Greek) I understand the proper initialisation should be preceded with
Caspell k.Init


I would appreciate it if you could confirm.

2. To extend the spelling check to the text in a notepad window, I intend to get the text in a string, then find-replace each space character by a newline character ([]), then apply a foreach statement and examine each word per se, using your code. I undestand the correct character could be retrieved and stored to clipboard through a[i-2], in order to replace the mistaken word in text.
Please advise accordingly.

Many thanks in advance.

Re: Spelling checker

PostPosted: Sun Oct 02, 2016 2:24 pm
by Gintaras
1. To use two languages in single macro? I would use two variables, one initialized with "en", another with "el". I can see these en and el in C:\Program Files (x86)\Aspell\dict.

2. Example.

Macro Macro274     ?
out

str s=
;she sels
;sea shels

#compile Caspell
Caspell k.Init("en_US")

ARRAY(str) a; int i
tok s a
for i 0 a.len
,str& w=a[i]
,if(k.Check(w)) continue
,ARRAY(str) b
,k.Suggest(w b)
,str sug=b; sug.findreplace("[]" ", ")
,out F"{w}: {sug}"


Re: Spelling checker

PostPosted: Sun Oct 02, 2016 2:30 pm
by ssimop
Many thanks for both, indeed!

Re: Spelling checker

PostPosted: Sun Jan 15, 2017 12:01 pm
by ssimop
Let me first express my sincere appreciation to this perfect tool : Caspell.qml

I am wondering whether there already exists a tool (in the form of a QM function) to output the content of a dictionary, for example as a text file. I mean something similar to that implemented in : superuser.com/questions/137957/how-to-convert-aspell-dictionary-to-simple-list-of-words.

Furthermore, I am also wondering whether there exists a way to delete an entry in the dictionary.

Many thanks in advance.

Re: Spelling checker

PostPosted: Sun Jan 15, 2017 1:24 pm
by Gintaras
Don't exist. Run the aspell command line program, like in superuser, with RunConsole2.

Re: Spelling checker

PostPosted: Mon Jan 16, 2017 8:31 am
by ssimop
Thank you once more. According to your advice, I came up with the following function. It works satisfactorily with the english version (en).

Function tempf05     ?
str param sout
param="''$my qm$\Aspell\bin\aspell.exe'' -d el dump master "
RunConsole2(param sout)
out sout



However, I envisage some difficulties to convert characters in my native character set (el). Any advice is mostly welcome. Best Regards.