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.

Source Distribution

PyHyphen-0.7.tar.gz (136.9 kB view details)

Uploaded Source

File details

Details for the file PyHyphen-0.7.tar.gz.

File metadata

  • Download URL: PyHyphen-0.7.tar.gz
  • Upload date:
  • Size: 136.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyHyphen-0.7.tar.gz
Algorithm Hash digest
SHA256 0cc59006f7682e35ff69dac4e276d170d1ab796547d72e537dbbefc7a51ed005
MD5 edcebd569415a9fb6aacf5e25326e2ef
BLAKE2b-256 866c39c9eb29a9b8fc940b5719ccda679536b25d83cfc921bd25e47f93da4630

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page