Hyphenation: PyHyphen-0.7 released

D

Dr. leo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top