f0ec1842d603

Make the pluralization slightly less awful
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 06 Feb 2017 21:24:37 +0000
parents 3d7298dcd3ef
children 3d06e5b432c9
branches/tags (none)
files src/chancery.lisp

Changes

--- 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)