tonkinese-grid


Nametonkinese-grid JSON
Version 2024.0.0a5 PyPI version JSON
download
home_pageNone
SummaryA python library to read and write a subset of TextGrid file format
upload_time2024-12-19 15:56:47
maintainerNone
docs_urlNone
authorRibosomeK
requires_python>=3.9
licenseCopyright (c) <2024> <RibosomeK> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords textgrid
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TonkineseGrid for TextGrid file format

This is a python library that can read and write a **subset** of [TextGrid file format](https://www.fon.hum.uva.nl/praat/manual/TextGrid_file_formats.html), with full type hint, and some extra methods to manipulate intervals. 

**Notice that this library does not support read file that contains TextTier class. Also this a side project has no full test of the codebase, therefore it is not production ready. Please use it at your own risk**

## Updates

- 2024-10-19 short format and utf-16 encoding is supported in both reading and saving

- 2024-11-05 
    - add better error messages while reading TextGrid files
    - add two methods in `IntervalTier`, `extend()` and `extend_from()`
    - add `format` parameter in `TextGrid.read()` to specify whether it is `full` or `short` format.

- 2024-12-19
    - "rename" `__repr__()` to `to_short_str()` in class `TextGrid`

## Basic Usage

Get started with installing the package (>=python3.9).

```bash
pip install tonkinese_grid
```

Then you can use it like the following.

```python
from tonkinese_grid import TextGrid

textgrid = TextGrid.read("file.TextGrid")
for items in textgrid:
    for interval in items:
        print(interval)

new = TextGrid(0, 2.5)
new.append_new(0, 2.5, "words")
new[0].append_new(0, 1, "hello")
new[0].append_new(1, 2.5, "world")
new.save("HelloWorld.TextGrid")
```

## Classes And Methods

This section list basic information about the classes and their methods. For more details, please read the source code

```python
class Interval:
    min: float
    max: float
    text: str
    @staticmethod
    def is_continuous(prev: "Interval", curr: "Interval") -> bool:

class IntervalList:
    """a wrapper of list of intervals, which makes sure intervals inside of it
    is continuous and provide some other useful methods."""
    def __getitem__(self, idx: int) -> Interval: ...
    def __iter__(self) -> Iterator[Interval]: ...
    def __len__(self) -> int: ...
    def size(self) -> int: ...
    def slice(
        self,
        start: Optional[int] = None,
        stop: Optional[int] = None,
        step: Optional[int] = None,
    ) -> IntervalList: ...
    def clear(self) -> None: ...
    def copy(self) -> IntervalList: ...
    def append(self, interval: Interval) -> None: ...
    def append_new(self, min: float, max: float, text: str) -> None: ...
    def extend(self, intervals: IntervalList) -> None: ...
    def extend_from(self, intervals: list[Interval]) -> None: ...
    def replace(self, idx: int, text: str) -> None: ...
    def move_offset(self, idx: int, offset: float) -> None: ...
    def move_offset_by_dur(self, idx: int, dur: float) -> None: ...
    def split_insert(self, idx: int, text: str, dur: float) -> None: ...
    def split_append(self, idx: int, text: str, dur: float) -> None: ...
    def merge(self, start: int, end: int, text: str) -> None: ...

class IntervalTier:
    """Has the same methods with IntervalList"""
    min: float
    max: float
    name: str
    intervals: IntervalList

class TextGrid:
    min: float
    max: float
    items: list[IntervalTier]
    def __iter__(self) -> Iterator[IntervalTier]: ...
    def __str__(self) -> str: ...
    def to_short_str(self) -> str: ...
    def __getitem__(self, idx: int) -> IntervalTier: ...
    def __setitem__(self, idx: int, tier: IntervalTier) -> None: ...
    @classmethod
    def read(cls, file: str, format: str="full", encoding: str="utf-8") -> "TextGrid": ...
    def size(self) -> int: ...
    def copy(self) -> "TextGrid": ...
    def save(self, path: str, format: str="full", encoding: str="utf-8") -> None: ...
    def append_new(self, min: float, max: float, name: str) -> None: ...
    def append(self, intervals: IntervalTier) -> None: ...
```

## Credit

[textgrid](https://github.com/kylebgorman/textgrid)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tonkinese-grid",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "TextGrid",
    "author": "RibosomeK",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/0f/fd/276d32b4961f875c7054319935c7ceabd1e66dbdb1baab7daf4854390ea6/tonkinese_grid-2024.0.0a5.tar.gz",
    "platform": null,
    "description": "# TonkineseGrid for TextGrid file format\n\nThis is a python library that can read and write a **subset** of [TextGrid file format](https://www.fon.hum.uva.nl/praat/manual/TextGrid_file_formats.html), with full type hint, and some extra methods to manipulate intervals. \n\n**Notice that this library does not support read file that contains TextTier class. Also this a side project has no full test of the codebase, therefore it is not production ready. Please use it at your own risk**\n\n## Updates\n\n- 2024-10-19 short format and utf-16 encoding is supported in both reading and saving\n\n- 2024-11-05 \n    - add better error messages while reading TextGrid files\n    - add two methods in `IntervalTier`, `extend()` and `extend_from()`\n    - add `format` parameter in `TextGrid.read()` to specify whether it is `full` or `short` format.\n\n- 2024-12-19\n    - \"rename\" `__repr__()` to `to_short_str()` in class `TextGrid`\n\n## Basic Usage\n\nGet started with installing the package (>=python3.9).\n\n```bash\npip install tonkinese_grid\n```\n\nThen you can use it like the following.\n\n```python\nfrom tonkinese_grid import TextGrid\n\ntextgrid = TextGrid.read(\"file.TextGrid\")\nfor items in textgrid:\n    for interval in items:\n        print(interval)\n\nnew = TextGrid(0, 2.5)\nnew.append_new(0, 2.5, \"words\")\nnew[0].append_new(0, 1, \"hello\")\nnew[0].append_new(1, 2.5, \"world\")\nnew.save(\"HelloWorld.TextGrid\")\n```\n\n## Classes And Methods\n\nThis section list basic information about the classes and their methods. For more details, please read the source code\n\n```python\nclass Interval:\n    min: float\n    max: float\n    text: str\n    @staticmethod\n    def is_continuous(prev: \"Interval\", curr: \"Interval\") -> bool:\n\nclass IntervalList:\n    \"\"\"a wrapper of list of intervals, which makes sure intervals inside of it\n    is continuous and provide some other useful methods.\"\"\"\n    def __getitem__(self, idx: int) -> Interval: ...\n    def __iter__(self) -> Iterator[Interval]: ...\n    def __len__(self) -> int: ...\n    def size(self) -> int: ...\n    def slice(\n        self,\n        start: Optional[int] = None,\n        stop: Optional[int] = None,\n        step: Optional[int] = None,\n    ) -> IntervalList: ...\n    def clear(self) -> None: ...\n    def copy(self) -> IntervalList: ...\n    def append(self, interval: Interval) -> None: ...\n    def append_new(self, min: float, max: float, text: str) -> None: ...\n    def extend(self, intervals: IntervalList) -> None: ...\n    def extend_from(self, intervals: list[Interval]) -> None: ...\n    def replace(self, idx: int, text: str) -> None: ...\n    def move_offset(self, idx: int, offset: float) -> None: ...\n    def move_offset_by_dur(self, idx: int, dur: float) -> None: ...\n    def split_insert(self, idx: int, text: str, dur: float) -> None: ...\n    def split_append(self, idx: int, text: str, dur: float) -> None: ...\n    def merge(self, start: int, end: int, text: str) -> None: ...\n\nclass IntervalTier:\n    \"\"\"Has the same methods with IntervalList\"\"\"\n    min: float\n    max: float\n    name: str\n    intervals: IntervalList\n\nclass TextGrid:\n    min: float\n    max: float\n    items: list[IntervalTier]\n    def __iter__(self) -> Iterator[IntervalTier]: ...\n    def __str__(self) -> str: ...\n    def to_short_str(self) -> str: ...\n    def __getitem__(self, idx: int) -> IntervalTier: ...\n    def __setitem__(self, idx: int, tier: IntervalTier) -> None: ...\n    @classmethod\n    def read(cls, file: str, format: str=\"full\", encoding: str=\"utf-8\") -> \"TextGrid\": ...\n    def size(self) -> int: ...\n    def copy(self) -> \"TextGrid\": ...\n    def save(self, path: str, format: str=\"full\", encoding: str=\"utf-8\") -> None: ...\n    def append_new(self, min: float, max: float, name: str) -> None: ...\n    def append(self, intervals: IntervalTier) -> None: ...\n```\n\n## Credit\n\n[textgrid](https://github.com/kylebgorman/textgrid)\n",
    "bugtrack_url": null,
    "license": "Copyright (c) <2024> <RibosomeK>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A python library to read and write a subset of TextGrid file format",
    "version": "2024.0.0a5",
    "project_urls": null,
    "split_keywords": [
        "textgrid"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "34a86020d9802363f5e11a3feb4b88b55e8c27a604e2e52cc04d5f269c229e38",
                "md5": "135f7a49995300cd1b1d52f816680f45",
                "sha256": "f750e0e231b1a9120f07ec5e53f98040fddee6ada13788dff879b2eff4bcb29d"
            },
            "downloads": -1,
            "filename": "tonkinese_grid-2024.0.0a5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "135f7a49995300cd1b1d52f816680f45",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 9173,
            "upload_time": "2024-12-19T15:56:46",
            "upload_time_iso_8601": "2024-12-19T15:56:46.561236Z",
            "url": "https://files.pythonhosted.org/packages/34/a8/6020d9802363f5e11a3feb4b88b55e8c27a604e2e52cc04d5f269c229e38/tonkinese_grid-2024.0.0a5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ffd276d32b4961f875c7054319935c7ceabd1e66dbdb1baab7daf4854390ea6",
                "md5": "4fbc6133211e7e4597ba448eb10717be",
                "sha256": "f696008caeef9cd31d2018dd9c4db0e4debb1c7d2f6ee21966296cc7f47d9710"
            },
            "downloads": -1,
            "filename": "tonkinese_grid-2024.0.0a5.tar.gz",
            "has_sig": false,
            "md5_digest": "4fbc6133211e7e4597ba448eb10717be",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 8643,
            "upload_time": "2024-12-19T15:56:47",
            "upload_time_iso_8601": "2024-12-19T15:56:47.867155Z",
            "url": "https://files.pythonhosted.org/packages/0f/fd/276d32b4961f875c7054319935c7ceabd1e66dbdb1baab7daf4854390ea6/tonkinese_grid-2024.0.0a5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-19 15:56:47",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "tonkinese-grid"
}
        
Elapsed time: 0.37765s