Hyphenation: PyHyphen-0.7 released

Discussion in 'Python' started by Dr. leo, Apr 2, 2008.

  1. Dr. leo

    Dr. leo Guest

    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
     
    Dr. leo, Apr 2, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dr. leo
    Replies:
    0
    Views:
    278
    Dr. leo
    Feb 13, 2008
  2. Dr. leo
    Replies:
    5
    Views:
    316
    thebjorn
    Feb 25, 2008
  3. Dr. leo
    Replies:
    0
    Views:
    252
    Dr. leo
    Feb 27, 2008
  4. Dr. leo
    Replies:
    0
    Views:
    263
    Dr. leo
    Mar 2, 2008
  5. Replies:
    0
    Views:
    256
Loading...

Share This Page