Hyphenation: PyHyphen-0.7 released



Hi,

I have just uploaded the latest sources of PyHyphen
(http://cheeseshop.python.org/pypi/PyHyphen). The tarball also contains
Windows binaries of the C extension for Python 2.4 and 2.5. So most Windows
users will get going without compiling. Just enter the usual 'python
setup.py install'.

There are many bug fixes both in the Python modules on top as well as in the
C extension that uses a new release of the underlying hyphenation library
(hyphen-2.3.1).

Further, I have added a module 'dictools' for easy download and installation
of dictionaries (see below). Finally, a script for easy testing of the
hyphenation functionality with large wordlists and multiple dictionaries has
been added. Dictionaries are installed on the fly and everything is logged.

The default dir for dictionaries and the default repository to download
dictionaries are configurable, so that one can use existing dictionaries,
e.g., from an OpenOffice installation.

The package also includes and installs the module 'textwrap2' which adds a
hyphenation feature to the standard module textwrap.


Code example:

from hyphen import hyphenator
from hyphen.dictools import *

# Download and install some dictionaries in the default directory using the
default
# repository, usually the OpenOffice website
for lang in ['de_DE', 'fr_FR', 'en_UK', 'hu_HU']:
if not is_installed(lang): install(lang)

# Create some hyphenators
h_de = hyphenator('de_DE')
h_en = hyphenator('en_US')
h_hu = hyphenator('hu_HU')

# Now hyphenate some words

print h_hu.inserted(u'asszonnyal')
'asz=szony=nyal'

print h_en.pairs('beautiful')
[[u'beau', u'tiful'], [u'beauti', u'ful']]

print h_en.wrap('beautiful', 6)
[u'beau-', u'tiful']

print h_en.wrap('beautiful', 7)
[u'beauti-', u'ful']

from textwrap2 import fill
print fill('very long text...', width = 40, use_hyphens = h_en)

My thanks go to those who helped enormously with advice, suggestions,
criticism and Windows builds.

Regards

Leo


.



Relevant Pages

  • Re: Hyphenation
    ... Mary Sauer MSFT MVP ... So I used the install ... What happens when you turn on/off hyphenation in Tools, options, edit ...
    (microsoft.public.publisher)
  • Re: How to change permissions for /usr/share
    ... download -> install some dictionaries. ... I suppose you installed stardict from ubuntu repositories. ...
    (Ubuntu)
  • Re: Hyphenation
    ... Mary Sauer MSFT MVP ... this annoying window keeps coming up about wanting to install Hyphenator. ... What happens when you turn on/off hyphenation in Tools, options, edit tab? ...
    (microsoft.public.publisher)
  • Re: Word - Dictionary
    ... Every time I open Word, the dictionary always defaults to the ... "English US" Dictionary no matter how many times I set it to ... Can't you just Install it from the M$ Office/Word Installation CD? ... Tree up, to see the various Options), there are various Dictionaries ...
    (uk.people.silversurfers)
  • Re: Comprehensive spelling
    ... for Word 6.0 and it won't install without 6.0 ... Or is there a way to import medical terminology ... and save it into the Proofing folder under your profile that also contains ... Dictionaries dialog to add the new dictionary. ...
    (microsoft.public.word.docmanagement)