Skip to main content

The hyphenation library of OpenOffice and FireFox wrapped for Python

Project description

PyHyphen is a wrapper around the high quality hyphenation library hnj_hyphen-2.3.1 (Feb 2008) that ships
with OpenOffice.org and Mozilla products. Consequently, all dictionaries compatible with OpenOffice can be used.

It compiles and runs at least on Windows and Linux with Python 2.4 and 2.5, maybe also with Python 2.3.
However, the source distribution includes Windows binaries of the C extension module for Python
2.4 and 2.5. They were compiled with MSVC 2003.

By default, the appropriate binary, if available, will be installed rather
than compiling the C sources. Of course, you can also
download a Windows installer if available for your environment.

PyHyphen also contains textwrap2, an enhanced though backwards-compatible version of the standard Python module textwrap. Not very surprisingly, textwrap2 can hyphenate words when wrapping them.

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)

The PyHyphen project is hosted at http://pyhyphen.googlecode.com. In order to obtain the latest sources,
you will need Subversion (www.tigris.org).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for PyHyphen, version 0.7
Filename, size File type Python version Upload date Hashes
Filename, size PyHyphen-0.7.tar.gz (136.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page