Giter VIP home page Giter VIP logo

pyenchant's Introduction

pyenchant: Python bindings for the Enchant spellchecker

image

image

image

image

image

This package provides a set of Python language bindings for the Enchant spellchecking library. For more information, visit the project website:

http://pyenchant.github.io/pyenchant/

What is Enchant?

Enchant is used to check the spelling of words and suggest corrections for words that are miss-spelled. It can use many popular spellchecking packages to perform this task, including ispell, aspell and MySpell. It is quite flexible at handling multiple dictionaries and multiple languages.

More information is available on the Enchant website:

https://abiword.github.io/enchant/

How do I use PyEnchant ?

Warning: in general, PyEnchant will not work out of the box after having been installed with pip (or any other installation method) -see the documentation for more details.

Who is responsible for all this?

The credit for Enchant itself goes to Dom Lachowicz. Find out more details on the Enchant website listed above. Full marks to Dom for producing such a high-quality library.

The glue to pull Enchant into Python via ctypes was written by Ryan Kelly. He needed a decent spellchecker for another project he was working on, and all the solutions turned up by Google were either extremely non-portable (e.g. opening a pipe to ispell) or had completely disappeared from the web (what happened to SnakeSpell?) It was also a great excuse to teach himself about SWIG, ctypes, and even a little bit of the Python/C API.

Finally, after Ryan stepped down from the project, Dimitri Merejkowsky became the new maintainer.

pyenchant's People

Contributors

0mp avatar arkershaw avatar bgermann avatar dhellmann avatar dkaman avatar dmerejkowsky avatar etingof avatar fabianhauser avatar felipeacsi avatar freakboy3742 avatar halfak avatar jdufresne avatar jelly avatar jwilk avatar mattbennett avatar mlk97 avatar mtelka avatar ngulden avatar pmhahn avatar raphaelm avatar rfk avatar saschpe avatar sbraz avatar simonmaignan avatar spagh-eddie avatar tbroadley avatar timgates42 avatar timkam avatar typhon0 avatar undo76 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyenchant's Issues

tests FAIL: Test whether all advertised providers are in fact available.

Hi. I'm unsure if this is a bug or misconfiguration, but running tests ends with the following errors:

/usr/lib/python2.6/site-packages/Pyrex/Compiler/Errors.py:17: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
self.message = message
running test
running egg_info
writing pyenchant.egg-info/PKG-INFO
writing eager_resources to pyenchant.egg-info/eager_resources.txt
writing top-level names to pyenchant.egg-info/top_level.txt
writing dependency_links to pyenchant.egg-info/dependency_links.txt
reading manifest file 'pyenchant.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tools/pyenchant-bdist-win32-sources'
writing manifest file 'pyenchant.egg-info/SOURCES.txt'
running build_ext
Test installation in a path containing unicode chars. ...
NOT SKIPPED <module 'enchant' from '/var/tmp/portage/dev-python/pyenchant-1.5.3/temp/tmpoDgf9n/test_åäö_ing/enchant/init.py'> ['fr']

NOT SKIPPED ['fr']

NOT SKIPPED <function request_dict at 0x94773ac> ['fr']

NOT SKIPPED <bound method Broker.request_dict of <enchant.Broker object at 0x947e96c>> ['fr']

NOT SKIPPED <bound method Broker.request_dict of <enchant.Broker object at 0x947e96c>> ['fr']

FAIL: Test whether all advertised languages are in fact available.

Traceback (most recent call last):
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/temp/tmpoDgf9n/test_åäö_ing/enchant/init.py", line 823, in test_LangsAreAvail
self.assert_(self.broker.dict_exists(lang))
AssertionError

FAIL: Test whether all advertised providers are in fact available.

Traceback (most recent call last):
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/temp/tmpoDgf9n/test_åäö_ing/enchant/init.py", line 828, in test_ProvsAreAvail
self.assert_(self.broker.dict_exists(lang))
AssertionError


Ran 44 tests in 27.054s

FAILED (failures=2)
FAIL
Test proper functioning of TestInstallEnv suite. ...
NOT SKIPPED <module 'enchant' from '/var/tmp/portage/dev-python/pyenchant-1.5.3/temp/tmpNXJdC9/build/enchant/init.py'> ['fr']

NOT SKIPPED ['fr']

NOT SKIPPED <function request_dict at 0x850c3ac> ['fr']

NOT SKIPPED <bound method Broker.request_dict of <enchant.Broker object at 0x851396c>> ['fr']

NOT SKIPPED <bound method Broker.request_dict of <enchant.Broker object at 0x851396c>> ['fr']

FAIL: Test whether all advertised languages are in fact available.

Traceback (most recent call last):
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/temp/tmpNXJdC9/build/enchant/init.py", line 823, in test_LangsAreAvail
self.assert_(self.broker.dict_exists(lang))
AssertionError

FAIL: Test whether all advertised providers are in fact available.

Traceback (most recent call last):
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/temp/tmpNXJdC9/build/enchant/init.py", line 828, in test_ProvsAreAvail
self.assert_(self.broker.dict_exists(lang))
AssertionError


Ran 44 tests in 25.275s

