spacy-syllables


Namespacy-syllables JSON
Version 3.0.2 PyPI version JSON
download
home_page
Summaryspacy pipeline component for syllables
upload_time2023-03-08 11:19:36
maintainer
docs_urlNone
author
requires_python>=3.7
licenseCopyright 2020 sloev 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 spacy pyphen syllable syllables
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![spacy syllables](https://raw.githubusercontent.com/sloev/spacy-syllables/master/header.jpg)

# Spacy Syllables

![example workflow](https://github.com/sloev/spacy-syllables/actions/workflows/test.yml/badge.svg) [![Latest Version](https://img.shields.io/pypi/v/spacy-syllables.svg)](https://pypi.python.org/pypi/spacy-syllables) [![Python Support](https://img.shields.io/pypi/pyversions/spacy-syllables.svg)](https://pypi.python.org/pypi/spacy-syllables)

<a href="https://www.buymeacoffee.com/sloev" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-pink.png" alt="Buy Me A Coffee" height="51px" width="217px"></a>

A [spacy 2+ pipeline component](https://spacy.io/universe/category/pipeline) for adding multilingual syllable annotation to tokens. 

* Uses well established [pyphen](https://github.com/Kozea/Pyphen) for the syllables.
* Supports [a ton of languages](https://github.com/Kozea/Pyphen/tree/master/pyphen/dictionaries)
* Ease of use thx to the awesome pipeline framework in spacy

## Install

```bash
$ pip install spacy_syllables
```

which also installs the following dependencies:

* spacy = "^2.2.3"
* pyphen = "^0.9.5"

## Usage

The [`SpacySyllables`](spacy_syllables/__init__.py) class autodetects language from the given spacy nlp instance, but you can also override the detected language by specifying the `lang` parameter during instantiation, see how [here](tests/test_all.py).

### Normal usecase

```python

import spacy
from spacy_syllables import SpacySyllables

nlp = spacy.load("en_core_web_sm")

nlp.add_pipe("syllables", after="tagger")

assert nlp.pipe_names == ["tok2vec", "tagger", "syllables", "parser", "ner", "attribute_ruler", "lemmatizer"]

doc = nlp("terribly long")

data = [(token.text, token._.syllables, token._.syllables_count) for token in doc]

assert data == [("terribly", ["ter", "ri", "bly"], 3), ("long", ["long"], 1)]

```

more examples in [tests](tests/test_all.py)

## Migrating from spacy 2.x to 3.0

In spacy 2.x, spacy_syllables was originally added to the pipeline by instantiating a [`SpacySyllables`](spacy_syllables/__init__.py) object with the desired options and adding it to the pipeline: 

```python
from spacy_syllables import SpacySyllables

syllables = SpacySyllables(nlp, "en_US")

nlp.add_pipe(syllables, after="tagger")
```

In spacy 3.0, you now add the component to the pipeline simply by adding it by name, setting custom configuration information in the `add_pipe()` parameters:
```python
from spacy_syllables import SpacySyllables

nlp.add_pipe("syllables", after="tagger", config={"lang": "en_US"})
```



In addition, the default pipeline components have changed between 2.x and 3.0; please make sure to update any asserts you have that check for these.
e.g.:

spacy 2.x:
```python
assert nlp.pipe_names == ["tagger", "syllables", "parser", "ner"]
```

spacy 3.0:
```python
assert nlp.pipe_names == ["tok2vec", "tagger", "syllables", "parser", "ner", "attribute_ruler", "lemmatizer"]
```

## Dev setup / testing

### install

install the dev package and pyenv versions

```bash
$ pip install -e ".[dev]"
$ python -m spacy download en_core_web_sm
```

### run tests

```bash
$ black .
$ pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "spacy-syllables",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "spacy,pyphen,syllable,syllables",
    "author": "",
    "author_email": "sloev <johannes.valbjorn@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/15/9a/b94b12188ef0a08e5b87ab95f2f4018365ade7ff36ba22496e6af1c98b21/spacy_syllables-3.0.2.tar.gz",
    "platform": null,
    "description": "![spacy syllables](https://raw.githubusercontent.com/sloev/spacy-syllables/master/header.jpg)\n\n# Spacy Syllables\n\n![example workflow](https://github.com/sloev/spacy-syllables/actions/workflows/test.yml/badge.svg) [![Latest Version](https://img.shields.io/pypi/v/spacy-syllables.svg)](https://pypi.python.org/pypi/spacy-syllables) [![Python Support](https://img.shields.io/pypi/pyversions/spacy-syllables.svg)](https://pypi.python.org/pypi/spacy-syllables)\n\n<a href=\"https://www.buymeacoffee.com/sloev\" target=\"_blank\"><img src=\"https://cdn.buymeacoffee.com/buttons/default-pink.png\" alt=\"Buy Me A Coffee\" height=\"51px\" width=\"217px\"></a>\n\nA [spacy 2+ pipeline component](https://spacy.io/universe/category/pipeline) for adding multilingual syllable annotation to tokens. \n\n* Uses well established [pyphen](https://github.com/Kozea/Pyphen) for the syllables.\n* Supports [a ton of languages](https://github.com/Kozea/Pyphen/tree/master/pyphen/dictionaries)\n* Ease of use thx to the awesome pipeline framework in spacy\n\n## Install\n\n```bash\n$ pip install spacy_syllables\n```\n\nwhich also installs the following dependencies:\n\n* spacy = \"^2.2.3\"\n* pyphen = \"^0.9.5\"\n\n## Usage\n\nThe [`SpacySyllables`](spacy_syllables/__init__.py) class autodetects language from the given spacy nlp instance, but you can also override the detected language by specifying the `lang` parameter during instantiation, see how [here](tests/test_all.py).\n\n### Normal usecase\n\n```python\n\nimport spacy\nfrom spacy_syllables import SpacySyllables\n\nnlp = spacy.load(\"en_core_web_sm\")\n\nnlp.add_pipe(\"syllables\", after=\"tagger\")\n\nassert nlp.pipe_names == [\"tok2vec\", \"tagger\", \"syllables\", \"parser\", \"ner\", \"attribute_ruler\", \"lemmatizer\"]\n\ndoc = nlp(\"terribly long\")\n\ndata = [(token.text, token._.syllables, token._.syllables_count) for token in doc]\n\nassert data == [(\"terribly\", [\"ter\", \"ri\", \"bly\"], 3), (\"long\", [\"long\"], 1)]\n\n```\n\nmore examples in [tests](tests/test_all.py)\n\n## Migrating from spacy 2.x to 3.0\n\nIn spacy 2.x, spacy_syllables was originally added to the pipeline by instantiating a [`SpacySyllables`](spacy_syllables/__init__.py) object with the desired options and adding it to the pipeline: \n\n```python\nfrom spacy_syllables import SpacySyllables\n\nsyllables = SpacySyllables(nlp, \"en_US\")\n\nnlp.add_pipe(syllables, after=\"tagger\")\n```\n\nIn spacy 3.0, you now add the component to the pipeline simply by adding it by name, setting custom configuration information in the `add_pipe()` parameters:\n```python\nfrom spacy_syllables import SpacySyllables\n\nnlp.add_pipe(\"syllables\", after=\"tagger\", config={\"lang\": \"en_US\"})\n```\n\n\n\nIn addition, the default pipeline components have changed between 2.x and 3.0; please make sure to update any asserts you have that check for these.\ne.g.:\n\nspacy 2.x:\n```python\nassert nlp.pipe_names == [\"tagger\", \"syllables\", \"parser\", \"ner\"]\n```\n\nspacy 3.0:\n```python\nassert nlp.pipe_names == [\"tok2vec\", \"tagger\", \"syllables\", \"parser\", \"ner\", \"attribute_ruler\", \"lemmatizer\"]\n```\n\n## Dev setup / testing\n\n### install\n\ninstall the dev package and pyenv versions\n\n```bash\n$ pip install -e \".[dev]\"\n$ python -m spacy download en_core_web_sm\n```\n\n### run tests\n\n```bash\n$ black .\n$ pytest\n```\n",
    "bugtrack_url": null,
    "license": "Copyright 2020 sloev  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": "spacy pipeline component for syllables",
    "version": "3.0.2",
    "project_urls": {
        "Homepage": "https://github.com/sloev/spacy-syllables"
    },
    "split_keywords": [
        "spacy",
        "pyphen",
        "syllable",
        "syllables"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bcc0412775c4db008df8f5d3887e0d96fa4d14306b9ba8ae257c21aa98a3ec4b",
                "md5": "f8f406cb85c4ceaf2897574e8769d6c7",
                "sha256": "0c67cfc086624c643f510bb05c53c93c323de4357761b500ce8d9e48942618ed"
            },
            "downloads": -1,
            "filename": "spacy_syllables-3.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f8f406cb85c4ceaf2897574e8769d6c7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5066,
            "upload_time": "2023-03-08T11:19:34",
            "upload_time_iso_8601": "2023-03-08T11:19:34.754963Z",
            "url": "https://files.pythonhosted.org/packages/bc/c0/412775c4db008df8f5d3887e0d96fa4d14306b9ba8ae257c21aa98a3ec4b/spacy_syllables-3.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "159ab94b12188ef0a08e5b87ab95f2f4018365ade7ff36ba22496e6af1c98b21",
                "md5": "ea123b4bd0d59ccc906b3d2fc1714d8e",
                "sha256": "1f45a8307382daa0c65d32a996d84bd5dd90552f42e675f721342c35ba3d032b"
            },
            "downloads": -1,
            "filename": "spacy_syllables-3.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ea123b4bd0d59ccc906b3d2fc1714d8e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4673,
            "upload_time": "2023-03-08T11:19:36",
            "upload_time_iso_8601": "2023-03-08T11:19:36.967976Z",
            "url": "https://files.pythonhosted.org/packages/15/9a/b94b12188ef0a08e5b87ab95f2f4018365ade7ff36ba22496e6af1c98b21/spacy_syllables-3.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-08 11:19:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sloev",
    "github_project": "spacy-syllables",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "spacy-syllables"
}
        
Elapsed time: 0.26735s