Code Monkey home page Code Monkey logo

pylabeador's Introduction

codecov

Pylabeador: Automatic Syllabification of Spanish Words

Install

pip install pylabeador

Use

You can use it as a Python library:

>>> import pylabeador
>>> pylabeador.syllabify("silabear")
['si', 'la', 'be', 'ar']

And you can use it as a command line tool:

$ pylabeador interesante
in-te-re-san-te

Accuracy

Automatic syllabification without additional lexical or and semantic knowledge of the words can only go so far. This syllabifier does not have such knowledge. Because of this, words such as transatlántico, whose correct hyphenation is trans-a-tlán-ti-co or even trans-at-lán-ti-co, end up being divided here into tran-sa-tlán-ti-co. To hyphenate this correctly, it is necessary to know that the word without the prefix exists in Spanish with similar semantics to the one of the original word. This is better and further explained in this paper: Automatic syllabification for Spanish using lemmatization and derivation to solve the prefix’s prominence issue

Inspiration / Original source

This work is inspired by the excellent online tool Silabeador TIP. This tool considers the semantics of the words and correctly separates syllables in the presence of prefixes. They also provide a C++ library that performs the naive syllable separation that pylabeador does. In fact, pyleabeador started as a Python port of that library.

pylabeador's People

Contributors

jdevera avatar jdevera-hj avatar kikocorreoso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kikocorreoso

pylabeador's Issues

Erratic behaviour of the letter 'y'

Hi again,

in the use of this wonderful implementation of your program, I spotted a behavior which someone (depends on who), could consider erratic.

Of course, it is comprehensible that the management of this letter represents a challenge as it arise mostly of foreign terms. Nevertheless, in the cases that I will present here, I believe there is an easy, simple and non-debatable way of syllabify these words, even in the case where the pronunciation is borrowed from other language too.

Note: DRAE stands for Diccionario de la Real Academia Española (some of the terms have an alternative writing adapted to the Spanish language, like bypass (baipás) or curry (curri) ).

First we have the errors raised when the 'y' is in the middle of two consonants:

pylabeador.syllabify('Tytonidae') #Family of birds, could have use Tyto too
Traceback (most recent call last):
...
raise HyphenatorError("Nucleus expects a vowel!", word)
...

pylabeador.syllabify('bypass') #Appears in DRAE
raise HyphenatorError("Nucleus expects a vowel!", word)

pylabeador.syllabify('byroniano') #Appears in DRAE
raise HyphenatorError("Nucleus expects a vowel!", word)

On the other hand we have (this one, I reckon, could use a debate)

pylabeador.syllabify('byte') #Appears in DRAE
raise HyphenatorError("Nucleus expects a vowel!", word)

Yes, but one may think that only one syllable pronounced like 'bait'
(in Spanish), is the correct way to proceed. My personal point of view is that this 'y' should behave like an 'i' and in Spanish, two syllables arises.

Second, its behaviour when proceeded of 'rr':

pylabeador.syllabify('curry') #Appears in DRAE
['cur', 'ry']

Which, I do not know, could be related to...

Third:

pylabeador.syllabify('cónyuge') #Appears in DRAE, very common word
['có', 'nyu', 'ge']

It is interesting that this one, possibly due to the presence of two strong vowels 'oa', works fine since the hyphenation was broken in such a way that it matches a vowel each consonant (d and y):

pylabeador.syllabify('coadyuvar') #Appears in DRAE
['co', 'ad', 'yu', 'var']

I excuse myself for not providing better explanations of the observed behaviour. I hope that this examples could be helpful for you.

Thank you very much for your work,
M.

A little bug regarding a consonant+'ch'

Hello there,

I think that I spotted a bug in the fantastic pylabeador program. I'll write some self-explaining examples below where you can appreciate that it does not manage the 'ch' in the right way if it is preceded by a consonant.

pylabeador.syllabify('jarcha')
['jarc', 'ha']
pylabeador.syllabify('parche')
['parc', 'he']
pylabeador.syllabify('elche')
['elc', 'he']
pylabeador.syllabify('colcha')
['colc', 'ha']
pylabeador.syllabify('deschapar')
['desc', 'ha', 'par']

Again, thank you for your effort and congratulations for such an interesting work.

M

count inconsistency?

When you do the following:

from pylabeador import syllabify_with_details

word = syllabify_with_details("melón")
print(word.accented)
print(word.stressed)

The accented 'counter' starts from 0 and the stressed 'counter' starts from 1.

From a user point of view maybe it has more sense that in both cases the counter starts from one.

If you agree I can prepare a PR fixing this.

Bug when dealing with ''c+consonant"

Hi again, I spotted another bug in the pylabeador program. I'll leave some self-explaining examples below about de management of 'c'+consonant (h seems to work fine).

pylabeador.syllabify('ocre')
['oc', 're']
pylabeador.syllabify('chacra')
['chac', 'ra']
pylabeador.syllabify('Tecla')
['Tec', 'la']
pylabeador.syllabify('aclimatar')
['ac', 'li', 'ma', 'tar']

Thank you very much for your work.
M

Show human readable details of syllabification in the CLI tool

I was thinking in the addition of a new option for the command line. Something like:

$ pylabeador --full torpedo

That provides a more complete output than just ['tor', 'pe', 'do'].

If you agree i can implement this this week and then you can prepare a new release. If you don't like the enhancement just close it and prepare the new release 👍

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.