Coder Social home page Coder Social logo

syllabifier's Introduction

Syllabifier

Count the number of syllables in arbitrary English words

Adapted from this repository with some major changes:

  • Ported to Python 3 and rewrote much of the code in a more Pythonic style
  • Made a few relatively minor corrections to the syllabification rules, following "English Words: A Linguistic Introduction" by Heidi Harley (Blackwell Publishing).
  • Removed ambisyllabicity rules for onset and coda

Please see Anthony Evans' README file for a detailed background to the project.

Set up

  • Requires Python 3
  • Clone this repo. No further installation required.

Usage

One word at a time:

python3 syllable3.py linguistics

Or several (space-separated):

python3 syllable3.py colourless green ideas

If using as a library, and you just need the syllable count of a word, use the num_syllables(word: str) function instead.

Output

If the input word is found in the dictionary, a phonemic, syllabified transcript is returned. For example, for the word linguistics:

linguistics: 3 syllables: <o:L|n:IH|c:NG> <o:GW|n:IH|c:None> <o:ST|n:IH|c:KS>

Each syllable is made up of an 'o' onset, 'n' nucleus, and 'c' coda. Phonemes capitalized in ARPAbet format. In line with phonological theory, the nucleus must have content, whereas the onset and coda may be empty.

CMU Pronouncing Dictionary

Syllabify depends on the CMU Pronouncing Dictionary of North American English word pronunciations. Version 0.7b was the current one at time of writing, but it throws a UnicodeDecodeError, so we're still using version 0.7a (amended to remove erroneous 'G' from SUGGEST and related words). Please see the dictionary download website to obtain the current version, add the cmudict-N.nx(.phones|.symbols)* files to the CMU_dictionary directory, remove the '.txt' suffixes, and update the line VERSION = 'cmudict-n.nx' in cmuparser3.py

syllabifier's People

Contributors

anson-vandoren avatar

Stargazers

 avatar Johannah O'Mahony avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

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.