Skip to main content

Multilingual syllable annotation pipeline component for spacy

Project description

spacy syllables

Spacy Syllables

Build Status Latest Version Python Support

A spacy 2+ pipeline component for adding multilingual syllable annotation to tokens.

  • Uses well established pyphen for the syllables.
  • Supports a ton of languages
  • Ease of use thx to the awesome pipeline framework in spacy

Install

$ pip install spacy_syllables

which also installs the following dependencies:

  • spacy = "^2.2.3"
  • pyphen = "^0.9.5"

Usage

The SpacySyllables 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.

Normal usecase

import spacy
from spacy_syllables import SpacySyllables

nlp = spacy.load("en_core_web_sm")

syllables = SpacySyllables(nlp)

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

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

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

Dev setup / testing

we are using

  • poetry for the package
  • nox for the tests
  • pyenv for specifying python versions for nox tests

install

then install the dev package and pyenv versions

$ poetry install
$ poetry run nox --session install_pyenv_versions

run tests

$ poetry run nox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for spacy-syllables, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size spacy_syllables-1.0.0-py3-none-any.whl (5.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size spacy_syllables-1.0.0.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page