Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spelling checker
#1
Spelling checker using Aspell.
Requires QM 2.3.0 or later.

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

Macro
Code:
Select All      Help
;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


Attached Files
.qml   Caspell.qml (Size: 13.67 KB / Downloads: 470)
#2
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
#3
Yes, I'll add functions to simplify it.
#4
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!
#5
Now personal word list and replacements word list can be used.
#6
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
#7
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
#8
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.
#9
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
#10
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.
#11
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.
#12
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
Quote: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.
#13
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
Code:
Select All      Help
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}"
#14
Many thanks for both, indeed!
#15
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.
#16
Don't exist. Run the aspell command line program, like in superuser, with RunConsole2.
#17
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
Code:
Select All      Help
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.


Forum Jump:


Users browsing this thread: 1 Guest(s)