Skip to content

Instantly share code, notes, and snippets.

View sgrove's full-sized avatar
💭
Infinigraph, and beyond!

Sean Grove sgrove

💭
Infinigraph, and beyond!
View GitHub Profile
@sgrove
sgrove / gist:676202
Created November 14, 2010 23:12
:vana-inflector interface for adding rules/exceptions
(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"
@sgrove
sgrove / gist:676204
Created November 14, 2010 23:13
:vana-inflector example irregular rules
(defvar *irregulars*
(args->alist
"person" "people"
"man" "men"
"child" "children"
"sex" "sexes"
"move" "moves"
"cow" "kine"))
@sgrove
sgrove / gist:676205
Created November 14, 2010 23:13
:vana-inflector example uncountable list
(defvar *uncountables*
(list "equipment" "information" "rice" "money" "species" "series" "fish" "sheep" "jeans"))
@sgrove
sgrove / Grammar fix courtesy of Scott, idiomatic fix pointed out by Xach.lisp
Created November 14, 2010 23:14
:vana-inflector plural to singular rule list
(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")
@sgrove
sgrove / gist:676208
Created November 14, 2010 23:15
rails inflection plural to singular rule list
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')
@sgrove
sgrove / gist:676209
Created November 14, 2010 23:15
:vana-inflector instruction to work in :vana package
(in-package :vana-inflector)
@sgrove
sgrove / gist:676211
Created November 14, 2010 23:16
:vana-inflector package declaration
(defpackage :vana-inflector
(:use :cl
:cl-ppcre
:vana-utils)
(:export :pluralize
:plural-of
:singularize
:singular-of
:irregular?
:irregular
@sgrove
sgrove / gist:676226
Created November 14, 2010 23:32
ruby returning multiple values
first_name, last_name = full_name.split(" ")
@sgrove
sgrove / gist:700030
Created November 15, 2010 04:33
tag-name
(defun tag-name (name content)
(format nil "<~A>~A</~A>" name content name))
@sgrove
sgrove / gist:700031
Created November 15, 2010 04:33
tag-name example
> (tag-name "div" "Hello World")
"<div>Hello World</div>"