utilities for polyglots
Project description
polyquack
Preamble
polyquack
is a utility (possibly part of a larger set in the future) for pluralizing words based on rules of varying complexity.
It has been inspired by the Localization and Plurals page from the MDN.
Installation
Simply run pip install polyquack
.
Usage
First, define a list of forms. It is a simple dict
with language codes as keys. For now, refer to the tests/test_pluralization.py
file to see the form definitions by rule, and the rules.py
file for a mapping of languages to rules. Not all languages have the same number of forms (for instance, slavic languages often have a genitive plural form).
>>> song_forms = {
... "en": ["song", "songs"],
... "fr": ["chanson", "chansons"],
... "pl": ["piosenka", "piosenki", "piosenek"],
... }
This package provides a handy Pluralizable
class that you can use.
>>> from polyquack import pluralization
>>> song = pluralization.Pluralizable(forms=song_forms)
>>> print(f"4 {song.pluralize_by_language('pl', 4)}") # nominative plural
4 piosenki
>>> print(f"5 {song.pluralize_by_language('pl', 5)}") # genitive plural
5 piosenek
Todo
This project is barely a few days old. I will be adding proper documentation, and tox
for testing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for polyquack-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d37af6ef5da6fc46f61456d3c237ad19cfa499038d50eb2bdae2ca3aad8874da |
|
MD5 | 1d427b52d01ba27b6a6f6ce682d57db2 |
|
BLAKE2b-256 | 5a3059b91d71350c6760199b8e86a37b5464b18e336add05086346745cd2d4c6 |