public function singularize($word)
{
// Get the cached noun of it exists
if (isset($this->cache['singularized'][$word])) {
return $this->cache['singularized'][$word];
}
// Check if the noun is already in singular form, i.e. in the pluralized cache
if (isset($this->cache['pluralized'][$word])) {
return $word;
}
// Create the singular noun
if (in_array($word, $this->rules['uncountable'])) {
$_cache['singularized'][$word] = $word;
return $word;
}
foreach ($this->rules['singularization'] as $regexp => $replacement) {
$matches = null;
$singular = preg_replace($regexp, $replacement, $word, -1, $matches);
if ($matches > 0) {
$_cache['singularized'][$word] = $singular;
return $singular;
}
}
return $word;
}