# HG changeset patch # User Steve Losh # Date 1486416277 0 # Node ID f0ec1842d603db147f547a046274bd14083e67ac # Parent 3d7298dcd3efa84e3c468e9027f5fae8e7e79bbb Make the pluralization slightly less awful diff -r 3d7298dcd3ef -r f0ec1842d603 src/chancery.lisp --- a/src/chancery.lisp Fri Jan 20 23:25:35 2017 +0000 +++ b/src/chancery.lisp Mon Feb 06 21:24:37 2017 +0000 @@ -256,13 +256,17 @@ (defun s (string) "Pluralize `string`." ;; todo: fix for caps + ;; todo: make this suck less in general, see http://blog.writeathome.com/index.php/2011/12/how-to-make-nouns-plural/ (assert-nonempty string "Cannot pluralize an empty string.") - (case (ch string -1) - ((#\y #\Y) (if (vowelp (ch string -2)) - (cat string "s") - (cat (chop string 1) "ies"))) - ((#\x #\X) (cat (chop string 1) "en")) - ((#\z #\h #\Z #\H) (cat (chop string 1) "es")) + (case (char-downcase (ch string -1)) + (#\y (if (vowelp (ch string -2)) + (cat string "s") + (cat (chop string 1) "ies"))) + ((#\x #\s #\z) (cat string "es")) + (#\h (cat string + (case (ch string -2) + ((#\c #\s) "es") + (t "s")))) (t (cat string "s")))) (defun pos (string)