gnu-Aspell in windows example

Windows specific questions.
Site Admin
Posts: 3308
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada

gnu-Aspell in windows example

Postby coderJeff » Jan 14, 2007 2:00

Aspell example using precompiled binaries and dictionaries for windows from The .def/.lib/.h files are in a development download at the bottom of the (aspell) page.

I never yet converted a header or added .def's to CVS. Any advice would be welcome.

I could not properly unpack or run the fbswig.exe v1c posted in the /tmp dir a while back. So I only converted a portion of the header by hand. I can email the full C header, or give more detail on which package to get it from if someone wants to help convert the whole thing.

I am going to (try anyway) use this package to spell check the wiki documenation.


Code: Select all

'' - minimal conversion only, by hand.  Just to test that this works.


#inclib "aspell-15"

extern "C"

type AspellConfig as AspellConfig_

type AspellErrorInfo
  isa as AspellErrorInfo ptr
  mesg as zstring ptr
  num_parms as uinteger
  parms(2) as zstring ptr
end type

type AspellError
  mesg as zstring ptr
  err as AspellErrorInfo ptr
end type

type AspellCanHaveError as AspellCanHaveError_

type AspellSpeller as AspellSpeller_

type AspellWordList as AspellWordList_

type AspellFilter as AspellFilter_

type AspellStringEnumeration as AspellStringEnumeration_

declare function new_aspell_config() as AspellConfig ptr
declare sub      delete_aspell_config( byval ths as AspellConfig ptr )
declare function aspell_config_replace(byval ths as AspellConfig ptr, byval key as zstring ptr, byval value as zstring ptr ) as integer
declare function aspell_error_number(byval ths as AspellCanHaveError ptr) as uinteger
declare function aspell_error_message(byval  ths as AspellCanHaveError ptr) as zstring ptr
declare function aspell_error(byval ths as AspellCanHaveError ptr) as AspellError ptr
declare sub      delete_aspell_can_have_error(byval ths as AspellCanHaveError ptr)
declare function new_aspell_speller(byval config as AspellConfig ptr) as AspellCanHaveError ptr
declare function to_aspell_speller(byval obj as AspellCanHaveError ptr) as AspellSpeller ptr
declare sub      delete_aspell_speller(byval ths as AspellSpeller ptr)
declare function aspell_speller_check(byval ths as AspellSpeller ptr, byval word as zstring ptr, byval word_size as integer) as integer
declare function aspell_speller_suggest(byval ths as AspellSpeller ptr, byval word as zstring ptr, byval word_size as integer) as AspellWordList ptr
declare function aspell_word_list_elements(byval ths as AspellWordList ptr) as AspellStringEnumeration ptr
declare sub      delete_aspell_string_enumeration(byval ths as AspellStringEnumeration ptr)
declare function aspell_string_enumeration_next(byval ths as AspellStringEnumeration ptr) as zstring ptr

end extern


'' Test code

Code: Select all

'' aspell_test.bas

#include ""

public sub aspell_test()

   dim as AspellConfig ptr spell_config = new_aspell_config()

   aspell_config_replace(spell_config, "lang", "en_CA")

   dim as AspellSpeller ptr spell_checker = 0

   dim as AspellCanHaveError ptr possible_err = new_aspell_speller(spell_config)

   if (aspell_error_number(possible_err) <> 0) then
      print aspell_error_message(possible_err)
      end 1
      spell_checker = to_aspell_speller(possible_err)
   end if

   ' *** Not sure about this block
   'dim as AspellConfig ptr spell_config2 = aspell_config_clone(spell_config)
   'aspell_config_replace(spell_config2, "lang","nl")
   'possible_err = new_aspell_speller(spell_config2)

   dim as integer correct
   dim as AspellWordList ptr suggestions
   dim as AspellStringEnumeration ptr elements
   dim as zstring ptr word
   dim as string input_word

      input "Enter a word: ", input_word

      if( len(input_word) = 0 ) then
         exit do
      end if

      correct = aspell_speller_check(spell_checker, strptr(input_word), len(input_word))

      if( correct <> 0 ) then
         print "Correct"
         print "Suggestions:"
         suggestions = aspell_speller_suggest(spell_checker, strptr(input_word), len(input_word))
         elements = aspell_word_list_elements(suggestions)
            word = aspell_string_enumeration_next(elements)
            if word = 0 then
               exit do
            end if
            print "   "; *word
      end if

      ' - Report the replacement
      'aspell_speller_store_repl(spell_checker, misspelled_word, size,
      '                          correctly_spelled_word, size);
      ' - Add to session or personal dictionary
      'aspell_speller_add_to_session|personal(spell_checker, word, size)



end sub

#ifdef __FB_MAIN__

Sample output:
Enter a word: workng
Posts: 60
Joined: Feb 21, 2019 19:24
Location: Israel

Re: gnu-Aspell in windows example

Postby ron77 » Oct 16, 2020 9:39

hello coderJeff...

i tried your example i downloaded aspell and aspell dictionary and installed then yet when i tried your code examples i got an error saying "aspell 15.dll" was not found so i copy paste aspell 15.dll from the aspell program files in bin folder and pasted it in the folder of the files with your code (the bi file and the bas file) and then what the code compiles fine but doesn't do anything :-/ no window no console no nothing... why?

Posts: 60
Joined: Feb 21, 2019 19:24
Location: Israel

Re: gnu-Aspell in windows example

Postby ron77 » Oct 17, 2020 5:38

this thread has the answer i think.


Return to “Windows”

Who is online

Users browsing this forum: No registered users and 1 guest