Journal Eli Gottlieb's Journal: Common Lisp Code to Terrorist-ize Given Text
;This maker of food for the NSA Line Eater is copyright (C) Eli Gottlieb, December 26 2005.
(defvar *dictionary* '("assasinate" "kill" "suicide bomb" "dirty bomb" "nuclear device"
"Al-Quaeda" "insurgency" "Hamas" "Baath"
"jihad" "Allah" "Islam"
"Sears Tower" "Empire State Building" "White House" "Golden Gate Bridge" "New York City subway"
"Iraq" "Afghanistan" "Palestine" "Iran" "Saudi Arabia"
"Israel" "America" "England"
"infidels"
"Usama bin Laden"
"London"))
(defun terroristize (lines)
(if (not (equalp lines nil))
(append
(if (equalp (cdr lines) nil)
(list (car lines))
(list (car lines) (nth (random (length *dictionary*)) *dictionary*)))
(terroristize (cdr lines)))
nil))
(defun equal-to-any (value any)
(cond
((equalp value (car any)) (car any))
((cdr any) (equal-to-any value (cdr any)))
('t nil)))
(defun all-whitespace-before-p (the-string start-index end-index)
(do ((index start-index (- index 1)))
((equalp index end-index) T)
(if (not (equalp (elt the-string index) #\ ))
(return nil))))
(defun token-delimited-p (token-beginning index-of-char string-data delimiters)
(and
(equal-to-any (elt string-data index-of-char) delimiters)
(not (all-whitespace-before-p string-data index-of-char token-beginning))))
(defun tokenize (string-input delimiters &optional (inclusive nil))
(setf tokens nil)
(setf token-beginning 0)
(dotimes (c (length string-input))
(if (token-delimited-p token-beginning c string-input delimiters)
(progn
(setf tokens (append tokens (list (subseq string-input token-beginning (if inclusive (+ c 1) c)))))
(setf token-beginning (+ c 1)))))
(if ( token-beginning (length string-input))
(append tokens (list (subseq string-input token-beginning)))
tokens))
(defun parse-for-words (sentence)
(tokenize sentence '(#\ )))
(defun parse-for-sentences (message)
(tokenize message '(#\. #\? #\!) T))
(defun string-reglue (str1 str2 delimiter)
(concatenate 'string (concatenate 'string str1 (string delimiter)) str2))
(defun list-to-string (list-input)
(if (stringp (car list-input))
(if (cdr list-input)
(string-reglue (car list-input) (list-to-string (cdr list-input)) #\ )
(car list-input))
nil))
(defun feed-echelon (message)
(setf sentences (mapcar 'parse-for-words (parse-for-sentences message)))
(dotimes (sentence (length sentences))
(setf (elt sentences sentence) (terroristize (elt sentences sentence)))
)
(list-to-string (mapcar 'list-to-string sentences))
)
Common Lisp Code to Terrorist-ize Given Text More Login
Common Lisp Code to Terrorist-ize Given Text
Slashdot Top Deals