Friday, August 17, 2012

Cameron McKay: Counting Syllables and Detecting Rhyme in PHP

Cameron McKay: Counting Syllables and Detecting Rhyme in PHP:
In this new post to his site, Cameron McKay has posted a bit of interesting code - functionality that detects the number of syllables in words and checks for rhyming in phrases.

The simplicity of the rules got me thinking: how hard would it be to write a program to check if a poem stanza is ottava rima? In this article, we will write a simple ottava rima detector in PHP.
His code takes in the content and performs a few checks, one simple (length) and two custom - "is_iambic_pentameter" and "is_abababcc_rhyme". The code for these two checks are included in the post as well that, in turn, use some other functions to count syllables and vowels and use Arpabet phonetic transcription and monophthongs/diphthongs to detect iambic pentameter and rhyme.


DIGITAL JUICE

No comments:

Post a Comment

Thank's!