"""Pluralize English nouns (stage 6)This program is part of "Dive Into Python", a free Python book forexperienced programmers. Visit http://diveintopython.org/ for thelatest version.Command line usage:$ python plural6.py nounnouns"""__author__="Mark Pilgrim (mark@diveintopython.org)"__version__="$Revision: 1.7 $"__date__="$Date: 2004/05/03 19:40:42 $"__copyright__="Copyright (c) 2004 Mark Pilgrim"__license__="Python"importredefrules(language):forlineinfile('plural-rules.%s'%language):pattern,search,replace=line.split()yieldlambdaword:re.search(pattern,word)andre.sub(search,replace,word)defplural(noun,language='en'):"""returns the plural form of a noun"""forapplyRuleinrules(language):result=applyRule(noun)ifresult:returnresultif__name__=='__main__':importsysifsys.argv[1:]:printplural(sys.argv[1])else:print__doc__