;;; fixed typo in retrieving superlativeform property - Jon 22/02/96

#-kpml (DEFUN Generate-Inflected-Word (&OPTIONAL Spelling Ending-Type Properties Inflected-Form &REST IGNORE)
  (PROG ((stem Spelling)
	 (stem-minus-last-letter (subseq Spelling 0 (- (length spelling) 1)))
	 (last-letter (subseq Spelling (- (length spelling) 1) (length spelling)))
	 (next-to-last-letter (subseq Spelling (- (length spelling) 2) (- (length spelling) 1)))
	 (possible-inflected-forms '(Pluralform Comparativeform Superlativeform Pastform 
						Edparticipleform Ingparticipleform 
						Firstsingularform Secondsingularform 
						Thirdsingularform Verbpluralform 
						Firstsingularpastform Secondsingularpastform 
						Thirdsingularpastform Pluralpastform))
	 (possible-ending-types '(Es-ed S-*ed S-ed S-d *-Irr S-irr Es-irr Irr Er-est R-st *Er-*est 
					Es S))
	 (inflected-spelling NIL))
	(cond
	  ((Not (And (Stringp Spelling)
		     (symbolp Ending-Type)
		     (member Ending-Type possible-ending-types)
		     (Or (Not Properties)
			 (value-if-listp Properties))
		     (Or (Not Inflected-Form)
			 (And (symbolp Inflected-Form)
			      (member Inflected-Form possible-inflected-forms)))))
	   (Warning "Invalid inflection information, unable to generate word inflection")
	   (break "Invalid inflection information, unable to generate word inflection")
	   (RETURN NIL)))
	(cond
	  ((And (Equal Ending-Type 'Es-ed)
		(Not (member next-to-last-letter '("a" "o" "u" "e")))
		(Equal last-letter "y"))
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT 
									      stem-minus-last-letter 
									      "ies")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem-minus-last-letter "ied")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem-minus-last-letter "ied")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Es-ed)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "es")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem "ed")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem "ed")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S-*ed)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem last-letter "ed")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem last-letter "ed")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem last-letter "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S-ed)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem "ed")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem "ed")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S-d)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem "d")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem "d")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem-minus-last-letter "ing"))
				    )
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type '*-Irr)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem last-letter "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((And (Equal Ending-Type 'S-irr)
		(Equal last-letter "e"))
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem-minus-last-letter "ing"))
				    )
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S-irr)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((And (Equal Ending-Type 'Es-irr)
		(Not (member next-to-last-letter '("a" "o" "u" "e")))
		(Equal last-letter "y"))
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT 
									      stem-minus-last-letter 
									      "ies")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Es-irr)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "es")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Irr)
	   (Case Inflected-Form (Firstsingularform (SETQ inflected-spelling (
									     Get-Lexical-Property-Value 'Firstsingularform
									     Properties)))
		 (Secondsingularform (SETQ inflected-spelling (Get-Lexical-Property-Value
								'Secondsingularform
								Properties)))
		 (Thirdsingularform (SETQ inflected-spelling (Get-Lexical-Property-Value
							       'Thirdsingularform
							       Properties)))
		 (Pluralform (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pluralform
										  Properties)))
		 (Firstsingularpastform (SETQ inflected-spelling (Get-Lexical-Property-Value
								   'Firstsingularpastform
								   Properties)))
		 (Secondsingularpastform (SETQ inflected-spelling (Get-Lexical-Property-Value
								    'Secondsingularpastform
								    Properties)))
		 (Thirdsingularpastform (SETQ inflected-spelling (Get-Lexical-Property-Value
								   'Thirdsingularpastform
								   Properties)))
		 (Pluralpastform (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pluralpastform
										      Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							       'Ingparticipleform
							       Properties)))
		 (pastform (SETQ inflected-spelling (Get-Lexical-Property-Value
							       'pastform
							       Properties)))
		 (comparativeform
		  (setq inflected-spelling
		    (Get-Lexical-Property-Value 'comparativeform Properties)))
		 (superlativeform
		  (setq inflected-spelling
		    (Get-Lexical-Property-Value 'superlativeform Properties)))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((And (Equal Ending-Type 'Er-est)
		(Not (member next-to-last-letter '("a" "o" "u" "e")))
		(Equal last-letter "y"))
	   (Case Inflected-Form (Comparativeform (SETQ inflected-spelling (CONCAT 
									    stem-minus-last-letter 
									    "ier")))
		 (Superlativeform (SETQ inflected-spelling (CONCAT stem-minus-last-letter "iest")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Er-est)
	   (Case Inflected-Form (Comparativeform (SETQ inflected-spelling (CONCAT stem "er")))
		 (Superlativeform (SETQ inflected-spelling (CONCAT stem "est")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'R-st)
	   (Case Inflected-Form (Comparativeform (SETQ inflected-spelling (CONCAT stem "r")))
		 (Superlativeform (SETQ inflected-spelling (CONCAT stem "st")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type '*Er-*est)
	   (Case Inflected-Form (Comparativeform (SETQ inflected-spelling (CONCAT stem last-letter 
										  "er")))
		 (Superlativeform (SETQ inflected-spelling (CONCAT stem last-letter "est")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((And (Equal Ending-Type 'Es)
		(Not (member next-to-last-letter '("a" "o" "u" "e")))
		(Equal last-letter "y"))
	   (Case Inflected-Form (Pluralform (SETQ inflected-spelling (CONCAT stem-minus-last-letter 
									     "ies")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Es)
	   (Case Inflected-Form (Pluralform (SETQ inflected-spelling (CONCAT stem "es")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S)
	   (Case Inflected-Form (Pluralform (SETQ inflected-spelling (CONCAT stem "s")))
		 (otherwise (SETQ inflected-spelling stem)))))
	(RETURN  inflected-spelling )))


#+kpml (defun GENERATE-INFLECTED-ENGLISH-WORD (Spelling Ending-type Properties Inflected-form)
  (PROG ((stem Spelling)
	 (stem-minus-last-letter (subseq Spelling 0 (- (length spelling) 1)))
	 (last-letter (subseq Spelling (- (length spelling) 1) (length spelling)))
	 (next-to-last-letter (subseq Spelling (- (length spelling) 2) (- (length spelling) 1)))
	 (possible-inflected-forms '(Pluralform Comparativeform Superlativeform Pastform 
						Edparticipleform Ingparticipleform 
						Firstsingularform Secondsingularform 
						Thirdsingularform Verbpluralform 
						Firstsingularpastform Secondsingularpastform 
						Thirdsingularpastform Pluralpastform))
	 (possible-ending-types *lexical-entry-ending-types*)
	 (inflected-spelling NIL))
	(cond
	  ((Not (And (Stringp Spelling)
		     (symbolp Ending-Type)
		     (member Ending-Type possible-ending-types)
		     (Or (Not Properties)
			 (value-if-listp Properties))
		     (Or (Not Inflected-Form)
			 (And (symbolp Inflected-Form)
			      (member Inflected-Form possible-inflected-forms)))))
	   (Warning "Invalid inflection information, unable to generate word inflection")
	   (RETURN NIL)))
	(cond
	  ((And (Equal Ending-Type 'Es-ed)
		(Not (member next-to-last-letter '("a" "o" "u" "e")))
		(Equal last-letter "y"))
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT 
									      stem-minus-last-letter 
									      "ies")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem-minus-last-letter "ied")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem-minus-last-letter "ied")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Es-ed)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "es")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem "ed")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem "ed")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S-*ed)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem last-letter "ed")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem last-letter "ed")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem last-letter "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S-ed)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem "ed")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem "ed")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S-d)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (CONCAT stem "d")))
		 (Edparticipleform (SETQ inflected-spelling (CONCAT stem "d")))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem-minus-last-letter "ing"))
				    )
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type '*-Irr)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem last-letter "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((And (Equal Ending-Type 'S-irr)
		(Equal last-letter "e"))
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem-minus-last-letter "ing"))
				    )
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S-irr)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "s")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((And (Equal Ending-Type 'Es-irr)
		(Not (member next-to-last-letter '("a" "o" "u" "e")))
		(Equal last-letter "y"))
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT 
									      stem-minus-last-letter 
									      "ies")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Es-irr)
	   (Case Inflected-Form (Thirdsingularform (SETQ inflected-spelling (CONCAT stem "es")))
		 ((Pastform Firstsingularpastform Pluralpastform Thirdsingularpastform)
		  (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pastform
								       Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (CONCAT stem "ing")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Irr)
	   (Case Inflected-Form (Firstsingularform (SETQ inflected-spelling (
									     Get-Lexical-Property-Value 'Firstsingularform
									     Properties)))
		 (Secondsingularform (SETQ inflected-spelling (Get-Lexical-Property-Value
								'Secondsingularform
								Properties)))
		 (Thirdsingularform (SETQ inflected-spelling (Get-Lexical-Property-Value
							       'Thirdsingularform
							       Properties)))
		 (Pluralform (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pluralform
										  Properties)))
		 (Firstsingularpastform (SETQ inflected-spelling (Get-Lexical-Property-Value
								   'Firstsingularpastform
								   Properties)))
		 (Secondsingularpastform (SETQ inflected-spelling (Get-Lexical-Property-Value
								    'Secondsingularpastform
								    Properties)))
		 (Thirdsingularpastform (SETQ inflected-spelling (Get-Lexical-Property-Value
								   'Thirdsingularpastform
								   Properties)))
		 (Pluralpastform (SETQ inflected-spelling (Get-Lexical-Property-Value 'Pluralpastform
										      Properties)))
		 (Edparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							      'Edparticipleform
							      Properties)))
		 (Ingparticipleform (SETQ inflected-spelling (Get-Lexical-Property-Value
							       'Ingparticipleform
							       Properties)))
		 (pastform (SETQ inflected-spelling (Get-Lexical-Property-Value
							       'pastform
							       Properties)))
		 (comparativeform
		  (setq inflected-spelling
		    (Get-Lexical-Property-Value 'comparativeform Properties)))
		 (superlativeform
		  (setq inflected-spelling
		    (Get-Lexical-Property-Value 'superlativeform Properties)))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((And (Equal Ending-Type 'Er-est)
		(Not (member next-to-last-letter '("a" "o" "u" "e")))
		(Equal last-letter "y"))
	   (Case Inflected-Form (Comparativeform (SETQ inflected-spelling (CONCAT 
									    stem-minus-last-letter 
									    "ier")))
		 (Superlativeform (SETQ inflected-spelling (CONCAT stem-minus-last-letter "iest")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Er-est)
	   (Case Inflected-Form (Comparativeform (SETQ inflected-spelling (CONCAT stem "er")))
		 (Superlativeform (SETQ inflected-spelling (CONCAT stem "est")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'R-st)
	   (Case Inflected-Form (Comparativeform (SETQ inflected-spelling (CONCAT stem "r")))
		 (Superlativeform (SETQ inflected-spelling (CONCAT stem "st")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type '*Er-*est)
	   (Case Inflected-Form (Comparativeform (SETQ inflected-spelling (CONCAT stem last-letter 
										  "er")))
		 (Superlativeform (SETQ inflected-spelling (CONCAT stem last-letter "est")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((And (Equal Ending-Type 'Es)
		(Not (member next-to-last-letter '("a" "o" "u" "e")))
		(Equal last-letter "y"))
	   (Case Inflected-Form (Pluralform (SETQ inflected-spelling (CONCAT stem-minus-last-letter 
									     "ies")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'Es)
	   (Case Inflected-Form (Pluralform (SETQ inflected-spelling (CONCAT stem "es")))
		 (otherwise (SETQ inflected-spelling stem))))
	  ((Equal Ending-Type 'S)
	   (Case Inflected-Form (Pluralform (SETQ inflected-spelling (CONCAT stem "s")))
		 (otherwise (SETQ inflected-spelling stem)))))
	(RETURN  inflected-spelling )))
