Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Hyphenation: PyHyphen-0.7 released

Reply
Thread Tools

Hyphenation: PyHyphen-0.7 released

 
 
Dr. leo
Guest
Posts: n/a
 
      04-02-2008
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Win XP wireless network adapter gets released and then connects ba =?Utf-8?B?cGkyMmJ5Nw==?= Wireless Networking 1 08-01-2008 08:33 PM
Battlefield 2 New Patch Released (yet Again...) Silverstrand Front Page News 4 07-20-2005 04:33 PM
*Mozilla Firefox 1.0.4 Released* Roland Firefox 4 05-13-2005 03:05 PM
Firefox 1.0.1 released Z Firefox 2 02-26-2005 04:11 AM
ANN: Anyplace Control 2.6 released Yura Goncharuk Wireless Networking 0 09-28-2004 10:13 AM



Advertisments