(use-modules (ice-9 regex)) (define lexicon '(("%n%" ("phone" "messaging" "sharing" "mom" "NASA" "yuppie" "personalization" "photo" "filtering" "broadband" "spam" "network" "Spock" "Tina Turner")) ("%v%" ("love" "buy" "use")) ("%adj%" ("instant" "digital" "streaming" "passive" "virtual" "private")) ("%det%" ("a" "the" "each" "every" "most" "all" "some")) ("%prep%" ("of" "for" "with" "by")) ("%comp%" ("that" "which")) ("%cp%" ("%np% %vp%")) ("%np%" ("%det% %n%" "%det% %ap% %n%" "%det% %n% %prep% %np%" "%det% %n% %comp% %cp%")) ("%ap%" ("%adj%" "%ap%" "")) ("%vp%" ("%v%" "%v% %np%")))) (define (get-word category) (let ((choices (car (cdr (assoc category lexicon))))) (list-ref choices (random (length choices))))) (define (substitute template) (let ((match (string-match "%[^%]*%" template))) (if match (substitute (string-append (match:prefix match) (get-word (match:substring match)) (match:suffix match))) template))) (display (string-append "