ainconv


Nameainconv JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/mkpoli/ainconv
SummaryConverts Ainu text between different scripts (Katakana, Latin, Cyrillic and more)
upload_time2024-03-09 13:32:24
maintainer
docs_urlNone
authormkpoli
requires_python>=3.9,<4.0
licenseMIT
keywords ainu converter katakana latin cyrillic language writing system text preprocessing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!-- omit in toc -->
# ainconv - Ainu language script converter

[![Version](https://img.shields.io/pypi/v/ainconv)](https://pypi.org/project/ainconv/)
[![Downloads](https://pepy.tech/badge/ainconv)](https://pepy.tech/project/ainconv)
[![Python Versions](https://img.shields.io/pypi/pyversions/ainconv)](https://pypi.org/project/ainconv/)
[![Read the Docs](https://img.shields.io/readthedocs/ainconv-py)](https://ainconv-py.readthedocs.io/)
[![MIT License](https://img.shields.io/pypi/l/ainconv)](./LICENSE)
[![GitHub issues](https://img.shields.io/github/issues/mkpoli/ainconv-py)](https://github.com/mkpoli/ainconv-py/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/mkpoli/ainconv-py)](https://github.com/mkpoli/ainconv-py/issues)
[![test](https://github.com/mkpoli/ainconv-py/actions/workflows/test.yml/badge.svg)](https://github.com/mkpoli/ainconv-py/actions/workflows/test.yml)
[![Discord](https://dcbadge.vercel.app/api/server/pkpAdPHzpP?style=flat)](https://discord.aynu.org/)

<!-- omit in toc -->
## Table of Contents

- [Overview](#overview)
  - [Important Note](#important-note)
- [Installation](#installation)
- [Usage](#usage)
  - [Word Conversion](#word-conversion)
  - [Extra Functionality](#extra-functionality)
    - [Conversion Options](#conversion-options)
      - [Katakana](#katakana)
    - [Script Detection](#script-detection)
    - [Syllable Splitting](#syllable-splitting)
- [Support](#support)
- [License](#license)
- [See also](#see-also)

## Overview


> [!IMPORTANT]
> By default, conversions between Katakana to and from any script are inherently lossy. See [Important Note](#important-note) for more details.

This package provides a comprehensive set of functions for converting text between different writing systems of the [Ainu language](https://en.wikipedia.org/wiki/Ainu_language).

Currently, Latin (Romanization), Katakana and Cyrillic scripts are supported. We are also planning to convert between different romanization systems and Katakana variants. Currently only the more adopted version of Latin script and lossy Katakana script are supported.

Sentence conversion is planned to be supported in the future. For now, only well-formed single word is accepted. The converted string are always in lower case.

### Important Note

Conversion between Latin and Cyrillic script are lossless, however, conversion between Katakana and any other scripts are lossy. This means that converting from Katakana to other scripts and then back to Katakana may not give the original string and the result may be ambiguous or even incorrect.

This is because the most widely used Katakana orthography for the Ainu language is intrinsically ambiguous. For example, *tow* and *tu* are both *トゥ*, *iw* and *i.u* are both *イウ*, *ay* and *a.i* are both *アイ*, etc. Some alternative Katakana scripts are proposed to solve this problem, but none of them are widely adopted.

We already added some options (see [Conversion Options](#conversion-options)) for Katakana output and are planning to support others to mitigate this problem. However, since Katakana orthography still contains less information than Latin orthography, you cannot get the original text back from the converted text, distinctions such as `-w`, `-y` and `-n` (with options off), `=` and `-` symbols, letter case, etc. are lost in the conversion. Additionally, Katakana text from elsewhere usually does not contain these distinctions, so converting losslessly from Katakana to other scripts is impossible.

## Installation

Install the package using pip

```bash
pip install ainconv
```

## Usage

> [!NOTE]
> You can also read the full documentation on [Read the Docs](https://ainconv-py.readthedocs.io/).

### Word Conversion

```python
from ainconv import (
    kana2latn,
    latn2kana,
    cyrl2latn,
    latn2cyrl,
    kana2cyrl,
    cyrl2kana,
    # ...
)

print(kana2latn("イランカラㇷ゚テ")) # "irankarapte"
print(latn2kana("irankarapte")) # "イランカラㇷ゚テ"
print(cyrl2latn("иранкараптэ")) # "irankarapte"
print(latn2cyrl("irankarapte")) # "иранкараптэ"
print(cyrl2kana("иранкараптэ")) # "イランカラㇷ゚テ"
print(kana2cyrl("イランカラㇷ゚テ")) # "иранкараптэ"
```

### Extra Functionality

#### Conversion Options

##### Katakana

```python
from ainconv import latn2kana

# Use ィ (-y), ゥ (-w) and ㇴ (-n)
assert latn2kana("kay") == "カイ"
assert latn2kana("kay", use_small_i=True) == "カィ"
assert latn2kana("kew") == "ケウ"
assert latn2kana("kew", use_small_u=True) == "ケゥ"
assert latn2kana("mun") == "ムン"
assert latn2kana("mun", use_small_n=True) == "ムㇴ"

# Use ヰ (wi), ヱ (we) and ヲ (wo) 
assert latn2kana("wiki") == "ウィキ"  # for loanwords only
assert latn2kana("wiki", use_wi=True) == "ヰキ"
assert latn2kana("weni") == "ウェニ"
assert latn2kana("weni", use_we=True) == "ヱニ"
assert latn2kana("wóse") == "ウォセ"
assert latn2kana("wóse", use_wo=True) == "ヲセ"

assert latn2kana("wiwewo") == "ウィウェウォ"
assert latn2kana("wiwewo", use_wi=True, use_we=True, use_wo=True) == "ヰヱヲ"
```


#### Script Detection

Detect the script of a given string.

```python
from ainconv import detect

print(detect("aynu")) # "Latn"
print(detect("アイヌ")) # "Kana"
print(detect("айну")) # "Cyrl"
```

#### Syllable Splitting

```python
from ainconv import separate

print(separate("eyaykosiramsuypa")) # ["e", "yay", "ko", "si", "ram", "suy", "pa"]
```

## Support

If you have a question or have found a bug or any other issue, feel free to [open an issue](https://github.com/mkpoli/ainconv-py/issues/new) to let me know. For instructions on how to contribute, see [CONTRIBUTING.md](https://github.com/mkpoli/ainconv-py/blob/master/CONTRIBUTING.md).

You can also [join our Discord](https://discord.aynu.org/) for discussion. We have many projects going on about Ainu, so you may find something interesting there as well.

## License

[MIT License](LICENSE) (c) 2024 mkpoli

## See also

* [ainconv - npm](https://www.npmjs.com/package/ainconv): The JavaScript version of this package
* [ainconv - crates.io](https://crates.io/crates/ainconv): The Rust version of this package
* [Module:ain-kana-conv - ウィクショナリー日本語版](https://ja.wiktionary.org/wiki/%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:ain-kana-conv): The original Lua Scribunto module in the Japanese Wiktionary

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mkpoli/ainconv",
    "name": "ainconv",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "ainu,converter,katakana,latin,cyrillic,language,writing system,text preprocessing",
    "author": "mkpoli",
    "author_email": "mkpoli@mkpo.li",
    "download_url": "https://files.pythonhosted.org/packages/f9/a3/74af141ddffd5bace2ce88ef4e051b7d84154933f9f64d797ecb262620d6/ainconv-0.4.0.tar.gz",
    "platform": null,
    "description": "<!-- omit in toc -->\n# ainconv - Ainu language script converter\n\n[![Version](https://img.shields.io/pypi/v/ainconv)](https://pypi.org/project/ainconv/)\n[![Downloads](https://pepy.tech/badge/ainconv)](https://pepy.tech/project/ainconv)\n[![Python Versions](https://img.shields.io/pypi/pyversions/ainconv)](https://pypi.org/project/ainconv/)\n[![Read the Docs](https://img.shields.io/readthedocs/ainconv-py)](https://ainconv-py.readthedocs.io/)\n[![MIT License](https://img.shields.io/pypi/l/ainconv)](./LICENSE)\n[![GitHub issues](https://img.shields.io/github/issues/mkpoli/ainconv-py)](https://github.com/mkpoli/ainconv-py/issues)\n[![GitHub pull requests](https://img.shields.io/github/issues-pr/mkpoli/ainconv-py)](https://github.com/mkpoli/ainconv-py/issues)\n[![test](https://github.com/mkpoli/ainconv-py/actions/workflows/test.yml/badge.svg)](https://github.com/mkpoli/ainconv-py/actions/workflows/test.yml)\n[![Discord](https://dcbadge.vercel.app/api/server/pkpAdPHzpP?style=flat)](https://discord.aynu.org/)\n\n<!-- omit in toc -->\n## Table of Contents\n\n- [Overview](#overview)\n  - [Important Note](#important-note)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Word Conversion](#word-conversion)\n  - [Extra Functionality](#extra-functionality)\n    - [Conversion Options](#conversion-options)\n      - [Katakana](#katakana)\n    - [Script Detection](#script-detection)\n    - [Syllable Splitting](#syllable-splitting)\n- [Support](#support)\n- [License](#license)\n- [See also](#see-also)\n\n## Overview\n\n\n> [!IMPORTANT]\n> By default, conversions between Katakana to and from any script are inherently lossy. See [Important Note](#important-note) for more details.\n\nThis package provides a comprehensive set of functions for converting text between different writing systems of the [Ainu language](https://en.wikipedia.org/wiki/Ainu_language).\n\nCurrently, Latin (Romanization), Katakana and Cyrillic scripts are supported. We are also planning to convert between different romanization systems and Katakana variants. Currently only the more adopted version of Latin script and lossy Katakana script are supported.\n\nSentence conversion is planned to be supported in the future. For now, only well-formed single word is accepted. The converted string are always in lower case.\n\n### Important Note\n\nConversion between Latin and Cyrillic script are lossless, however, conversion between Katakana and any other scripts are lossy. This means that converting from Katakana to other scripts and then back to Katakana may not give the original string and the result may be ambiguous or even incorrect.\n\nThis is because the most widely used Katakana orthography for the Ainu language is intrinsically ambiguous. For example, *tow* and *tu* are both *\u30c8\u30a5*, *iw* and *i.u* are both *\u30a4\u30a6*, *ay* and *a.i* are both *\u30a2\u30a4*, etc. Some alternative Katakana scripts are proposed to solve this problem, but none of them are widely adopted.\n\nWe already added some options (see [Conversion Options](#conversion-options)) for Katakana output and are planning to support others to mitigate this problem. However, since Katakana orthography still contains less information than Latin orthography, you cannot get the original text back from the converted text, distinctions such as `-w`, `-y` and `-n` (with options off), `=` and `-` symbols, letter case, etc. are lost in the conversion. Additionally, Katakana text from elsewhere usually does not contain these distinctions, so converting losslessly from Katakana to other scripts is impossible.\n\n## Installation\n\nInstall the package using pip\n\n```bash\npip install ainconv\n```\n\n## Usage\n\n> [!NOTE]\n> You can also read the full documentation on [Read the Docs](https://ainconv-py.readthedocs.io/).\n\n### Word Conversion\n\n```python\nfrom ainconv import (\n    kana2latn,\n    latn2kana,\n    cyrl2latn,\n    latn2cyrl,\n    kana2cyrl,\n    cyrl2kana,\n    # ...\n)\n\nprint(kana2latn(\"\u30a4\u30e9\u30f3\u30ab\u30e9\u31f7\u309a\u30c6\")) # \"irankarapte\"\nprint(latn2kana(\"irankarapte\")) # \"\u30a4\u30e9\u30f3\u30ab\u30e9\u31f7\u309a\u30c6\"\nprint(cyrl2latn(\"\u0438\u0440\u0430\u043d\u043a\u0430\u0440\u0430\u043f\u0442\u044d\")) # \"irankarapte\"\nprint(latn2cyrl(\"irankarapte\")) # \"\u0438\u0440\u0430\u043d\u043a\u0430\u0440\u0430\u043f\u0442\u044d\"\nprint(cyrl2kana(\"\u0438\u0440\u0430\u043d\u043a\u0430\u0440\u0430\u043f\u0442\u044d\")) # \"\u30a4\u30e9\u30f3\u30ab\u30e9\u31f7\u309a\u30c6\"\nprint(kana2cyrl(\"\u30a4\u30e9\u30f3\u30ab\u30e9\u31f7\u309a\u30c6\")) # \"\u0438\u0440\u0430\u043d\u043a\u0430\u0440\u0430\u043f\u0442\u044d\"\n```\n\n### Extra Functionality\n\n#### Conversion Options\n\n##### Katakana\n\n```python\nfrom ainconv import latn2kana\n\n# Use \u30a3 (-y), \u30a5 (-w) and \u31f4 (-n)\nassert latn2kana(\"kay\") == \"\u30ab\u30a4\"\nassert latn2kana(\"kay\", use_small_i=True) == \"\u30ab\u30a3\"\nassert latn2kana(\"kew\") == \"\u30b1\u30a6\"\nassert latn2kana(\"kew\", use_small_u=True) == \"\u30b1\u30a5\"\nassert latn2kana(\"mun\") == \"\u30e0\u30f3\"\nassert latn2kana(\"mun\", use_small_n=True) == \"\u30e0\u31f4\"\n\n# Use \u30f0 (wi), \u30f1 (we) and \u30f2 (wo) \nassert latn2kana(\"wiki\") == \"\u30a6\u30a3\u30ad\"  # for loanwords only\nassert latn2kana(\"wiki\", use_wi=True) == \"\u30f0\u30ad\"\nassert latn2kana(\"weni\") == \"\u30a6\u30a7\u30cb\"\nassert latn2kana(\"weni\", use_we=True) == \"\u30f1\u30cb\"\nassert latn2kana(\"w\u00f3se\") == \"\u30a6\u30a9\u30bb\"\nassert latn2kana(\"w\u00f3se\", use_wo=True) == \"\u30f2\u30bb\"\n\nassert latn2kana(\"wiwewo\") == \"\u30a6\u30a3\u30a6\u30a7\u30a6\u30a9\"\nassert latn2kana(\"wiwewo\", use_wi=True, use_we=True, use_wo=True) == \"\u30f0\u30f1\u30f2\"\n```\n\n\n#### Script Detection\n\nDetect the script of a given string.\n\n```python\nfrom ainconv import detect\n\nprint(detect(\"aynu\")) # \"Latn\"\nprint(detect(\"\u30a2\u30a4\u30cc\")) # \"Kana\"\nprint(detect(\"\u0430\u0439\u043d\u0443\")) # \"Cyrl\"\n```\n\n#### Syllable Splitting\n\n```python\nfrom ainconv import separate\n\nprint(separate(\"eyaykosiramsuypa\")) # [\"e\", \"yay\", \"ko\", \"si\", \"ram\", \"suy\", \"pa\"]\n```\n\n## Support\n\nIf you have a question or have found a bug or any other issue, feel free to [open an issue](https://github.com/mkpoli/ainconv-py/issues/new) to let me know. For instructions on how to contribute, see [CONTRIBUTING.md](https://github.com/mkpoli/ainconv-py/blob/master/CONTRIBUTING.md).\n\nYou can also [join our Discord](https://discord.aynu.org/) for discussion. We have many projects going on about Ainu, so you may find something interesting there as well.\n\n## License\n\n[MIT License](LICENSE) (c) 2024 mkpoli\n\n## See also\n\n* [ainconv - npm](https://www.npmjs.com/package/ainconv): The JavaScript version of this package\n* [ainconv - crates.io](https://crates.io/crates/ainconv): The Rust version of this package\n* [Module:ain-kana-conv - \u30a6\u30a3\u30af\u30b7\u30e7\u30ca\u30ea\u30fc\u65e5\u672c\u8a9e\u7248](https://ja.wiktionary.org/wiki/%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:ain-kana-conv): The original Lua Scribunto module in the Japanese Wiktionary\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Converts Ainu text between different scripts (Katakana, Latin, Cyrillic and more)",
    "version": "0.4.0",
    "project_urls": {
        "Documentation": "https://ainconv-py.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/mkpoli/ainconv",
        "Repository": "https://github.com/mkpoli/ainconv"
    },
    "split_keywords": [
        "ainu",
        "converter",
        "katakana",
        "latin",
        "cyrillic",
        "language",
        "writing system",
        "text preprocessing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d7a5a289e174c1837af755618ecc7f99170d65a811ef5d35a1692711549535d",
                "md5": "a84b2461cf01905f59a5f4468a60e020",
                "sha256": "7a549f37b9ae091fdfe64ac83f23a74b4f041846616583746a2bedd85eb9dcf2"
            },
            "downloads": -1,
            "filename": "ainconv-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a84b2461cf01905f59a5f4468a60e020",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 10029,
            "upload_time": "2024-03-09T13:32:23",
            "upload_time_iso_8601": "2024-03-09T13:32:23.194792Z",
            "url": "https://files.pythonhosted.org/packages/8d/7a/5a289e174c1837af755618ecc7f99170d65a811ef5d35a1692711549535d/ainconv-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9a374af141ddffd5bace2ce88ef4e051b7d84154933f9f64d797ecb262620d6",
                "md5": "7fa435a4cf5e87e0e1d1c7be06da93fd",
                "sha256": "1857af5e613a3d449c7234b8a7ca34614dc8c9c236aba2affa6d25a46642dd70"
            },
            "downloads": -1,
            "filename": "ainconv-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7fa435a4cf5e87e0e1d1c7be06da93fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 11035,
            "upload_time": "2024-03-09T13:32:24",
            "upload_time_iso_8601": "2024-03-09T13:32:24.967631Z",
            "url": "https://files.pythonhosted.org/packages/f9/a3/74af141ddffd5bace2ce88ef4e051b7d84154933f9f64d797ecb262620d6/ainconv-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-09 13:32:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mkpoli",
    "github_project": "ainconv",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ainconv"
}
        
Elapsed time: 0.29175s