home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / procs / plural.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  66 lines

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