Counting syllables - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Counting syllables

stevetomorrowstevetomorrow Posts: 58Member
How would i go about writing a script that counts syllables?

Comments

  • hicohico Posts: 3Member
    : How would i go about writing a script that counts syllables?
    :

    Ehh, what's "syllables"?
  • stevetomorrowstevetomorrow Posts: 58Member
    : : How would i go about writing a script that counts syllables?
    : :
    :
    : Ehh, what's "syllables"?
    :
    a syllable breaks up words into sections depending on vowls and such. ie: "hello" has 2 syllables. "bright" is 1 syllable. "banana" has 3 syllables, etc.
  • cmario00cmario00 Posts: 12Member
    A recursive function of mine, may have errors

    function findchar($char,$str,$chararray) {
    # returns the positions of a char in a string by recursively saving them in an array.
    # Example: find("t","this is a test to show how it works") would return an array with
    # 4 items where array[0] = 0, array[1] = 10, and so on .... till array[3]
    $newpos = strpos($str, $char);
    if(($newpos != -1) || ($newpos != false)) {
    $chararray[]=$newpos ;
    $newlen = strlen($str) - $newpos + 1;
    return findchar($char, substr($newpos, $newlen), $chararray);
    } else return $chararray ;
    }
Sign In or Register to comment.