Skip to main content

Scansion tool for Spanish texts

Project description

Scansion tool for Spanish texts

  • Free software: Apache Software License 2.0

Installation

pip install rantanplan

Usage

Install required resources

  1. Install spaCy model language for Spanish:

    python -m spacy download es_core_news_md
    
  2. Install Freeling rules for affixes:

    python -m spacy_affixes download es
    

Import rantanplan

To use rantanplan in a project:

import rantanplan

Usage example

from rantanplan.core import get_scansion

poem = """Me gustas cuando callas porque estás como ausente,
y me oyes desde lejos, y mi voz no te toca.
Parece que los ojos se te hubieran volado
y parece que un beso te cerrara la boca.

Como todas las cosas están llenas de mi alma
emerges de las cosas, llena del alma mía.
Mariposa de sueño, te pareces a mi alma,
y te pareces a la palabra melancolía."""

get_scansion(poem)

Output example

  [{'tokens': [{'word': [{'syllable': 'Me',
    'is_stressed': False,
    'is_word_end': True}],
  'stress_position': 0},
 {'word': [{'syllable': 'gus', 'is_stressed': True},
   {'syllable': 'tas', 'is_stressed': False, 'is_word_end': True}],
  'stress_position': -2},
 {'word': [{'syllable': 'cuan', 'is_stressed': False},
   {'syllable': 'do', 'is_stressed': False, 'is_word_end': True}],
  'stress_position': 0},
 {'word': [{'syllable': 'ca', 'is_stressed': True},
   {'syllable': 'llas', 'is_stressed': False, 'is_word_end': True}],
  'stress_position': -2},
 {'word': [{'syllable': 'por', 'is_stressed': False},
   {'syllable': 'que',
    'is_stressed': False,
    'has_synalepha': True,
    'is_word_end': True}],
  'stress_position': 0},
 {'word': [{'syllable': 'es', 'is_stressed': False},
   {'syllable': 'tás', 'is_stressed': True, 'is_word_end': True}],
  'stress_position': -1},
 {'word': [{'syllable': 'co', 'is_stressed': False},
   {'syllable': 'mo',
    'is_stressed': False,
    'has_synalepha': True,
    'is_word_end': True}],
  'stress_position': 0},
 {'word': [{'syllable': 'au', 'is_stressed': False},
   {'syllable': 'sen', 'is_stressed': True},
   {'syllable': 'te', 'is_stressed': False, 'is_word_end': True}],
  'stress_position': -2},
 {'symbol': ','}],
'phonological_groups': [{'syllable': 'Me',
  'is_stressed': False,
  'is_word_end': True},
 {'syllable': 'gus', 'is_stressed': True},
 {'syllable': 'tas', 'is_stressed': False, 'is_word_end': True},
 {'syllable': 'cuan', 'is_stressed': False},
 {'syllable': 'do', 'is_stressed': False, 'is_word_end': True},
 {'syllable': 'ca', 'is_stressed': True},
 {'syllable': 'llas', 'is_stressed': False, 'is_word_end': True},
 {'syllable': 'por', 'is_stressed': False},
 {'syllable': 'quees', 'is_stressed': False, 'synalepha_index': [2]},
 {'syllable': 'tás', 'is_stressed': True, 'is_word_end': True},
 {'syllable': 'co', 'is_stressed': False},
 {'syllable': 'moau', 'is_stressed': False, 'synalepha_index': [1]},
 {'syllable': 'sen', 'is_stressed': True},
 {'syllable': 'te', 'is_stressed': False, 'is_word_end': True}],
'rhythm': {'stress': '-+---+---+--+-', 'type': 'pattern', 'length': 14}},
 ...

Development

To run the all tests run:

tox

Note, to combine the coverage data from all the tox environments run:

Windows
set PYTEST_ADDOPTS=--cov-append
tox
Other
PYTEST_ADDOPTS=--cov-append tox

Changelog

0.4.2 (2020-03-11)

  • Added documentation

0.4.1 (2019-12-19)

  • Added ‘AUX’ to the split_on list for spacy affixes
  • Fixed syllabification exceptions, support for disabling/enabling spacy_affixes
  • Fixed multiline break
  • Fixed splitted verb stresses and secondary stress on ‘-mente’ adverbs
  • Fixed some issues
  • Added minimum length for ‘-mente’ adverbs

0.4.0 (2019-11-21)

  • Added SpaCy Doc input support
  • Add umlaut hyatus
  • Added new hyatus and fixed init
  • Refactoring code
  • Feat/new syllabification
  • Naming conventions
  • Adding rhyme analaysis to scansion output
  • Adding ‘singleton’ behaviour to load_pipeline
  • Metre analysis w/ sinaeresis and synalephas
  • Added new workflow for syllabification, with tests
  • Post syllabification rules regexes
  • Added unit tests for all functions

0.3.0 (2019-06-18)

  • Added SpaCy Doc input support
  • Add umlaut hyatus
  • Fixed syllabyfication errors, affixes and the pipeline
  • Fixed hyphenator for diphthongs with u umlaut
  • Added hyphenation for explicit hyatus with umlaut vowels
  • Added new hyatus and fixed __init__

0.2.0 (2019-06-14)

  • Better hyphenator, and affixes and pipeline fixes

0.1.2 (2019-06-10)

  • Republishing on Pypi

0.1.0 (2019-07-03)

  • Project name change.

0.0.1 (2019-02-21)

  • First release on PyPI.

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 rantanplan, version 0.5.0
Filename, size File type Python version Upload date Hashes
Filename, size rantanplan-0.5.0.tar.gz (794.7 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