Version 9 of English plurals

Updated 2001-12-04 21:35:55

Richard Suchenwirth - Peter Lewerin needed one for Tcl-PLEAC (see BOOK Programming Language Examples Alike Cookbook), so here goes (never written that may returns in my Tcl life ;-):

 proc en:pl word {
    switch -- $word {
        man   {return men}
        foot  {return feet}
        goose {return geese}
        louse {return lice}
        mouse {return mice}
        ox    {return oxen}
        tooth {return teeth}
        calf - elf - half - hoof - leaf - loaf - scarf
        - self - sheaf - thief - wolf 
              {return [string range $word 0 end-1]ves}
        knife - life - wife 
              {return [string range $word 0 end-2]ves}
        auto - kangaroo - kilo - memo 
        - photo - piano - pimento - pro - solo - soprano - studio
        - tattoo - video - zoo 
              {return ${word}s}
        cod - deer - fish - offspring - perch - sheep - trout 
              {return $word}
    }
    switch -regexp -- $word {
      {[ei]x$}                  {return [string range $word 0 end-2]ices}
      {[sc]h$} - {[soxz]$}      {return ${word}es}
      {[bcdfghjklmnprstvwxz]y$} {return [string range $word 0 end-1]ies}
      {child$}                  {return ${word}ren}
      {woman$}                  {return [string range $word 0 end-2]en}
    }
    return ${word}s
 }

No warranty, but enjoy, and feel free to improve!


English number reader - Arts and crafts of Tcl-Tk programming