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: 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)
  • hyphenation - possible glitch? ... just passing this on
    ... I see the following prompt - "Word hyphenation feature is not available. ... Run the Microsoft Office Setup program, install this feature and then try again." ... look for Hyphenation and discover it 'is installed on first use' ... ... (I've been using Vista and Office 2007 since Feb 2007 and this Hyphenation prompt never appeared before. ...
    (microsoft.public.word.newusers)
  • Re: Another Boring Technology Thread
    ... >recognition, will allow me to install my own dictionaries, and hopefully has ... It's light, has good handwriting recognition ... you still have to buy the accessory dictionaries you want. ... but consider that these Zaurus models run Java too. ...
    (sci.lang.japan)

Loading