home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / PLURAL.ICN < prev    next >
Text File  |  1991-09-05  |  2KB  |  61 lines

  1. ############################################################################
  2. #
  3. #    Name:    plural.icn
  4. #
  5. #    Title:    Produce plural of English noun
  6. #
  7. #    Author:    Ralph E. Griswold
  8. #
  9. #    Date:    September 2, 1991
  10. #
  11. ############################################################################
  12. #
  13. #     This procedure produces the plural form of a singular English noun.
  14. #  The procedure here is rudimentary and does not work in all cases.
  15. #
  16. ############################################################################
  17.  
  18. procedure plural(word)
  19.    local lcword
  20.    static plural_map, plural_id, plural_s
  21.  
  22.    initial {
  23.       plural_map := table()
  24.       plural_map["mouse"] := "mice"
  25.       plural_map["louse"] := "lice"
  26.       plural_map["goose"] := "geese"
  27.       plural_map["datum"] := "data"
  28.  
  29.       plural_id := set()
  30.       every insert(plural_id,"chassis" | "fish" | "sheep" | "semantics")
  31.  
  32.       plural_s := set()
  33.       every insert(plural_s,"roman" | "norman" | "human" | "shaman" |
  34.          "german" | "talisman" | "superhuman")
  35.       }
  36.    
  37.    lcword := map(word)
  38.  
  39.    if member(plural_id,lcword) then return word
  40.  
  41.    if member(plural_s,lcword) then return word || "s"
  42.  
  43.    (lcword := \plural_map[lcword]) | {
  44.       lcword ?:= {
  45.          (tab(-3) || (match("man") & "men")) |
  46.          (tab(-3) || (match("sis") & "ses")) |
  47.          (tab(-2) || =("ch" | "sh" | "ss") || "es") |
  48.          (tab(-2) || tab(any('cbdghmnprstvxz')) || (match("y") & "ies")) |
  49.          (tab(-1) || tab(any('xz')) || "es") |
  50.          (tab(0) || "s")
  51.          }
  52.       }
  53.  
  54.    if word ? any(&ucase) then lcword ?:= {
  55.       map(move(1),&lcase,&ucase) || tab(0)
  56.       }
  57.  
  58.    return lcword
  59.          
  60. end
  61.