def pluralize(word, pos=NOUN, custom={}, classical=True):
 if (word in custom):
  return custom[word]
 if word.endswith(("'", "'s")):
  w = word.rstrip("'s")
  w = pluralize(w, pos, custom, classical)
  if w.endswith('s'):
   return (w + "'")
  else:
   return (w + "'s")
 w = word.replace('-', ' ').split(' ')
 if (len(w) > 1):
  if ((w[1] == 'general') or ((w[1] == 'General') and (w[0] not in plural_categories['general-generals']))):
   return word.replace(w[0], pluralize(w[0], pos, custom, classical))
  elif (w[1] in plural_prepositions):
   return word.replace(w[0], pluralize(w[0], pos, custom, classical))
  else:
   return word.replace(w[(-1)], pluralize(w[(-1)], pos, custom, classical))
 n = range(len(plural_rules))
 if pos.startswith(ADJECTIVE):
  n = [0, 1]
 for i in n:
  for (suffix, inflection, category, classic) in plural_rules[i]:
   if (category is None):
    if ((not classic) or (classic and classical)):
     if (suffix.search(word) is not None):
      return suffix.sub(inflection, word)
   if (category is not None):
    if ((word in plural_categories[category]) and ((not classic) or (classic and classical))):
     if (suffix.search(word) is not None):
      return suffix.sub(inflection, word)
 return word

def pluralize ( word , pos = NOUN , custom = { } , classical = True ) : if ( word in custom ) : return custom [ word ] if word . endswith ( ( "'" , "'s" ) ) : w = word . rstrip ( "'s" ) w = pluralize ( w , pos , custom , classical ) if w . endswith ( 's' ) : return ( w + "'" ) else : return ( w + "'s" ) w = word . replace ( '-' , ' ' ) . split ( ' ' ) if ( len ( w ) > 1 ) : if ( ( w [ 1 ] == 'general' ) or ( ( w [ 1 ] == 'General' ) and ( w [ 0 ] not in plural_categories [ 'general-generals' ] ) ) ) : return word . replace ( w [ 0 ] , pluralize ( w [ 0 ] , pos , custom , classical ) ) elif ( w [ 1 ] in plural_prepositions ) : return word . replace ( w [ 0 ] , pluralize ( w [ 0 ] , pos , custom , classical ) ) else : return word . replace ( w [ ( - 1 ) ] , pluralize ( w [ ( - 1 ) ] , pos , custom , classical ) ) n = range ( len ( plural_rules ) ) if pos . startswith ( ADJECTIVE ) : n = [ 0 , 1 ] for i in n : for ( suffix , inflection , category , classic ) in plural_rules [ i ] : if ( category is None ) : if ( ( not classic ) or ( classic and classical ) ) : if ( suffix . search ( word ) is not None ) : return suffix . sub ( inflection , word ) if ( category is not None ) : if ( ( word in plural_categories [ category ] ) and ( ( not classic ) or ( classic and classical ) ) ) : if ( suffix . search ( word ) is not None ) : return suffix . sub ( inflection , word ) return word
pluralize term when n is greater than one .