Updates to correct errors
This commit is contained in:
parent
1b8f69879e
commit
1c69a39836
@ -99,7 +99,7 @@
|
|||||||
(if (<= 5 (random 10))
|
(if (<= 5 (random 10))
|
||||||
(setf sentence (format nil "~A ~A" sentence (find-pos words "ADJECTIVE" 'false)))
|
(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))
|
sentence))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
"You must meet <name> at <place> and retrieve the [random(<adjective>, .5)] <noun>"
|
"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)))
|
(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))))
|
sentence))))
|
||||||
|
|
||||||
|
18
splork.lsp
18
splork.lsp
@ -43,6 +43,17 @@
|
|||||||
(nth 0 (nth (random (length new-words)) new-words))
|
(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)
|
(defun find-noun-with-article (words)
|
||||||
"Generates any articles necessary for a noun"
|
"Generates any articles necessary for a noun"
|
||||||
(let* ((new-words '())
|
(let* ((new-words '())
|
||||||
@ -54,7 +65,7 @@
|
|||||||
(nth 0 word)
|
(nth 0 word)
|
||||||
(if (string-equal "PLACE" (nth 2 word))
|
(if (string-equal "PLACE" (nth 2 word))
|
||||||
(nth 0 word)
|
(nth 0 word)
|
||||||
(cons "the " (nth 0 word))
|
(format nil "the ~A" (nth 0 word))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
@ -66,7 +77,8 @@
|
|||||||
(let* ((compiled-results '())
|
(let* ((compiled-results '())
|
||||||
(generated-sentence ""))
|
(generated-sentence ""))
|
||||||
(setf compiled-results (mapcar #'exec-lambda *sentence-structures*))
|
(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)) )
|
(let* ( (interjection (find-pos words "INTERJECTION" 'false)) )
|
||||||
(if (<= 10 (random 10))
|
(if (<= 10 (random 10))
|
||||||
(if (string-equal "!" interjection)
|
(if (string-equal "!" interjection)
|
||||||
@ -80,6 +92,8 @@
|
|||||||
(if (not (string-equal "!" generated-sentence))
|
(if (not (string-equal "!" generated-sentence))
|
||||||
(setf generated-sentence (format nil "~A." 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))
|
generated-sentence))
|
||||||
|
|
||||||
(princ (splork))
|
(princ (splork))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user