Source for file Word.php
Documentation is available at Word.php
/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: George Schlossnagle <george@omniti.com> |
// +----------------------------------------------------------------------+
// $Id: Word.php 129208 2003-05-29 16:22:44Z gschlossnagle $
* Text_Word calculates the number of syllables in a word, based off of
* the number of contiguous vowel groupings in the word and applying
* matches to detect special cases.
* require_once 'Text/Word.php'
* $word = new Text_Word('word');
* $word->numSyllables(); // returns 1
* @package Text_Statistics
* @author George Schlossnagle <george@omniti.com>
* The number of syllables. This is internal, the value should be
* accessed through the accessor.
* The special cases of fragments which detect as 1 but should be 2
* @access static protected
* The special cases of fragments which detect as 2 but should be 1
* @access static protected
* Constructs a word by name.
* Helper function, canocalizes the word.
// conanonicalize the word
// trailings e's are almost always silent in English
* Helper function, counts syllable exceptions
// decrement our syllable count for words that contain
// 'silent' syllables, e.g. ely in 'abosultely'
// increment syllable count for certain conjoined vowel
// patterns which produce two syllables e.g.
* Returns the number of syllables. Caches the value in the object.
// cache the value in this object
// Split the word on the vowels. a e i o u, and for us always y
$fragments = preg_split("/[^aeiouy]+/", $scratch);
// remove null elements at the head and tail of
if($fragments && !$fragments[count($fragments) - 1 ]) {
// modify our syllable count for special cases
// now count our syllable
Documentation generated on Mon, 11 Mar 2019 15:36:08 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|