This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun uncountable (word) | |
"Notifies the inflector that a word is uncountable" | |
(push word *uncountables*)) | |
(defun irregular (singular plural) | |
"Adds a irregular single-plural set to the irregular list" | |
(push (cons singular plural) *irregulars*)) | |
(defun plural (rule replacement) | |
"Adds a plural rule, where RULE can be either a string or a regex, and REPLACEMENT can contain capture references defined in RULE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar *irregulars* | |
(args->alist | |
"person" "people" | |
"man" "men" | |
"child" "children" | |
"sex" "sexes" | |
"move" "moves" | |
"cow" "kine")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar *uncountables* | |
(list "equipment" "information" "rice" "money" "species" "series" "fish" "sheep" "jeans")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar *plurals* | |
'(("(quiz)$" "\\1zes") | |
("^(ox)$" "\\1en") | |
("([m|l])ouse$" "\\1ice") | |
("(matr|vert|ind)(?:ix|ex)$" "\\1ices") | |
("(x|ch|ss|sh)$" "\\1es") | |
("([^aeiouy]|qu)y$" "\\1ies") | |
("(hive)$" "\\1s") | |
("(?:([^f])fe|([lr])f)$" "\\1\\2ves") | |
("sis$" "ses") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inflect.plural(/$/, 's') | |
inflect.plural(/s$/i, 's') | |
inflect.plural(/(ax|test)is$/i, '\1es') | |
inflect.plural(/(octop|vir)us$/i, '\1i') | |
inflect.plural(/(alias|status)$/i, '\1es') | |
inflect.plural(/(bu)s$/i, '\1ses') | |
inflect.plural(/(buffal|tomat)o$/i, '\1oes') | |
inflect.plural(/([ti])um$/i, '\1a') | |
inflect.plural(/sis$/i, 'ses') | |
inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :vana-inflector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defpackage :vana-inflector | |
(:use :cl | |
:cl-ppcre | |
:vana-utils) | |
(:export :pluralize | |
:plural-of | |
:singularize | |
:singular-of | |
:irregular? | |
:irregular |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_name, last_name = full_name.split(" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun tag-name (name content) | |
(format nil "<~A>~A</~A>" name content name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> (tag-name "div" "Hello World") | |
"<div>Hello World</div>" |