FAILED (failures=2)
FAIL
Test pyenchant running inside a py2exe executable. ... ok
Test that the en_US language is available. ... ok
Test whether all advertised languages are in fact available. ... FAIL
Test that provider ordering works correctly. ... ok
Test whether all advertised providers are in fact available. ... FAIL
Test that unicode language tags are accepted ... ok
Test adding/removing from default user dictionary. ... ok
Test behaviour of default language selection. ... ok
Test that the en_US language is available through default broker. ... ok
Test that the dict's broker is set correctly. ... ok
Test that check() works on some common words. ... ok
Test that adding words to the session works as required. ... ok
Test that suggest() gets simple suggestions right. ... ok
Test whether suggest() hangs on some inputs (Bug #1404196) ... ok
Test that the dict's tag is set correctly. ... ok
Test checking/suggesting for unicode strings ... ok
Test functionality of DictWithPWL using exclude list. ... ok
Test functionality of DictWithPWL. ... ok
Test functionality of DictWithPWL using transient dicts. ... ok
Test our pure-python PWL implementation. ... ok
Test that unicode chars in PWL paths are accepted. ... ok
Test that unicode PWL filenames are accepted. ... ok
Test that adding words to a PWL works correctly. ... ok
Test that basic checking works for PWLs. ... ok
Test getting suggestions from a PWL. ... ok
Test that all our docstrings are error-free. ...
NOT SKIPPED <module 'enchant' from '/var/tmp/portage/dev-python/pyenchant-1.5.3/work/pyenchant-1.5.3/enchant/init.py'> ['fr']

NOT SKIPPED ['fr']

NOT SKIPPED <function request_dict at 0x8d238ec> ['fr']

NOT SKIPPED <bound method Broker.request_dict of <enchant.Broker object at 0x8d2550c>> ['fr']

NOT SKIPPED <bound method Broker.request_dict of <enchant.Broker object at 0x8d2550c>> ['fr']
ok
Test a basic run of the SpellChecker class. ... ok
Testcases for bug #2785373. ... ok
Test SpellChecker with a character array as input. ... ok
Test SpellChecker with the 'filters' argument. ... ok
Test checker loop with PWL. ... ok
Test SpellChecker with a unicode string. ... ok
Simple regression test for basic white-space tokenization. ... ok
Test special-char-stripping edge-cases in basic_tokenize. ... ok
Test wrapping of one tokenizer with another. ... ok
Check for tokenization regressions identified in bug #1591450. ... ok
Testcases for bug #2785373 ... ok
Simple regression test for English tokenization. ... ok
Test tokenization of a basic unicode string. ... ok
Test tokenization with unicode combining symbols. ... ok
Test tokenization of UTF8-encoded bytes (bug #2500184). ... ok
Test several filters combined ... ok
Test filtering of email addresses ... ok
Test filtering of URLs ... ok
Test filtering of WikiWords ... ok

FAIL: Test installation in a path containing unicode chars.

Traceback (most recent call last):
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/work/pyenchant-1.5.3/enchant/init.py", line 1264, in test_UnicodeInstallPath
self.runtests()
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/work/pyenchant-1.5.3/enchant/init.py", line 1252, in runtests
self.assertEquals(res,0)
AssertionError: 256 != 0

FAIL: Test proper functioning of TestInstallEnv suite.

Traceback (most recent call last):
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/work/pyenchant-1.5.3/enchant/init.py", line 1257, in test_basic
self.runtests()
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/work/pyenchant-1.5.3/enchant/init.py", line 1252, in runtests
self.assertEquals(res,0)
AssertionError: 256 != 0

FAIL: Test whether all advertised languages are in fact available.

Traceback (most recent call last):
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/work/pyenchant-1.5.3/enchant/init.py", line 823, in test_LangsAreAvail
self.assert_(self.broker.dict_exists(lang))
AssertionError

FAIL: Test whether all advertised providers are in fact available.

Traceback (most recent call last):
File "/var/tmp/portage/dev-python/pyenchant-1.5.3/work/pyenchant-1.5.3/enchant/init.py", line 828, in test_ProvsAreAvail
self.assert_(self.broker.dict_exists(lang))
AssertionError


Ran 47 tests in 80.717s

FAILED (failures=4)

That's not something new, since similar issue was reported at our bugzilla for pyenchant-1.1.5. Could you help us to resolve this issue? Thank you for your time.

Build fails while trying to make an exe-file with cx_Freeze

I've been trying to include pyenchant with my program, and I can't get it to work with cx_freeze. If I build an exe with pyenchant, the program won't start. The error is:


cx_Freeze: Python error in main script

Traceback (most recent call last):
File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27, in
exec(code, m.dict)
File "C:\Scripts\Spellcheck\spellcheck.py", line 14, in
from spellcheck import spellcheck # A class for spellchecking
File "C:\Python\32-bit\3.3\lib\importlib_bootstrap.py", line 1558, in _find_and_load
File "C:\Python\32-bit\3.3\lib\importlib_bootstrap.py", line 1525, in _find_and_load_unlocked
File "C:\Scripts\Spellcheck\spellcheck.py", line 5, in
import enchant # Python bindings for the Enchant spellchecking system
File "C:\Python\32-bit\3.3\lib\importlib_bootstrap.py", line 1558, in find_and_load
File "C:\Python\32-bit\3.3\lib\importlib_bootstrap.py", line 1525, in find_and_load_unlocked
File "C:\Python33\lib\site-packages\enchant__init
.py", line 90, in
from enchant import _enchant as _e
File "C:\Python\32-bit\3.3\lib\importlib_bootstrap.py", line 1607, in _handle_fromlist
File "C:\Python\32-bit\3.3\lib\importlib_bootstrap.py", line 313, in _call_with_frames_removed
File "C:\Python\32-bit\3.3\lib\importlib_bootstrap.py", line 1558, in _find_and_load
File "C:\Python\32-bit\3.3\lib\importlib_bootstrap.py", line 1525, in _find_and_load_unlocked
File "C:\Python33\lib\site-packages\enchant_enchant.py", line 80, in
e_path = utils.get_resource_filename("libenchant.dll")
File "C:\Python33\lib\site-packages\enchant\utils.py", line 244, in get_resource_filename
exe_path = unicode(sys.executable,sys.getfilesystemencoding())
TypeError: decoding str is not supported

Test failures

5 failures occur with all versions of Python.
3 errors occur only with Python 3.3.
(Test results from git head.)

$ PYTHONPATH="build/lib" python3.3 setup.py test
running test
running egg_info
writing pyenchant.egg-info/PKG-INFO
writing dependency_links to pyenchant.egg-info/dependency_links.txt
writing eager_resources to pyenchant.egg-info/eager_resources.txt
writing top-level names to pyenchant.egg-info/top_level.txt
reading manifest file 'pyenchant.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*' under directory 'docs/'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'tools/pyenchant-bdist-win32-sources'
no previously-included directories found matching 'tools/pyenchant-bdist-osx-sources'
writing manifest file 'pyenchant.egg-info/SOURCES.txt'
running build_ext
test_UnicodeInstallPath (enchant.tests.TestInstallEnv)
Test installation in a path containing unicode chars. ... Traceback (most recent call last):
  File "/tmp/tmp5g3508/test_åäö_ing/enchant/__init__.py", line 894, in <module>
    res = enchant.tests.runtestsuite()
  File "/tmp/tmp5g3508/test_åäö_ing/enchant/tests.py", line 613, in runtestsuite
    return unittest.TextTestRunner(verbosity=0).run(buildtestsuite(recurse=recurse))
  File "/usr/lib64/python3.3/unittest/runner.py", line 168, in run
    test(result)
  File "/usr/lib64/python3.3/unittest/suite.py", line 67, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python3.3/unittest/suite.py", line 105, in run
    test(result)
  File "/usr/lib64/python3.3/unittest/suite.py", line 67, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python3.3/unittest/suite.py", line 105, in run
    test(result)
  File "/usr/lib64/python3.3/unittest/case.py", line 492, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python3.3/unittest/case.py", line 452, in run
    result.addFailure(self, exc_info)
  File "/usr/lib64/python3.3/unittest/runner.py", line 75, in addFailure
    super(TextTestResult, self).addFailure(test, err)
  File "/usr/lib64/python3.3/unittest/result.py", line 17, in inner
    return method(self, *args, **kw)
  File "/usr/lib64/python3.3/unittest/result.py", line 121, in addFailure
    self.failures.append((test, self._exc_info_to_string(err, test)))
  File "/usr/lib64/python3.3/unittest/result.py", line 160, in _exc_info_to_string
    msgLines = traceback.format_exception(exctype, value, tb, length)
  File "/usr/lib64/python3.3/traceback.py", line 187, in format_exception
    list.extend(format_tb(tb, limit))
  File "/usr/lib64/python3.3/traceback.py", line 75, in format_tb
    return format_list(extract_tb(tb, limit))
  File "/usr/lib64/python3.3/traceback.py", line 100, in extract_tb
    line = linecache.getline(filename, lineno, f.f_globals)
  File "/usr/lib64/python3.3/linecache.py", line 15, in getline
    lines = getlines(filename, module_globals)
  File "/usr/lib64/python3.3/linecache.py", line 41, in getlines
    return updatecache(filename, module_globals)
  File "/usr/lib64/python3.3/linecache.py", line 126, in updatecache
    with tokenize.open(fullname) as fp:
AttributeError: 'module' object has no attribute 'open'
FAIL
test_basic (enchant.tests.TestInstallEnv)
Test proper functioning of TestInstallEnv suite. ... Traceback (most recent call last):
  File "/tmp/tmpu9b95v/build/enchant/__init__.py", line 894, in <module>
    res = enchant.tests.runtestsuite()
  File "/tmp/tmpu9b95v/build/enchant/tests.py", line 613, in runtestsuite
    return unittest.TextTestRunner(verbosity=0).run(buildtestsuite(recurse=recurse))
  File "/usr/lib64/python3.3/unittest/runner.py", line 168, in run
    test(result)
  File "/usr/lib64/python3.3/unittest/suite.py", line 67, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python3.3/unittest/suite.py", line 105, in run
    test(result)
  File "/usr/lib64/python3.3/unittest/suite.py", line 67, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python3.3/unittest/suite.py", line 105, in run
    test(result)
  File "/usr/lib64/python3.3/unittest/case.py", line 492, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python3.3/unittest/case.py", line 452, in run
    result.addFailure(self, exc_info)
  File "/usr/lib64/python3.3/unittest/runner.py", line 75, in addFailure
    super(TextTestResult, self).addFailure(test, err)
  File "/usr/lib64/python3.3/unittest/result.py", line 17, in inner
    return method(self, *args, **kw)
  File "/usr/lib64/python3.3/unittest/result.py", line 121, in addFailure
    self.failures.append((test, self._exc_info_to_string(err, test)))
  File "/usr/lib64/python3.3/unittest/result.py", line 160, in _exc_info_to_string
    msgLines = traceback.format_exception(exctype, value, tb, length)
  File "/usr/lib64/python3.3/traceback.py", line 187, in format_exception
    list.extend(format_tb(tb, limit))
  File "/usr/lib64/python3.3/traceback.py", line 75, in format_tb
    return format_list(extract_tb(tb, limit))
  File "/usr/lib64/python3.3/traceback.py", line 100, in extract_tb
    line = linecache.getline(filename, lineno, f.f_globals)
  File "/usr/lib64/python3.3/linecache.py", line 15, in getline
    lines = getlines(filename, module_globals)
  File "/usr/lib64/python3.3/linecache.py", line 41, in getlines
    return updatecache(filename, module_globals)
  File "/usr/lib64/python3.3/linecache.py", line 126, in updatecache
    with tokenize.open(fullname) as fp:
AttributeError: 'module' object has no attribute 'open'
FAIL
test_py2exe (enchant.tests.TestPy2exe)
Test pyenchant running inside a py2exe executable. ... ok
test_GetSetParam (enchant.tests.TestBroker) ... ok
test_HasENUS (enchant.tests.TestBroker)
Test that the en_US language is available. ... ok
test_LangsAreAvail (enchant.tests.TestBroker)
Test whether all advertised languages are in fact available. ... FAIL
test_ProvOrdering (enchant.tests.TestBroker)
Test that provider ordering works correctly. ... warning: line 274: incompatible stripping characters and condition
warning: line 275: incompatible stripping characters and condition
warning: line 599: incompatible stripping characters and condition
warning: line 901: incompatible stripping characters and condition
warning: line 1309: incompatible stripping characters and condition
warning: line 1310: incompatible stripping characters and condition
warning: line 1311: incompatible stripping characters and condition
warning: line 1759: incompatible stripping characters and condition
warning: line 1760: incompatible stripping characters and condition
warning: line 1761: incompatible stripping characters and condition
warning: line 2119: incompatible stripping characters and condition
warning: line 274: incompatible stripping characters and condition
warning: line 275: incompatible stripping characters and condition
warning: line 599: incompatible stripping characters and condition
warning: line 901: incompatible stripping characters and condition
warning: line 1309: incompatible stripping characters and condition
warning: line 1310: incompatible stripping characters and condition
warning: line 1311: incompatible stripping characters and condition
warning: line 1759: incompatible stripping characters and condition
warning: line 1760: incompatible stripping characters and condition
warning: line 1761: incompatible stripping characters and condition
warning: line 2119: incompatible stripping characters and condition
warning: line 274: incompatible stripping characters and condition
warning: line 275: incompatible stripping characters and condition
warning: line 599: incompatible stripping characters and condition
warning: line 901: incompatible stripping characters and condition
warning: line 1309: incompatible stripping characters and condition
warning: line 1310: incompatible stripping characters and condition
warning: line 1311: incompatible stripping characters and condition
warning: line 1759: incompatible stripping characters and condition
warning: line 1760: incompatible stripping characters and condition
warning: line 1761: incompatible stripping characters and condition
warning: line 2119: incompatible stripping characters and condition
ok
test_ProvsAreAvail (enchant.tests.TestBroker)
Test whether all advertised providers are in fact available. ... FAIL
test_UnicodeTag (enchant.tests.TestBroker)
Test that unicode language tags are accepted ... ok
test_AddRemove (enchant.tests.TestDict)
Test adding/removing from default user dictionary. ... ok
test_DefaultLang (enchant.tests.TestDict)
Test behaviour of default language selection. ... ok
test_HasENUS (enchant.tests.TestDict)
Test that the en_US language is available through default broker. ... ok
test_broker (enchant.tests.TestDict)
Test that the dict's broker is set correctly. ... ok
test_check (enchant.tests.TestDict)
Test that check() works on some common words. ... ok
test_pickling (enchant.tests.TestDict)
Test that pickling doensn't corrupt internal state. ... ok
test_session (enchant.tests.TestDict)
Test that adding words to the session works as required. ... ok
test_suggest (enchant.tests.TestDict)
Test that suggest() gets simple suggestions right. ... ok
test_suggestHang1 (enchant.tests.TestDict)
Test whether suggest() hangs on some inputs (Bug #1404196) ... ok
test_tag (enchant.tests.TestDict)
Test that the dict's tag is set correctly. ... ok
test_unicode1 (enchant.tests.TestDict)
Test checking/suggesting for unicode strings ... ok
test_DWPWL (enchant.tests.TestPWL)
Test functionality of DictWithPWL. ... ok
test_DWPWL_empty (enchant.tests.TestPWL)
Test functionality of DictWithPWL using transient dicts. ... ok
test_PyPWL (enchant.tests.TestPWL)
Test our pure-python PWL implementation. ... ok
test_UnicodeCharsInPath (enchant.tests.TestPWL)
Test that unicode chars in PWL paths are accepted. ... ok
test_UnicodeFN (enchant.tests.TestPWL)
Test that unicode PWL filenames are accepted. ... ok
test_add (enchant.tests.TestPWL)
Test that adding words to a PWL works correctly. ... ok
test_check (enchant.tests.TestPWL)
Test that basic checking works for PWLs. ... ok
test_suggestions (enchant.tests.TestPWL)
Test getting suggestions from a PWL. ... ok
test_trim_suggestions (enchant.tests.TestUtils) ... /tmp/pyenchant/enchant/tests.py:416: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(trim_suggestions(word,suggs,40),["god","good","bad+"])
ok
test_docstrings (enchant.tests.TestDocStrings)
Test that all our docstrings are error-free. ... ERROR
test_basic (enchant.checker.tests.TestChecker)
Test a basic run of the SpellChecker class. ... ok
test_bug2785373 (enchant.checker.tests.TestChecker)
Testcases for bug #2785373. ... ok
test_chararray (enchant.checker.tests.TestChecker)
Test SpellChecker with a character array as input. ... FAIL
test_chunkers (enchant.checker.tests.TestChecker)
Test SpellChecker with the 'chunkers' argument. ... ok
test_chunkers_and_filters (enchant.checker.tests.TestChecker)
Test SpellChecker with the 'chunkers' and 'filters' arguments. ... ERROR
test_default_language (enchant.checker.tests.TestChecker) ... ok
test_filters (enchant.checker.tests.TestChecker)
Test SpellChecker with the 'filters' argument. ... ERROR
test_pwl (enchant.checker.tests.TestChecker)
Test checker loop with PWL. ... ok
test_replace_with_empty_string (enchant.checker.tests.TestChecker)
Testcase for replacing with an empty string (bug #10) ... /tmp/pyenchant/enchant/checker/tests.py:246: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(chkr.get_text(),". I   .")
ok
test_replace_with_shorter_string (enchant.checker.tests.TestChecker)
Testcase for replacing with a shorter string (bug #10) ... ok
test_unicode (enchant.checker.tests.TestChecker)
Test SpellChecker with a unicode string. ... ok
test_basic_tokenize (enchant.tokenize.tests.TestTokenization)
Simple regression test for basic white-space tokenization. ... ok
test_tokenize_strip (enchant.tokenize.tests.TestTokenization)
Test special-char-stripping edge-cases in basic_tokenize. ... ok
test_wrap_tokenizer (enchant.tokenize.tests.TestTokenization)
Test wrapping of one tokenizer with another. ... ok
test_bug1591450 (enchant.tokenize.tests.TestTokenizeEN)
Check for tokenization regressions identified in bug #1591450. ... ok
test_bug2785373 (enchant.tokenize.tests.TestTokenizeEN)
Testcases for bug #2785373 ... ok
test_finnish_text (enchant.tokenize.tests.TestTokenizeEN)
Test tokenizing some Finnish text. ... ok
test_tokenize_en (enchant.tokenize.tests.TestTokenizeEN)
Simple regression test for English tokenization. ... ok
test_unicodeBasic (enchant.tokenize.tests.TestTokenizeEN)
Test tokenization of a basic unicode string. ... ok
test_unicodeCombining (enchant.tokenize.tests.TestTokenizeEN)
Test tokenization with unicode combining symbols. ... ok
test_utf8_bytes (enchant.tokenize.tests.TestTokenizeEN)
Test tokenization of UTF8-encoded bytes (bug #2500184). ... ok
test_utf8_bytes_at_end (enchant.tokenize.tests.TestTokenizeEN)
Test tokenization of UTF8-encoded bytes at end of word. ... ok
test_utf8_bytes_in_an_array (enchant.tokenize.tests.TestTokenizeEN)
Test tokenization of UTF8-encoded bytes stored in an array. ... ok
test_CombinedFilter (enchant.tokenize.tests.TestFilters)
Test several filters combined ... ok
test_EmailFilter (enchant.tokenize.tests.TestFilters)
Test filtering of email addresses ... ok
test_URLFilter (enchant.tokenize.tests.TestFilters)
Test filtering of URLs ... ok
test_WikiWordFilter (enchant.tokenize.tests.TestFilters)
Test filtering of WikiWords ... ok

======================================================================
ERROR: test_docstrings (enchant.tests.TestDocStrings)
Test that all our docstrings are error-free.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 398, in next
    (word,pos) = next(self._curtok)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 132, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 227, in next
    raise StopIteration()
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 398, in next
    (word,pos) = next(self._curtok)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 132, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 227, in next
    raise StopIteration()
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tests.py", line 469, in test_docstrings
    newobjs = list(self._check_docstrings(obj,errors))
  File "/tmp/pyenchant/enchant/tests.py", line 478, in _check_docstrings
    for err in chkr:
  File "/tmp/pyenchant/enchant/checker/__init__.py", line 230, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/checker/__init__.py", line 251, in next
    (word,pos) = next(self._tokens)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 392, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 401, in next
    (word,pos) = next(self._tokenizer)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 392, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 402, in next
    while self._skip(word):
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 445, in _skip
    if self._pattern.match(word):
TypeError: buffer size mismatch

======================================================================
ERROR: test_chunkers_and_filters (enchant.checker.tests.TestChecker)
Test SpellChecker with the 'chunkers' and 'filters' arguments.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 398, in next
    (word,pos) = next(self._curtok)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 132, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 227, in next
    raise StopIteration()
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 398, in next
    (word,pos) = next(self._curtok)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 132, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 227, in next
    raise StopIteration()
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/checker/tests.py", line 129, in test_chunkers_and_filters
    for err in chkr:
  File "/tmp/pyenchant/enchant/checker/__init__.py", line 230, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/checker/__init__.py", line 251, in next
    (word,pos) = next(self._tokens)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 392, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 401, in next
    (word,pos) = next(self._tokenizer)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 392, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 402, in next
    while self._skip(word):
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 445, in _skip
    if self._pattern.match(word):
TypeError: buffer size mismatch

======================================================================
ERROR: test_filters (enchant.checker.tests.TestChecker)
Test SpellChecker with the 'filters' argument.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 398, in next
    (word,pos) = next(self._curtok)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 132, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 227, in next
    raise StopIteration()
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 398, in next
    (word,pos) = next(self._curtok)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 132, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 227, in next
    raise StopIteration()
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/checker/tests.py", line 105, in test_filters
    for err in chkr:
  File "/tmp/pyenchant/enchant/checker/__init__.py", line 230, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/checker/__init__.py", line 251, in next
    (word,pos) = next(self._tokens)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 392, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 401, in next
    (word,pos) = next(self._tokenizer)
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 392, in __next__
    return self.next()
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 402, in next
    while self._skip(word):
  File "/tmp/pyenchant/enchant/tokenize/__init__.py", line 459, in _skip
    if self._pattern.match(word):
TypeError: buffer size mismatch

======================================================================
FAIL: test_UnicodeInstallPath (enchant.tests.TestInstallEnv)
Test installation in a path containing unicode chars.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tests.py", line 550, in test_UnicodeInstallPath
    self.runtests()
  File "/tmp/pyenchant/enchant/tests.py", line 538, in runtests
    self.assertEqual(res,0)
AssertionError: 1 != 0

======================================================================
FAIL: test_basic (enchant.tests.TestInstallEnv)
Test proper functioning of TestInstallEnv suite.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tests.py", line 543, in test_basic
    self.runtests()
  File "/tmp/pyenchant/enchant/tests.py", line 538, in runtests
    self.assertEqual(res,0)
AssertionError: 1 != 0

======================================================================
FAIL: test_LangsAreAvail (enchant.tests.TestBroker)
Test whether all advertised languages are in fact available.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tests.py", line 86, in test_LangsAreAvail
    assert False, "language '"+lang+"' advertised but non-existent"
AssertionError: language 'ru_RU_yo' advertised but non-existent

======================================================================
FAIL: test_ProvsAreAvail (enchant.tests.TestBroker)
Test whether all advertised providers are in fact available.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/tests.py", line 91, in test_ProvsAreAvail
    self.assertTrue(self.broker.dict_exists(lang))
AssertionError: False is not true

======================================================================
FAIL: test_chararray (enchant.checker.tests.TestChecker)
Test SpellChecker with a character array as input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyenchant/enchant/checker/tests.py", line 189, in test_chararray
    self.assertEqual(err.word,"aray")
AssertionError: 'stord' != 'aray'
- stord
+ aray


----------------------------------------------------------------------
Ran 57 tests in 11.653s

FAILED (failures=5, errors=3)

python3 typeError

 Copying pyenchant.egg-info to /build/pkg/python-pyenchant/usr/lib/python3.2

/site-packages/pyenchant-1.6.5-py3.2.egg-info running install_scripts
Traceback (most recent call last):
File "setup.py", line 215, in
test_suite="enchant.tests.buildtestsuite",
File "/usr/lib/python3.2/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.2/distutils/dist.py", line 917, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "build/bdist.linux-x86_64/egg/setuptools/command/install.py", line 5
3, in run File "/usr/lib/python3.2/distutils/command/install.py", line 581, in run
self.run_command(cmd_name)
File "/usr/lib/python3.2/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "build/bdist.linux-x86_64/egg/setuptools/command/install_scripts.py"
, line 37, in run File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", l
ine 1597, in get_script_args File "build/bdist.linux-x86_64/egg/setuptools/command easy_install.py", l
ine 1449, in get_script_header TypeError: can't use a bytes pattern on a string-like object

When using python setup.py build

Update and fix OSX build process

The old OSX build process no longer works due to (AFAICT) changes in Xcode and related tooling. It's also archaic in that it was still trying to build ppc versions of the libs, which are probably no longer needed.

We should update the Makefile to build 32bit/64bit intel fat binaries, including glib and its dependencies. Ideally it would target OSX 10.6 SDK, if that's even possible on the latest versions of Xcode.

Can not install pyenchant-1.6.5

Hi, I have problem with installation on Linux Ubuntu, Python 2. 5. 2.

$ sudo python2.5 setup.py install
Traceback (most recent call last):
  File "setup.py", line 195, in <module>
    import enchant
  File "/home/vojta/NLP/pyenchant-1.6.5/enchant/__init__.py", line 90, in <module>
    from enchant import _enchant as _e
  File "/home/vojta/NLP/pyenchant-1.6.5/enchant/_enchant.py", line 250, in <module>
    dict_add1 = e.enchant_dict_add
  File "/usr/lib/python2.5/ctypes/__init__.py", line 361, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python2.5/ctypes/__init__.py", line 366, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/libenchant.so.1: undefined symbol: enchant_dict_add

problems running on 64-bit unix

(moving from disqus to github issue)

Is it possible to use PyEnchant on 64 bit Unix (64 bit python) ? I have installed libenchant 1.6 c library, but each time i try to run a program it crashes with something like:
cannot include C library -> OSError: wrong ELF: ELFCLASS32

new win32 installer seems broken

Today's new version (1.6.4) installs fine on my computer (win64 / win7) but throws two "procedure not found" errors and then a "dictionary not found" error when I try to actually use it.

The dictionaries are there... I think it might be having a problem calling the enchant code.

Reinstalling the old version (1.6.3) fixed it and, consequently, I do not have the exact text of the error :(

Great package, by the way!

binary installer pyenchant-1.6.2.win32.exe bad libglib dll

after installing from the binary pyenchant-1.6.2.win32.exe
doing a
import enchant
shows a notification window with (translated from spanish):
title: python.exe - entry point not found
body: entry point for g_hash_table_get_keys not found in the dynamic library libglib-2.0-0.dll

other info: winxp sp3 32bits, python 2.6.5

Update instructions for using OpenOffice dictionaries

(transferring from private email)

I'd like to point out the following:

There is this part:

PyEnchant can use dictionaries from the OpenOffice.org project. Locate the appropriate file on their dictionary download page at http://wiki.services.openoffice.org/wiki/Dictionaries.

The download will be a zip file containing the necessary dictionary files.

But when I go tho the OpenOffice page, I get this:
Documentation caution.png IMPORTANT NOTE: For OpenOffice 3.x and 4.x dictionaries are available via the Extensions Repository.

I went there, but the dictionaries are not zip files anymore, but .oxt files.

It would be awesome if you could explain to us how to do this with the new way OpenOffice offers their dictionaries.

Windows import side effects

I'm having difficulty using PyEnchant with PyGObject (https://wiki.gnome.org/Projects/PyGObject) on Windows 7. I'm using the WinPython (http://winpython.github.io/) portable distribution.

If I import enchant before PyGObject, the latter fails:

C:\Users\Jim\Documents\GitHub\Photini>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import enchant
>>> import gi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Jim\Documents\GitHub\Photini\src\windows\WinPython\python-3.4.3
\lib\site-packages\gi\__init__.py", line 42, in <module>
    from . import _gi
ImportError: DLL load failed: The specified procedure could not be found.
>>>

If I import gi first then enchant generates access violation errors:

C:\Users\Jim\Documents\GitHub\Photini>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> import enchant
>>> d = enchant.Dict()
>>> d.suggest('fred')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Jim\Documents\GitHub\Photini\src\windows\WinPython\python-3.4.3
\lib\site-packages\enchant\__init__.py", line 651, in suggest
    suggs = _e.dict_suggest(self._this,word.encode())
  File "C:\Users\Jim\Documents\GitHub\Photini\src\windows\WinPython\python-3.4.3
\lib\site-packages\enchant\_enchant.py", line 258, in dict_suggest
    suggs_c = dict_suggest1(dict,word,len(word),numSuggsP)
OSError: exception: access violation reading 0x561E097F
>>>

I've had a look at the import code in both PyEnchant and PyGObject and I'm unable to see how either is upsetting the other. I'm no expert in DLL importing though.

[PS I get similar results with Python 2.7]

Rename "tokenizer" module

This name conflicts with a python stdlib module, which can cause all sorts of weird problems. We should change it in the next major version rev.

Test Failure

hi,

in enchant/checker/init.py is written
If using an array of characters with this object and the
array is modified outside of the spellchecking loop, use the
'set_offset' method to reposition the internal loop pointer
to make sure it doesn't skip any words.

this is beeing tested in enchant/checker/tests.py which results
in an error:

braas@chinamon:~/projects/pyenchant$ python -m unittest
enchant.checker.tests.TestChecker

..F........

FAIL: test_chararray (enchant.checker.tests.TestChecker)

Test SpellChecker with a character array as input.

Traceback (most recent call last):
File "enchant/checker/tests.py", line 189, in test_chararray
self.assertEqual(err.word,"aray")
AssertionError: 'stord' != 'aray'


Ran 11 tests in 0.625s

the test only succeeds if set_offset at line 187 is ommited
What am I missing here?

It seems to me that the original errorlist is preserved. The added word is
not rechecked after insertion and repositioning with the use of set_offset.

what would (or should) happen if 'stord' was replaced with 'storxxd'?

This is on 1.6.6

Error written to stderr: "This UTF-8 encoding can't convert to UTF-16:"

This seems to happen when unicode chars > 2**16 - 1 are checked against a dictionary.

$ python
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import enchant
>>> d = enchant.Dict("en")
>>> d.check("test")
True
>>> chr(2**16 - 1)
'\uffff'
>>> d.check(chr(2**16 - 1))
False
>>> d.check(chr(2**16))
This UTF-8 encoding can't convert to UTF-16:
𐀀[goofy unicode char here]
False
>>> d.check(chr(2**16 + 1))
This UTF-8 encoding can't convert to UTF-16:
𐀀[goofy unicode char here]𐀁
False
>>> chr(2**16)
'𐀀𐀀[goofy unicode char here]'

This stderr should be silenced. I've been using this function to perform cleanup before running dictionary checks. It could probably be incorporated into pyenchant:

def utf16_cleanup(token):
    return "".join(c if ord(c) < 2**16 else REPLACEMENT_CHAR
                   for c in token)

Built-in tokenizer tokenizes on digits

from enchant.tokenize import get_tokenizer
tknzr = get_tokenizer("en_US")
[w for w in tknzr("foo2bar")]
[('foo', 0), ('bar', 4)]

I find the above behavior unexpected, and think that it would be more useful to not tokenize on digits, i.e. for the above example return just a single "foo2bar" token.

Cannot install on Python 3.3 with pip

Every system I tried it on, inside and outside of a virtualenv, raised the error raised in this build failure when trying to install pyenchant from pip under Python 3.3: error: invalid command 'bdist_egg'

I could be doing something dumb, but I'm pretty sure I've tried everything. I even tried this, but of course that's in a virtualenv, so it doesn't help.

Python 3.4 exception on exit

I get the following error on exit with Python 3.4 and enchant 1.6.5 from Debian repositories. It doesn't happen with Python 3.3.

Python 3.4.0 (default, Mar 22 2014, 15:42:03) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import enchant
>>> d = enchant.Dict('fr')
>>> d.suggest('pere')
['père', 'pères', 'perce', 'percé', 'perde', 'perle', 'perlé', 'perse', 'perte', 'pègre', 'périe', 'pétré', 'pète', 'pété', 'pré', 'ère', 'opère', 'opéré', 'hère', 'pers', 'PERL', 'aère', 'aéré', 'gère', 'géré', 'mère', 'pare', 'paré', 'pelé', 'perd', 'pesé', 'pire', 'pore', 'pure', 'pèle', 'pèse', 'pèze', 'pépé', 'péri', 'pêne']
>>> quit()

** (process:7967): WARNING **: 1 dictionaries weren't free'd.

Exception ignored in: <bound method Dict.__del__ of <enchant.Dict object at 0xb71905ec>>
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/enchant/__init__.py", line 508, in __del__
  File "/usr/lib/python3/dist-packages/enchant/__init__.py", line 562, in _free
  File "/usr/lib/python3/dist-packages/enchant/__init__.py", line 292, in _free_dict
  File "/usr/lib/python3/dist-packages/enchant/__init__.py", line 165, in _check_this
enchant.errors.Error: Broker unusable: the underlying C-library object has been freed.

words form personal word list are not suggested

Hi,
I've noticed that words from pwl are never suggested.

dict = enchant.DictWithPWL( "en_US", "My.vocabulary" )
print dict.suggest( "myWord")
while My.vocabulary file contains myWord entry
Regards,
Alex

enchant.checker.wxSpellCheckerDialog.wxSpellCheckerDialog should use shortcut keys for it's buttons and text boxes

Hi,
I've just been messing with the wxSpellCheckerDialog class, and it's brilliant, but it provides no shortcut keys for interracting with it's buttons / text boxes.

I've pasted my updated version of the class below.

If you don't like what I did, or if you would just like to provide more configurability, how about setting the buttons list on the class so that people can sub-class and overwrite the list as they like, and add more buttons if they want too (cancel button for example).

Cheers, and good work, this is a really good library, thank you!

class wxSpellCheckerDialog(wx.Dialog):
"""Simple spellcheck dialog for wxPython

This class implements a simple spellcheck interface for wxPython,
in the form of a dialog.  It's intended mainly of an example of
how to do this, although it should be useful for applications that
just need a simple graphical spellchecker.

To use, a SpellChecker instance must be created and passed to the
dialog before it is shown:

    >>> dlg = wxSpellCheckerDialog(None,-1,"")
    >>> chkr = SpellChecker("en_AU",text)
    >>> dlg.SetSpellChecker(chkr)
    >>> dlg.Show()

This is most useful when the text to be checked is in the form of
a character array, as it will be modified in place as the user
interacts with the dialog.  For checking strings, the final result
will need to be obtained from the SpellChecker object:

    >>> dlg = wxSpellCheckerDialog(None,-1,"")
    >>> chkr = SpellChecker("en_AU",text)
    >>> dlg.SetSpellChecker(chkr)
    >>> dlg.ShowModal()
    >>> text = dlg.GetSpellChecker().get_text()

Currently the checker must deal with strings of the same type as
returned by wxPython - unicode or normal string depending on the
underlying system.  This needs to be fixed, somehow...
"""
_DOC_ERRORS = ["dlg","chkr","dlg","SetSpellChecker","chkr","dlg",
               "dlg","chkr","dlg","SetSpellChecker","chkr","dlg",
               "ShowModal","dlg","GetSpellChecker"]

# Remember dialog size across invocations by storing it on the class
sz = (300,70)

def __init__(self, parent=None,id=-1,title="Checking Spelling..."):
    wx.Dialog.__init__(self, parent, id, title, size=wxSpellCheckerDialog.sz, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
    self._numContext = 40
    self._checker = None
    self._buttonsEnabled = True
    self.error_text = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH)
    self.replace_text = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER)
    self.replace_list = wx.ListBox(self, -1, style=wx.LB_SINGLE)
    self.InitLayout()
    wx.EVT_LISTBOX(self,self.replace_list.GetId(),self.OnReplSelect)
    wx.EVT_LISTBOX_DCLICK(self,self.replace_list.GetId(),self.OnReplace)

def InitLayout(self):
    """Lay out controls and add buttons."""
    sizer = wx.BoxSizer(wx.HORIZONTAL)
    txtSizer = wx.BoxSizer(wx.VERTICAL)
    btnSizer = wx.BoxSizer(wx.VERTICAL)
    replaceSizer = wx.BoxSizer(wx.HORIZONTAL)
    txtSizer.Add(wx.StaticText(self, -1, "&Unrecognised Word:"), 0, wx.LEFT|wx.TOP, 5)
    txtSizer.Add(self.error_text, 1, wx.ALL|wx.EXPAND, 5)
    replaceSizer.Add(wx.StaticText(self, -1, "Replace &with:"), 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
    replaceSizer.Add(self.replace_text, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
    txtSizer.Add(replaceSizer, 0, wx.EXPAND, 0)
    txtSizer.Add(self.replace_list, 2, wx.ALL|wx.EXPAND, 5)
    sizer.Add(txtSizer, 1, wx.EXPAND, 0)
    self.buttons = []
    for label, action, tip in (\
        ("&Ignore", self.OnIgnore, "Ignore this word and continue"),
        ("I&gnore All", self.OnIgnoreAll, "Ignore all instances of this word and continue"),
        ("&Replace", self.OnReplace, "Replace this word"),
        ("Replace &All", self.OnReplaceAll, "Replace all instances of this word"),
        ("A&dd", self.OnAdd, "Add this word to the dictionary"),
        ("D&one", self.OnDone, "Finish spell-checking and accept changes"),
        ):
        btn = wx.Button(self, -1, label)
        btn.SetToolTip(wx.ToolTip(tip))
        btnSizer.Add(btn, 0, wx.ALIGN_RIGHT|wx.ALL, 4)
        btn.Bind(wx.EVT_BUTTON, action)
        self.buttons.append(btn)
    sizer.Add(btnSizer, 0, wx.ALL|wx.EXPAND, 5)
    self.SetAutoLayout(True)
    self.SetSizer(sizer)
    sizer.Fit(self)

def Advance(self):
    """Advance to the next error.

    This method advances the SpellChecker to the next error, if
    any.  It then displays the error and some surrounding context,
    and well as listing the suggested replacements.
    """
    # Disable interaction if no checker
    if self._checker is None:
        self.EnableButtons(False)
        return False
    # Advance to next error, disable if not available
    try:
        self._checker.next()
    except StopIteration:
        self.EnableButtons(False)
        self.error_text.SetValue("")
        self.replace_list.Clear()
        self.replace_text.SetValue("")
        if self.IsModal(): # test needed for SetSpellChecker call
            # auto-exit when checking complete
            self.EndModal(wx.ID_OK)
        return False
    self.EnableButtons()
    # Display error context with erroneous word in red.
    # Restoring default style was misbehaving under win32, so
    # I am forcing the rest of the text to be black.
    self.error_text.SetValue("")
    self.error_text.SetDefaultStyle(wx.TextAttr(wx.BLACK))
    lContext = self._checker.leading_context(self._numContext)
    self.error_text.AppendText(lContext)
    self.error_text.SetDefaultStyle(wx.TextAttr(wx.RED))
    self.error_text.AppendText(self._checker.word)
    self.error_text.SetDefaultStyle(wx.TextAttr(wx.BLACK))
    tContext = self._checker.trailing_context(self._numContext)
    self.error_text.AppendText(tContext)
    # Display suggestions in the replacements list
    suggs = self._checker.suggest()
    self.replace_list.Set(suggs)
    self.replace_text.SetValue(suggs and suggs[0] or '')
    return True

def EnableButtons(self, state=True):
    """Enable the checking-related buttons"""
    if state != self._buttonsEnabled:
        for btn in self.buttons[:-1]:
            btn.Enable(state)
        self._buttonsEnabled = state

def GetRepl(self):
    """Get the chosen replacement string."""
    repl = self.replace_text.GetValue()
    return repl

def OnAdd(self, evt):
    """Callback for the "add" button."""
    self._checker.add()
    self.Advance()

def OnDone(self, evt):
    """Callback for the "close" button."""
    wxSpellCheckerDialog.sz = self.error_text.GetSizeTuple()
    if self.IsModal():
        self.EndModal(wx.ID_OK)
    else:
        self.Close()

def OnIgnore(self, evt):
    """Callback for the "ignore" button.
    This simply advances to the next error.
    """
    self.Advance()

def OnIgnoreAll(self, evt):
    """Callback for the "ignore all" button."""
    self._checker.ignore_always()
    self.Advance()

def OnReplace(self, evt):
    """Callback for the "replace" button."""
    repl = self.GetRepl()
    if repl:
        self._checker.replace(repl)
    self.Advance()

def OnReplaceAll(self, evt):
    """Callback for the "replace all" button."""
    repl = self.GetRepl()
    self._checker.replace_always(repl)
    self.Advance()

def OnReplSelect(self, evt):
    """Callback when a new replacement option is selected."""
    sel = self.replace_list.GetSelection()
    if sel == -1:
        return
    opt = self.replace_list.GetString(sel)
    self.replace_text.SetValue(opt)

def GetSpellChecker(self):
    """Get the spell checker object."""
    return self._checker

def SetSpellChecker(self,chkr):
    """Set the spell checker, advancing to the first error.
    Return True if error(s) to correct, else False."""
    self._checker = chkr
    return self.Advance()

Heroku install pyenchant error

When try to install pyenchant on heroku, the following error occurs:

Running setup.py egg_info for package pyenchant
Traceback (most recent call last):
File "", line 16, in
File "/tmp/pip-build-u16111/pyenchant/setup.py", line 195, in
import enchant
File "enchant/init.py", line 90, in
from enchant import _enchant as _e
File "enchant/_enchant.py", line 133, in
raise ImportError("enchant C library not found")
ImportError: enchant C library not found
Complete output from command python setup.py egg_info

Can't find dicts

Installed on Win XP

>>> import enchant
>>> d = enchant.Dict("en_US")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 528, in __init__
    _EnchantObject.__init__(self)
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 168, in __init__
    self._init_this()
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 535, in _init_this
    this = self._broker._request_dict_data(self.tag)
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 295, in _request_dict_data
    self._raise_error(eStr % (tag,),DictNotFoundError)
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 249, in _raise_error
    raise eclass(default)
enchant.errors.DictNotFoundError: Dictionary for language 'en_US' could not be found

Copy and extract dicts from src\pyenchant\tools\pyenchant-bdist-win32-sources\build\share\enchant\myspell to C:\Python27\Lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\share\enchant\myspell

>>> import enchant
>>>  enchant.set_param("enchant.myspell.dictionary.path",r"C:\Python27\Lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\share\enchant\myspell")
>>> d = enchant.Dict("en_US")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 528, in __init__
    _EnchantObject.__init__(self)
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 168, in __init__
    self._init_this()
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 535, in _init_this
    this = self._broker._request_dict_data(self.tag)
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 295, in _request_dict_data
    self._raise_error(eStr % (tag,),DictNotFoundError)
  File "C:\Python27\lib\site-packages\pyenchant-1.6.6-py2.7.egg\enchant\__init__.py", line 249, in _raise_error
    raise eclass(default)
enchant.errors.DictNotFoundError: Dictionary for language 'en_US' could not be found

So where does it look for dicts?
Can you write that in some README file?

Build pre-compiled libs for win64

Similar to the win32 binaries, we should ship a wheel for the win_amd64 platform. Once we get the win32 build process fixed this might be a simple matter of re-compiling for that platform. Or it might be a good deal more complicated...

win32_data_files() should not include iconv, intl, libglib and libgmodule (?)

In https://github.com/rfk/pyenchant/blob/master/enchant/utils.py#L334, there's currenty this piece of code:

    for prefix in ("iconv","intl","libglib","libgmodule"):
        if dll.startswith(prefix):
            break
    else:
        continue
    dataFiles[0][1].append(os.path.join(mainDir,dll))

From my understanding, this for cycle is currently non-functional. While I assume it's supposed to skip the four dll files and not add them to the data file list, it does nothing. If my assumption about the intention of this piece of code is correct, then here's a possible fix which makes it work:

    for prefix in ("iconv","intl","libglib","libgmodule"):
        if dll.startswith(prefix):
            skip = True
            break
        else:
            continue
    if not skip:
        dataFiles[0][1].append(os.path.join(mainDir,dll))

By the way, in lines 327-330 above this, libenchant.dll (or libenchant-1.dll) is being added to the list manually, but this for cycle adds that library anyway, making lines 327-330 unnecessary.

pyenchant not working with self-compiled enchant

I'm using win7-64bit. Trying to use pyenchant 1.6.6 under WinPython-64bit I compiled enchant 1.6.0 with TDM-GCC-64 and copied the 3 dlls (libenchant-1.dll, libenchant_ispell.dll and libenchant_myspell.dll) into the proper folders (enchant/ or enchant/lib/enchant/). But using pyenchant I got an „Dict-not-found-error“.
The same error message occured after compiling enchant with TDM-GCC-32 for Python-32bit.
What is going wrong?
Wolfgang

d.check critical error for string of length 0

I am a new user of pyenchant. Using under Windows.

Except for one small problem, it works like a charm.

When the check method is called with a length 0 string, a critical error is raised.
It would seem better to simply return False.

Here's an interactive session, run under Emacs Shell:

(pyenchant) c:\ejf\pdfs\TM2013\ccs\research\german>python -i
python -i
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import enchant
>>> d = enchant.Dict("de_DE")
>>> d.check("")

** (python.exe:5956): CRITICAL **: enchant_dict_check: assertion `len' failed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\ejf\pdfs\TM2013\ccs\research\german\pyenchant\lib\site-packages\enchant\__init__.py", line 641, in check
    self._raise_error()
  File "c:\ejf\pdfs\TM2013\ccs\research\german\pyenchant\lib\site-packages\enchant\__init__.py", line 612, in _raise_error
    raise eclass(default)
enchant.errors.Error: Unspecified Error
>>> 

Remove all words in personal word lists

I accidentally add words into this, and I forgot what I added. Is there a way to remove all words in this list? I tried to uninstall pyenchant and reinstall, but seems the personal word list file is not deleted while uninstalling.

enchant.Dict("he").check always True

I have noticed a bug in the latest stable and github code. I am using hspell as a back end for Hebrew spell checking. All spell checks against it are returning True. See below.

import enchant
enchant.Dict("he").check("fo#$#4o")
True

pyenchant personal word list

Using MacPorts enchant package (version 1.5.0_0) running on latest Snow Leopard (10.6.2); Python 2.6.4

The call

pwl = enchant.request_pwl_dict("pwl.txt")
erases the content of pwl.txt

Adding words to the personal dictionary works fine - until you start the follwoing session, when they disappear.

Update and fix win32 build process

The current build process for win32 seems to be broken - compiling with latest mingw32 gives runtime errors that appear to be a segfault in libstdc++. This needs to be updated to the latest versions of the dependencies and the makefile re-done to build with the latest toolchain.

URLFilter does not match urls enclodes in <...>

URLs like <http://www.gnu.org/licenses/> are not recognized as URLs since they start with a angled bracket. Using angled brackets arround URLs is recommended in http://www.w3.org/Addressing/URL/5.1_Wrappers.html.

Solution: Simply change the pattern into

    _pattern = re.compile(r"^([a-zA-z]+:\/\/[^\s].*"
                          "|"
                          r"<[a-zA-z]+:\/\/[^\s].*>)")

Draw-back: This will match this syntax in HTML, too. So a new URLFilterWithBrackets may be suited better.

wxSpellCheckerDialog Missing GetSpellChecker

In wxSpellCheckerDialog's help text you have the following example code:
>>> dlg = wxSpellCheckerDialog(None,-1,"")
>>> chkr = SpellChecker("en_AU",text)
>>> dlg.SetSpellChecker(chkr)
>>> dlg.ShowModal()
>>> text = dlg.GetSpellChecker().get_text()

However, an exception is thrown because GetSpellChecker is not defined (however SetSpellCheck is defined).

It seems this is a fairly simple fix though.

err.replace fails

The following snippet fails. I will continualy print 'ERROR: ning"

it seems that replacing the errornous word is not handled correctly

The correct word is "vergunning", dutch for "permit"

from enchant.checker import SpellChecker
text = "verguning."
chkr = SpellChecker("nl_NL",text)
for err in chkr:
....print "ERROR", err.word
....err.replace("SPAM")
print chkr.get_text()

if i want to replace with an empty string i get the error:
** (process:7094): CRITICAL **: enchant_dict_store_replacement: assertion `cor_len' failed

I'm using pyenchant 1.6.5

Python enchant dictionary exist but not working

I am using Python2.7 and trying to get enchant or aspell to come with some Danish spelling suggestions. The same goes for Norwegian and Swedish. I am using OS X Yosemite

I downloaded the brew install aspell --with-lang-da and that seems to work, because the dictionary seems to exist.

import enchant

print enchant.list_languages() #['da', 'en', 'en_CA', 'en_GB', 'en_US']
print enchant.list_dicts() #[('da', <Enchant: Aspell Provider>), ('en', <Enchant: Aspell Provider>), ('en_CA', <Enchant: Aspell Provider>), ('en_GB', <Enchant: Aspell Provider>), ('en_US', <Enchant: Aspell Provider>)]

d = enchant.request_dict("da")
print(d.suggest("motorcyke"))

d = enchant.Dict("da")
print(d.suggest("motorcyke"))

The problem is that no suggestion are showing up. It is like the dictionary exist but is empty.

Thanks...

Making correction suggestions from CmdLineChecker is tricky for us humans

I've just got started using pyenchant for my application in less than an hour, which is always a good sign. But I've gotta say: making the input for spelling suggestions zero-based is always going to be tricky for mere humans...

Anyone concur that to select the first suggestion in the list one should type '1', not '0'?

Install fails on OS X

Running python setup.py install returns the following traceback:

Traceback (most recent call last):
  File "setup.py", line 143, in <module>
    for fName in os.listdir(libDir):
OSError: [Errno 2] No such file or directory: './tools/pyenchant-bdist-osx-sources/build/lib'

Not sure whether there is something missing in the distribution or what; just wanted to give you a heads-up. Thanks!

TypeError at shutdown

I use pylint, which uses pyenchant. After pylint does its thing, pyenchant spits out an exception. This doesn't seem to happen linting every file, but it happens frequently.

Here is the exception:

Exception ignored in: <bound method Broker.__del__ of <enchant.Broker object at 0x7f811afaad68>>
Traceback (most recent call last):
  File "/home/USER/.local/lib/python3.4/site-packages/enchant/__init__.py", line 244, in __del__
  File "/home/USER/.local/lib/python3.4/site-packages/enchant/__init__.py", line 273, in _free
TypeError: 'NoneType' object is not callable

As evident by the exception, the error seems to be occurring in the Broker object destructor __del__(). It looks like maybe the Broker class is setting self._free to None and then trying to execute it like self._free(), but I'm not certain. The Dict object destructor may also be vulnerable to the same sort of thing, as it runs self._free() in a try block with except AttributeError but does not catch TypeError. Anyways, I'm not familiar with pyenchant and whether that is likely to occur in the Dict class, so I won't add it.

I will submit a pull request to fix the error that I've been getting. If you think the same thing could occur in the Dict class then you may want to fix __del__() there too.

Update

See pull request #56.

Assertion error in suggestions

Hi,

I have installed pyenchant-1.6.5.win32.exe under python 2.6 on win xp.

The code below raises assertion error:

import enchant
enchant.get_enchant_version()
'1.6.0'
d = enchant.Dict("de_DE")
d.suggest("ssa")

** (Python.exe:1320): CRITICAL **: enchant_is_title_case: assertion `word && *word' failed

** (Python.exe:1320): CRITICAL **: enchant_is_all_caps: assertion `word && *word' failed
['SAS', '']

Is there anything I can do to workaround this?

BTW: Why if I have installed pyenchant-1.6.5 get_enchant_version() returns '1.6.0' ?

Edit: Hint: it only happens for some specific words in specific languages. "ssa" is one of them, another bad word is "fdf". Suggestions for this word in the same German dictionary returns the same error.

Best Regards,
Mateusz

TypeError on Python3, OSX

The retext project uses pyenchant and somehow the version i have installed seems to fail.

python3 ./retext.py                                                                            
Traceback (most recent call last):
  File "./retext.py", line 24, in <module>
    from ReText import datadirs, globalSettings
  File "/Users/techdragon/dev/sourceforge.com/retext-git/ReText/__init__.py", line 23, in <module>
    import enchant
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/enchant/__init__.py", line 92, in <module>
    from enchant import _enchant as _e
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/enchant/_enchant.py", line 121, in <module>
    prefix_dir.contents = c_char_p(e_dir)
TypeError: bytes or integer address expected instead of str instance

Double checking, the issue is with the python wrapper as i can't get it to work using the wheel just by itself in the python interpreter.

python3                                                                                          1   master
Python 3.4.0 (v3.4.0:04f714765c13, Mar 15 2014, 23:02:41)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import enchant
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/enchant/__init__.py", line 92, in <module>
    from enchant import _enchant as _e
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/enchant/_enchant.py", line 121, in <module>
    prefix_dir.contents = c_char_p(e_dir)
TypeError: bytes or integer address expected instead of str instance
>>>

mac os dmg download "not recognized"

downloaded pyenchant-1.6.5-py2.6-macosx-10.4-universal.dmg twice, when I try to open it the Finder pops up a dialog I'd never seen before saying "The following disk images couldn't be opened" and Reason: not recognized. N.B. the matching egg seems to install fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.