Updates to correct errors
This commit is contained in:
parent
1b8f69879e
commit
1c69a39836
@ -99,7 +99,7 @@
|
||||
(if (<= 5 (random 10))
|
||||
(setf sentence (format nil "~A ~A" sentence (find-pos words "ADJECTIVE" 'false)))
|
||||
)
|
||||
(setf sentence (format nil "~A ~A; ~A ~A ~A" sentence (find-noun-with-article words) (find-noun-with-article words) (find-pos words "PREPOSITION" 'false) (find-place-noun words)))
|
||||
(setf sentence (format nil "~A ~A; ~A ~A" sentence (find-noun-with-article words) (find-noun-with-article words) (find-pos words "PREPOSITION" 'false) (find-place-noun words)))
|
||||
sentence))
|
||||
(lambda ()
|
||||
"You must meet <name> at <place> and retrieve the [random(<adjective>, .5)] <noun>"
|
||||
@ -118,3 +118,4 @@
|
||||
)
|
||||
(setf sentence (format nil "~A ~A, ~A ~A ~A ~A!" sentence (find-pos words "NOUN" 'false) (find-noun-with-article words) (find-pos words "VERB" 'false) (find-pos words "PREPOSITION" 'false) (find-place-noun words)))
|
||||
sentence))))
|
||||
|
||||
|
24
splork.lsp
24
splork.lsp
@ -43,6 +43,17 @@
|
||||
(nth 0 (nth (random (length new-words)) new-words))
|
||||
))
|
||||
|
||||
(defun replace-substring (string substring replacement)
|
||||
"Replaces all occurrences of substring in string with replacement."
|
||||
(let ((result ""))
|
||||
(loop while (position substring string)
|
||||
do (let ((pos (position substring string)))
|
||||
(setf result (concatenate 'string result
|
||||
(subseq string 0 pos)
|
||||
replacement))
|
||||
(setf string (subseq string (+ pos (length substring))))))
|
||||
(concatenate 'string result string)))
|
||||
|
||||
(defun find-noun-with-article (words)
|
||||
"Generates any articles necessary for a noun"
|
||||
(let* ((new-words '())
|
||||
@ -52,11 +63,11 @@
|
||||
|
||||
(if (string-equal "PROPER" (nth 2 word))
|
||||
(nth 0 word)
|
||||
(if (string-equal "PLACE" (nth 2 word))
|
||||
(nth 0 word)
|
||||
(cons "the " (nth 0 word))
|
||||
(if (string-equal "PLACE" (nth 2 word))
|
||||
(nth 0 word)
|
||||
(format nil "the ~A" (nth 0 word))
|
||||
)
|
||||
)
|
||||
)
|
||||
))
|
||||
|
||||
(defun exec-lambda (x)
|
||||
@ -66,7 +77,8 @@
|
||||
(let* ((compiled-results '())
|
||||
(generated-sentence ""))
|
||||
(setf compiled-results (mapcar #'exec-lambda *sentence-structures*))
|
||||
(setf generated-sentence (nth (random (length compiled-results)) compiled-results))
|
||||
(setf sent-index (random (length compiled-results)))
|
||||
(setf generated-sentence (nth sent-index compiled-results))
|
||||
(let* ( (interjection (find-pos words "INTERJECTION" 'false)) )
|
||||
(if (<= 10 (random 10))
|
||||
(if (string-equal "!" interjection)
|
||||
@ -80,6 +92,8 @@
|
||||
(if (not (string-equal "!" generated-sentence))
|
||||
(setf generated-sentence (format nil "~A." generated-sentence))
|
||||
)
|
||||
(setf generated-sentence (replace-substring generated-sentence " " " "))
|
||||
(setf generated-sentence (replace-substring generated-sentence "the the" "the"))
|
||||
generated-sentence))
|
||||
|
||||
(princ (splork))
|
||||
|
Loading…
x
Reference in New Issue
Block a user