iCode Posted June 13, 2014 Posted June 13, 2014 This UDF was originally written by ProgAndy, who gave up Windows, and thus AutoIt, in favor of Linux. Apparently he was well liked and respected for his capabilities, and will be missed. I have been playing with this UDF and modifying it a bit for my own use and i wanted to post the code (permission was granted from ProgAndy after i finally managed to reach him). The original code is still available at progandy.de and is also added here as an attachment. My modified version is attached. You will need the ProgAndy version for the dll code and examples. I think this is a really cool project that could be useful to many, so it would be nice if we could work on it and improve it. I'm not very knowledgeable regarding the depths of AutoIt capabilities, and am especially weak in anything having to do with DLL's. I will post a complete example with a GUI in the near future, but for now, here is my modified UDF... expandcollapse popup#include-once ; #INDEX# ======================================================================================================================= ; Title .........: Hunspell Hypenate MyThes ; Description ...: This module contains various functions to call Hunspell, Hyphenate and MyThes ; Author ........: Prog@ndy http://progandy.co.cc/downloads/view.download/12 ; Licence .......: The DLLs are open source, taken from the NHunspell project (http://nhunspell.sf.net) ; NHunspell is licenced under: GPL/LGPL/MPL. ; Free use in commercial applications is permittet according to the LGPL and MPL licenses. ; Your commercial application can link against the NHunspell DLLs. ; =============================================================================================================================== OnAutoItExitRegister("__Spell_Shutdown") ; =============================================================================================================================== ; GLOBAL VARIABLES ; =============================================================================================================================== Global $hHunspellDll = -1, $hHunspell = -1 ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_Spell_HunspellAdd ;_Spell_HunspellAddWithAffix ;_Spell_HunspellAnalyze ;_Spell_HunspellFree ;_Spell_HunspellGenerate ;_Spell_HunspellInit ;_Spell_HunspellSpell ;_Spell_HunspellStem ;_Spell_HunspellSuggest ;_Spell_HyphenFree ;_Spell_HyphenHyphenate ;_Spell_HyphenInit ;_Spell_MyThesFree ;_Spell_MyThesInit ;_Spell_MyThesLookup ;_Spell_Startup ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ;__Spell_PtrStringReadW ;__Spell_HunspellReadStringArray ;__Spell_MyThesReadMarshalBuffer ;__Spell_MyThesReadMeaningBuffer ;__Spell_Shutdown ; =============================================================================================================================== ; #ORIGINAL_CALLCONV#============================================================================================================ ; definitions taken from sourcefile: /trunk/Hunspell/HunspellExportFunctions.cpp ; Link: http://nhunspell.svn.sourceforge.net/viewvc/nhunspell/trunk/Hunspell/ ; ; #define DLLEXPORT extern "C" _declspec( dllexport ) ==> CDECL ! ; ; DLLEXPORT NHunspell * HunspellInit(wchar_t * aff_file, wchar_t *dict_file, wchar_t * key) ; DLLEXPORT void HunspellFree(NHunspell * handle ) ; DLLEXPORT bool HunspellAdd(NHunspell * handle, wchar_t * word ) ; DLLEXPORT bool HunspellAddWithAffix(NHunspell * handle, wchar_t * word, wchar_t * affix ) ; DLLEXPORT bool HunspellSpell(NHunspell * handle, wchar_t * word ) ; DLLEXPORT void * HunspellSuggest(NHunspell * handle, wchar_t * word ) ; DLLEXPORT void * HunspellAnalyze(NHunspell * handle, wchar_t * word ) ; DLLEXPORT void * HunspellStem(NHunspell * handle, wchar_t * word ) ; DLLEXPORT void * HunspellGenerate(NHunspell * handle, wchar_t * word, wchar_t * word2 ) ; ; DLLEXPORT void * HyphenInit(wchar_t * dict_file) ; DLLEXPORT void HyphenFree(NHyphen * handle ) ; DLLEXPORT void * HyphenHyphenate(NHyphen * handle, wchar_t * word ) ; ; DLLEXPORT void * MyThesInit(wchar_t * idx_file, wchar_t * dat_file) ; DLLEXPORT void MyThesFree(NMyThes * handle ) ; DLLEXPORT void * MyThesLookup(NMyThes * handle, wchar_t * word ) ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellAdd ; Description ...: add word to the run-time dictionary ; Syntax.........: _Spell_HunspellAdd($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the word to add ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellAddWithAffix ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellAdd($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "int:cdecl", "HunspellAdd", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellAddWithAffix ; Description ...: add word to the run-time dictionary with affix flags of the example (a dictionary word) ; Syntax.........: _Spell_HunspellAddWithAffix($hHunspell, $sWord, $sAffix) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the word to add ; $sAffix - Affix ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: Hunspell will recognize affixed forms of the new word, too. ; Related .......: _Spell_HunspellAdd ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellAddWithAffix($hHunspell, $sWord, $sAffix) Local $aResult = DllCall($hHunspellDll, "int:cdecl", "HunspellAddWithAffix", "ptr", $hHunspell, "wstr", $sWord, "wstr", $sAffix) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellAnalyze ; Description ...: morphological analysis of the word ; Syntax.........: _Spell_HunspellAnalyze($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the word to analyze ; Return values .: Success - array with analyzation result ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellGenerate ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellAnalyze($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HunspellAnalyze", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2, 0, 0) Local $aTemp = __Spell_HunspellReadStringArray($aResult[0]) If @error Then Return SetError(3, 0, 0) Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellFree ; Description ...: Frees memory associated with a Hunspell handle ; Syntax.........: _Spell_HunspellFree($hHunspell) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; Return values .: Failure - Sets @error = 1 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HunspellFree($hHunspell) DllCall($hHunspellDll, "none:cdecl", "HunspellFree", "ptr", $hHunspell) If @error Then Return SetError(1) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellGenerate ; Description ...: morphological generation by example(s) ; Syntax.........: _Spell_HunspellGenerate($hHunspell, $sWord, $sWord2) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - first word ; $sWord2 - second word ; Return values .: Success - array with result ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellAnalyze ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellGenerate($hHunspell, $sWord, $sWord2) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HunspellGenerate", "ptr", $hHunspell, "wstr", $sWord, "wstr", $sWord2) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2,0,0) Local $aTemp = __Spell_HunspellReadStringArray($aResult[0]) If @error Then Return SetError(3, 0, 0) Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellInit ; Description ...: Initializes Hunspell ; Syntax.........: _Spell_HunspellInit($sAff_file, $sDict_file, $sKey=0) ; Parameters ....: $sAff_file - Hunspell .aff-file ; $sDict_file - Hunspell .dict-file ; $sKey - [optional] a Key String ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HunspellInit($sAff_file, $sDict_file, $sKey=0) Local $tpKey='ptr' If IsString($sKey) Then $tpKey='wstr' Local $aResult = DllCall($hHunspellDll, 'ptr:cdecl', 'HunspellInit', 'wstr', $sAff_file, 'wstr', $sDict_file, $tpKey, $sKey) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellSpell ; Description ...: Checks the spelling of the given word ; Syntax.........: _Spell_HunspellSpell($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the Word to check ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellSuggest ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HunspellSpell($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "int:cdecl", "HunspellSpell", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellStem ; Description ...: stemmer function ; Syntax.........: _Spell_HunspellStem($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - the word to stem ; Return values .: Success - array with result ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _Spell_HunspellStem($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HunspellStem", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2, 0, 0) Local $aTemp = __Spell_HunspellReadStringArray($aResult[0]) If @error Then Return SetError(3, 0, 0) Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HunspellSuggest ; Description ...: Suggests alternatives for a misspelled word ; Syntax.........: _Spell_HunspellSuggest($hHunspell, $sWord) ; Parameters ....: $hHunspell - Hunspell handle returned from _Spell_HunspellInit ; $sWord - The word you want alternatives for ; Return values .: Success - Array with suggestions (0 based) ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _Spell_HunspellSpell ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HunspellSuggest($hHunspell, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HunspellSuggest", "ptr", $hHunspell, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2, 0, 0) Local $aTemp = __Spell_HunspellReadStringArray($aResult[0]) If @error Then Return SetError(3, 0, 0) Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HyphenFree ; Description ...: Frees memory associated with a Hyphen-handle ; Syntax.........: _Spell_HyphenFree($hHyphen) ; Parameters ....: $hHyphen - Hyphen-handle returned from _Spell_HyphenInit ; Return values .: Failure - Sets @error = 1 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HyphenFree($hHyphen) DllCall($hHunspellDll, "none:cdecl", "HyphenFree", "ptr", $hHyphen) If @error Then Return SetError(1) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HyphenHyphenate ; Description ...: Analyze a word for possible hyphenation ; Syntax.........: _Spell_HyphenHyphenate($hHyphen, $sWord) ; Parameters ....: $hHyphen - Hyphen-handle returned from _Spell_HyphenInit ; $sWord - Word to be analyzed ; Return values .: Success - Array with hyphenation result ; |$array[0] contains the siblings separated with = ; |$array[$i] is 0 if you can"t split the word after letter $i ; |$array[$i] is 1 if it is possible to split the word after letter $i ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HyphenHyphenate($hHyphen, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HyphenHyphenate", "ptr", $hHyphen, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) If $aResult[0] = 0 Then Return SetError(2, 0, 0) Local $stHyphen = DllStructCreate("ptr;ptr;",$aResult[0]) Local $sTemp = __Spell_PtrStringReadW(DllStructGetData($stHyphen,1)) Local $iMax = StringLen($sWord), $iIndex Local $aTemp[$iMax+1] = [$sTemp] $stHyphen = DllStructCreate("byte[" & $iMax & "]",DllStructGetData($stHyphen,2)) If @error Then Return SetError(3, 0, 0) For $iIndex = 1 To $iMax $aTemp[$iIndex] = Mod(DllStructGetData($stHyphen,1,$iIndex),2) Next Return $aTemp EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_HyphenInit ; Description ...: Initializes a Hyphen-handle ; Syntax.........: _Spell_HyphenInit($sDict_file) ; Parameters ....: $sDict_file - Dictionary for hyphenation ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_HyphenInit($sDict_file) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "HyphenInit", "wstr", $sDict_file) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_MyThesFree ; Description ...: Frees memory associated with a MyThes handle ; Syntax.........: _Spell_MyThesFree($hMyThes) ; Parameters ....: $hMyThes - MyThes-handle returned from _Spell_MyThesInit ; Return values .: Failure - Sets @error = 1 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_MyThesFree($hMyThes) DllCall($hHunspellDll, "none:cdecl", "MyThesFree", "ptr", $hMyThes) If @error Then Return SetError(1) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_MyThesInit ; Description ...: Initializes a Thesaurus ; Syntax.........: _Spell_MyThesInit($sIdx_file, $sDat_file) ; Parameters ....: $sIdx_file - MyThes .idx-file ; $sDat_file - MyThes .dat-file ; Return values .: Success - 1 ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_MyThesInit($sIdx_file, $sDat_file) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "MyThesInit", "wstr", $sIdx_file, "wstr", $sDat_file) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_MyThesLookup ; Description ...: Looks up the meanings and synonyms of a word ; Syntax.........: _Spell_MyThesLookup($hMyThes, $sWord) ; Parameters ....: $hMyThes - MyThes-handle returned from _Spell_MyThesInit ; $sWord - The word o analyze ; Return values .: Success - Array of Arrays: ; |$array[$i] - the entries for one meaning of the word ; |--> $subarray[0] - the description of the meaning ; |--> $subarray[$j] - synonyms for this meaning ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_MyThesLookup($hMyThes, $sWord) Local $aResult = DllCall($hHunspellDll, "ptr:cdecl", "MyThesLookup", "ptr", $hMyThes, "wstr", $sWord) If @error Then Return SetError(1, 0, 0) $aResult = __Spell_MyThesReadMarshalBuffer($aResult[0]) If @error Then Return SetError(2, 0, 0) Return $aResult EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Spell_Startup ; Description ...: Loads the DLL containing Hunspell, Hyphen and Thesaurus (selects 32 or 64 bit automatically) ; Syntax.........: _Spell_Startup(directory path where dll can be found) ; Parameters ....: $sDLL - Hunspell.dll for 32 bit ; $sDLLx64 - Hunspell.dll for 64 bit ; Return values .: Success - 1 ; Failure - 0 and sets @error = 1 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: No Unload function included, AutoIt does it automatically on termination ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _Spell_Startup($sDir) If $hHunspellDll <> -1 Then Return 1 Local $sDLL = $sDir & "\Hunspell_x86.dll" If @AutoItX64 Then $sDLL = $sDir & "\Hunspell_x64.dll" $hHunspellDll = DllOpen($sDLL) If $hHunspellDll = -1 Then Return SetError(1, 0, 0) Return 1 EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: __Spell_HunspellReadStringArray ; Description ...: Reads a zero-terminated array of pointers to wstrings (zero-terminated) ; Syntax.........: __Spell_HunspellReadStringArray($ptr) ; Parameters ....: $ptr - Pointer to array ; Return values .: Success - Array with read strings ; Failure - 0 ; Author ........: Prog@ndy, iCode ; Modified.......: 13-Jun-2014 ; Remarks .......: This function is used internally by _Spell_HunspellSuggest, _Spell_HunspellAnalyze, _Spell_HunspellStem, and _Spell_HunspellGenerate ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func __Spell_HunspellReadStringArray($ptr) If $ptr = 0 Then Return SetError(1, 0, 0) Local $stPtr = DllStructCreate("ptr", $ptr) Local $asStrings[50], $iIndex = 0, $iMax = 49 While 1 $asStrings[$iIndex] = __Spell_PtrStringReadW(DllStructGetData($stPtr,1)) If @error = 1 Then ExitLoop $iIndex += 1 If $iIndex > $iMax Then $iMax += 50 ReDim $asStrings[$iMax+1] EndIf $stPtr = DllStructCreate("ptr", $ptr + DllStructGetSize($stPtr)*$iIndex) WEnd If $iIndex = 0 Then Return SetError(2, 0, 0) ReDim $asStrings[$iIndex] Return $asStrings EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: __Spell_PtrStringReadW ; Description ...: Reads a zero-terminated wstrings from a pointer ; Syntax.........: __Spell_HunspellReadStringArray($ptr) ; Parameters ....: $ptr - Pointer to wstring ; Return values .: Success - read string ; Failure - empty string ("") ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: This function is used internally by __Spell_HunspellReadStringArray, and __Spell_MyThesReadMeaningBuffer ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func __Spell_PtrStringReadW($ptr) If $ptr = 0 Then Return SetError(1, 0 ,"") Local $aLen = DllCall("kernel32.dll", "int", "lstrlenW", "ptr", $ptr) If @error Or $aLen[0]=0 Then Return SetError(2, 0, "") Local $struct = DllStructCreate("wchar[" & ($aLen[0] + 1) & "]", $ptr) Return DllStructGetData($struct, 1) EndFunc ;==>__Spell_PtrStringReadW ; #INTERNAL_USE_ONLY# ==================================================================================================================== ; Name ..........: __Spell_Shutdown ; Description ...: close hunspell DLL ; Syntax ........: __Spell_Shutdown() ; Parameters ....: ; Return values .: None ; Author ........: iCode ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __Spell_Shutdown() If $hHunspellDll <> -1 Then DllClose($hHunspellDll) EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: __Spell_MyThesReadMarshalBuffer ; Description ...: Reads the Marhal-Buffer for _Spell_MyThesLookup ; Syntax.........: __Spell_MyThesReadMarshalBuffer($pBuffer) ; Parameters ....: $pBuffer - Pointer to Marshal buffer ; Return values .: Success - Array of Arrays ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: This function is used internally by _Spell_MyThesLookup ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func __Spell_MyThesReadMarshalBuffer($pBuffer) Local $stPtr = DllStructCreate("int_ptr", $pBuffer) If @error Then Return SetError(1, 0, 0) Local $iCount = DllStructGetData($stPtr, 1) $stPtr = DllStructCreate("int_ptr;ptr[" & $iCount & "]", $pBuffer) Local $aMeanings[$iCount], $i For $i = 1 To $iCount $aMeanings[$i-1] = __Spell_MyThesReadMeaningBuffer(DllStructGetData($stPtr, 2, $i)) Next Return $aMeanings EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: __Spell_MyThesReadMeaningBuffer ; Description ...: Helper to read the Marhal-Buffer for _Spell_MyThesLookup ; Syntax.........: __Spell_MyThesReadMeaningBuffer($pBuffer) ; Parameters ....: $pBuffer - Pointer to meaning-section in Marshal buffer ; Return values .: Success - Array of Strings ; Failure - 0 ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: This function is used internally by __Spell_MyThesReadMarshalBuffer ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================== Func __Spell_MyThesReadMeaningBuffer($pBuffer) Local $stPtr = DllStructCreate("int_ptr", $pBuffer) Local $iCount = DllStructGetData($stPtr,1) $stPtr = DllStructCreate("int_ptr;ptr;ptr[" & $iCount & "]", $pBuffer) Local $aSynonyms[$iCount+1], $i $aSynonyms[0] = __Spell_PtrStringReadW(DllStructGetData($stPtr, 2)) For $i = 1 To $iCount $aSynonyms[$i] = __Spell_PtrStringReadW(DllStructGetData($stPtr, 3, $i)) Next Return $aSynonyms EndFunc  hunspell-0.9.2-ProgAndy.zipHunspell_iCode_13_JUN_2014.zip mLipok and Luigi 2 FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences) CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)
jake72469 Posted September 23, 2014 Posted September 23, 2014 (edited) Looks very interesting.  I noticed that this library is using v0.9.2 of NHunspell's version of Hunspell.  It's good because  1) it is Unicode,  2) there is a 32-bit and 64-bit version, and  3) it can be run independently, i.e. the software does not depend on other software (other than the OS) to run.  I did a little digging and discovered that v0.9.2 is fairly old version of the NHunspell dll.  It was released in 2009.  I checked and the latest version of NHunspell, v1.2.5359.26126, was released in March, 2014.  The version prior, v1.1.1.0, was released in May, 2013.  The problem with the latest versions of NHunspell is that they have been integrated into the .NET environment. This is where the discussion goes over my head a bit.  They require the installation of additional software (the NuGet package I believe) in order to get it to work.  In addition, simple DLL calls are out because calls to the NHunspell wrapper modules are necessary to get it to work.  While I am not opposed to using objects to get the job done, requiring the installation of a bunch of 3rd-party software just to get the tiny spell module to work is a problem, at least to me.  So... somewhere between v0.9.2 and v1.1.1.0, NHunspell went over to the .NET side.  What I'm wondering is... is v0.9.2 the last BN (before .NET) version or is there a more recent version?  I've heard rumors of a 0.9.6 version but I have not been able to find it.  In fact, I haven't been able to find any of the older versions of the NHunspell dlls except for v0.9.2 and the only place I found it was as an attachment to the OP of this thread.  What would be even better that finding the latest "old" version of the NHunspell dll files would be to find the latest version of the native Hunspell API that has been compiled for Windows Unicode, and is available for x86 and x64.  The Hunspell project is really good about publishing the source code for their stuff but I recently discovered that finding a good/reliable source for compiled binaries is not easy.  In fact, it's next to impossible.  A couple of years back, PrincieD on the PureBasic forum posted some binaries of a fairly recent version (v1.3.2) of the Hunspell API for windows for 32-bit and 64-bit.  You can find the post here.  I'm not sure if I feel comfortable using these out-of-the-blue binaries but they might be worth checking in to, just to see if they work.  No, I haven't tested them myself... yet.  OK, let me bottom-line it.  Does anyone know where to find old versions of NHunspell dlls?  I think there is a v0.9.6 out there but I haven't been able to find it.  Better yet, does anyone know where to find recent versions of the Hunspell API for Windows dlls (32-bit and 64-bit) that come from a more reliable source than a 2 year-old post on a PureBasic forum?  I have to believe that they are out there.  I just haven't found them yet.  Thank you for your consideration. Edited September 23, 2014 by jake72469
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now