Pyphen

Presentation

Pyphen is a pure Python module to hyphenate words using included or external Hunspell hyphenation dictionaries.

Usage

>>> import pyphen
>>> pyphen.language_fallback('nl_NL_variant1')
'nl_NL'
>>> 'nl_NL' in pyphen.LANGUAGES
True
>>> dic = pyphen.Pyphen(lang='nl_NL')
>>> dic.inserted('lettergrepen')
'let-ter-gre-pen'
>>> dic.wrap('autobandventieldopje', 11)
('autoband-', 'ventieldopje')
>>> for pair in dic.iterate('Amsterdam'):
...     print(pair)
...
('Amster', 'dam')
('Am', 'sterdam')

You can also get the documentation of the module objects using:

>>> import pyphen
>>> help(pyphen)

Features

Included Dictionaries

The dictionaries included in LibreOffice are distributed with Pyphen:

Download

Latest version of Pyphen is 0.14.0, released on March 17, 2023.

Pyphen available on PyPI. To install, just type pip install pyphen as superuser.

Pyphen is also packaged for ArchLinux, CentOS, Gentoo, Fedora and Mageia.

If you want the development version, take a look at the git repository on GitHub, or clone it thanks to git clone git://github.com/Kozea/Pyphen.git.

You can also download the Pyphen package of the git repository.

Contribute

Features, bugs, hacks, documentation, tests, dictionaries? Fork us on GitHub, or chat with us on Gitter.

License

Pyphen is a friendly fork of the unmaintained python-hyphenator module.

Pyphen is released under the GPL 2.0+ ~ LGPL 2.1+ ~ MPL 1.1 tri-license. See COPYING.GPL, COPYING.LGPL and COPYING.MPL for more details.

The dictionaries included in Pyphen come from the LibreOffice’s git repository and are distributed under GPL, LGPL and/or MPL. See the dictionaries and LibreOffice’s repository for more details.