Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Spell 1.1


  • Please log in to reply
30 replies to this topic
majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
 
Spell

Spellchecking using Hunspell


Download          Documentation

Posted Image

heresy
  • Members
  • 291 posts
  • Last active: Sep 26 2008 10:47 PM
  • Joined: 11 Mar 2008
They're missing dictionary for my language :(
but well, looks great and well documented as always.
Thanks for sharing majkinetor !
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com

Zippo()
  • Guests
  • Last active:
  • Joined: --
Excellent. Thanks.

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Looks useful. Thanks. :D

silveredge78
  • Members
  • 499 posts
  • Last active: Mar 14 2014 03:19 AM
  • Joined: 25 Jul 2006
Perhaps I'm just not getting it.

How can I use this practically while typing in notepad for example? I would imagine I could press a hotkey, it would select all, and process for misspelled words? Or would it have to do one word at a time?

Can someone give example code as to how to do this? I looked at the example code included in the spell.ahk code, but it doesn't seem to work for me.
SilverEdge78

sugardaddy
  • Members
  • 41 posts
  • Last active: Jan 26 2010 11:23 PM
  • Joined: 05 Aug 2006
This works fine as long as the script doing the spell check is in the same folder as the Spell code. But I want to be able to call Spell from different programs. I tried making the paths in the Init() absolute instead of relative, but it still didn't work. Any clues?
#include C:\Spell_10\Spell.ahk

hSpell_word = win
hSpell := Spell_Init("dic\en_US.aff", "dic\en_US.dic")
if (Spell_Spell(hSpell, hSpell_word)) {
	msgbox, 0, , "%hSpell_word%" is spelled correctly.
} else {
	hSpell_suggestions_len := Spell_Suggest(hSPell, hSpell_word, hSpell_suggestions)
	msgbox These words might match...`n`n%hSpell_suggestions_len% - %hSpell_suggestions%
}
Spell_Uninit( hSpell )


sugardaddy
  • Members
  • 41 posts
  • Last active: Jan 26 2010 11:23 PM
  • Joined: 05 Aug 2006
I figured it out. My Spell.ahk function library was in the same folder as the DLL, but since I was doing an "#include", the base of reference was the file I was running. So I changed all the functions in Spell.ahk to accept another param: the path to the Spell directory. I pass that in, and all is well.

Note: I also changed the DLL calls in Spell.ahk to have the full path.

siafulinux
  • Members
  • 3 posts
  • Last active: Dec 11 2009 03:50 AM
  • Joined: 01 Dec 2009
Thank you so much for this. I'm currently working on a script for my job that does multiple things, but one big issue is spell check, because the current software doesn't include it. This is going to make life a lot easier!

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
The link to the Hunspell documentation appears to be bad (404). Here's what is posted on the documentation page for this library:
http://sourceforge.n...group_id=143754

... and here's the link from the main Hunspell page (I think it goes to the same place):
http://sourceforge.n...group_id=143754

Does anyone have the correct link (if any) or worst case, can anyone load a copy of the API documentation to AutoHokey.net (or anywhere including email) so I can have a look/see?

Thanks.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
This link was available from sourceforge main page (it still is). However, even there it doesn't work anymore.

This is the first thing I found, c .h file:
<!-- m -->http://hunspell.sour... ... ource.html<!-- m -->


At this moment, I guess module can be upgraded in AHKL to handle Unicode dictionaries.
Posted Image

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
majkinetor,

A program that checks your spelling has always been a great value so when this library was released, I (like many) popped my head up and said, "Hey, this is cool!". Unfortunately (for me), I haven't had any real need to incorporate a spell checker into anything until recently so... I took a few minutes (OK, more than a few) to play with the library.

One of the things that popped up rather quickly was a lack of a custom dictionary. It's no big deal at first, but after a lot of use, you grow very weary of having custom words pop up again and again (and again!).

I hope you don't mind but I've been re-working the library to add the following:
[*:1xp1wnpj] Support for multiple custom dictionaries.
[*:1xp1wnpj] Support dynamic DLL location (DLL file can be anywhere).
[*:1xp1wnpj]Improved performance.After the code settles down, I'll PM you with the changes. If you decide you like it, you can incorporate it (none, some, or all) into the library.

Laters...

I actually used the Spell library to spell check this rambling before I posted it. Pretty cool!

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Custom dicts could be easily compiled.
Aif and Dict files can be generated from AHKL.

Dict file is list of lines containing words with first line containing number of records.
Aif can be just copy of full dictionary.

With PutWord you can temporarily add word to dict.
Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
*** v1.1 ***

Updates by jballi:

[*:3b33g632] To allow for a dynamic DLL file location, the library is defined in one location (Spell_Init) and the rest of the functions use the hSpell variable to get at the API functions which remain in memory until the Spell_Uninit function is run.
[*:3b33g632] There are two function to support custom dictionaries. One to load the words from the custom dictionary to the active dictionary (very fast. Takes about 7 ms to load 1,000 custom words) and another function to add words to a custom dictionary file. The functions were very deliberately separated so as to be able to support multiple custom dictionaries.
[*:3b33g632] Custom dictionaries are dictionaries as defined by applications like Microsoft Word, IESpell, etc. They are simple text files that can be edited by the user. They are not compiled dictionaries (or personal dictionaries as defined by HunSpell) that include metadata. There are no special programs or rules to maintain them.
Posted Image

Gauss
  • Members
  • 203 posts
  • Last active: Jan 27 2012 12:49 PM
  • Joined: 10 Sep 2009
I wish majkinetor could like noobs alittle bit more
How can I use this with other programs, like msn or yahoo or notepad?

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Although module is meant to be used with AHK scripts, you could use it with 3thd party tools in different ways.

- By monitoring clipboard
- Via timer, where you can get the text from the child control containing text.
- Perhaps even with hook, but that is far from trivial.
Posted Image