{"library":"pyphen","title":"Pyphen","description":"Pyphen is a pure Python module designed for text hyphenation, leveraging existing Hunspell hyphenation dictionaries. It bundles a wide array of dictionaries sourced from the LibreOffice project. The library is currently at version 0.17.2 and maintains an active development status with regular releases, often including updates to dictionaries and broader Python version compatibility.","status":"active","version":"0.17.2","language":"en","source_language":"en","source_url":"https://github.com/Kozea/Pyphen","tags":["hyphenation","text processing","linguistics","hunspell","dictionaries","localization"],"install":[{"cmd":"pip install pyphen","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The primary class for creating a hyphenator instance.","symbol":"Pyphen","correct":"from pyphen import Pyphen"},{"note":"Utility function for language fallback logic, typically accessed via the module.","symbol":"language_fallback","correct":"import pyphen; pyphen.language_fallback(...)"},{"note":"A dictionary containing available language codes and their dictionary paths, accessed via the module.","symbol":"LANGUAGES","correct":"import pyphen; pyphen.LANGUAGES"}],"quickstart":{"code":"import pyphen\n\n# Instantiate Pyphen for a specific language (e.g., French)\ndic = pyphen.Pyphen(lang='fr_FR')\n\n# Check if a language is available\nprint(f\"Is 'fr_FR' available? {'fr_FR' in pyphen.LANGUAGES}\")\n\n# Hyphenate a word, inserting hyphens\nword = 'fromage'\nhyphenated_word = dic.inserted(word)\nprint(f\"'{word}' hyphenated: {hyphenated_word}\") # Expected: 'fro-mage'\n\n# Wrap a word to a certain width\nlong_word = 'autobandventieldopje'\nwrapped_word = dic.wrap(long_word, 11)\nprint(f\"'{long_word}' wrapped to 11 chars: {wrapped_word}\") # Expected: ('autoband-', 'ventieldopje')\n\n# Iterate over all possible hyphenation points\nprint(f\"Hyphenation iterations for 'Amsterdam':\")\nfor pair in dic.iterate('Amsterdam'):\n    print(pair)","lang":"python","description":"Initialize a `Pyphen` object for a desired language. The quickstart demonstrates basic hyphenation using `inserted()`, word wrapping with `wrap()`, and iterating through all possible hyphenation points with `iterate()`. It also shows how to check for available languages using `pyphen.LANGUAGES`. Dictionaries are automatically loaded upon instantiation."},"warnings":[{"fix":"Upgrade your Python environment to at least version 3.9 (or newer, as dictated by the specific Pyphen version you are using) to maintain compatibility. Check `requires_python` on PyPI or the official changelog for specific version requirements.","message":"Pyphen regularly drops support for older Python versions. For instance, v0.17.0 dropped Python 3.8, v0.15.0 dropped 3.7, and v0.12.0 dropped 3.6. Ensure your Python environment meets the `requires_python` specification, which is currently `>=3.9`.","severity":"breaking","affected_versions":"0.12.0, 0.15.0, 0.17.0 and newer"},{"fix":"Instantiate `Pyphen` once and reuse the object throughout your application rather than creating new instances repeatedly. Consider lazy loading if hyphenation is not immediately required.","message":"Initializing a `Pyphen` instance, particularly with large dictionaries, can be a time-consuming operation, especially on resource-constrained devices like a Raspberry Pi Zero where it might take tens of seconds. The delay occurs during dictionary parsing and setup.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For persistent issues with specific words or languages, it may be necessary to consult the upstream LibreOffice dictionaries or contribute fixes there. Pyphen itself uses these dictionaries without modification.","message":"The correctness of hyphenation is dependent on the quality and rules of the underlying Hunspell dictionaries. Occasionally, certain words or language nuances might lead to unexpected hyphenation points or errors (e.g., specific issues reported for Polish or German words).","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you are directly interacting with Pyphen's internal resource loading mechanisms (which is uncommon for typical usage), update your code to use `importlib.resources` for future compatibility. Standard usage `pyphen.Pyphen(lang='...')` is unaffected.","message":"Starting from version 0.15.0, Pyphen transitioned from `pkg_resources` to `importlib.resources` for resource management. While `pkg_resources` might still function in some older setups, it is officially deprecated in Python.","severity":"deprecated","affected_versions":"0.15.0 and newer"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}