Update to fix more errors

This commit is contained in:
William Moore 2024-08-07 16:38:27 -05:00
parent 13e7990f53
commit cc8397173c

View File

@ -17,9 +17,10 @@
(defun sentence-case (sentence)
"Changes the sentence to a capital case letter at the beginning."
(format "%s%s" (upcase (substring sentence 0 1)) (substring sentence 1))
)
(let ((trimmed-sentence (string-trim sentence)))
(format "%s%s" (upcase (substring trimmed-sentence 0 1)) (substring trimmed-sentence 1))
)
)
(defun find-pos (words pos excludeProper)
"Find the Part of Speech from the array"
(setq new-words (delq nil (mapcar (lambda (x) (and (equal pos (nth 1 x)) x)) words)))
@ -454,6 +455,7 @@
("disk drive" "NOUN" "")
("dinosaur" "NOUN" "")
("dictator" "NOUN" "")
("dice" "NOUN" "")
("dictaphone" "NOUN" "")
("diamond" "NOUN" "")
("devil" "NOUN" "")
@ -1098,6 +1100,7 @@
("will" "VERB" "ABILITY")
("cannot" "VERB" "ABILITY")
("can" "VERB" "ABILITY")
("Kansas City" "NOUN" "PLACE")
))
@ -1108,7 +1111,7 @@
"The [random(<adjective>, .5)] <noun> [random(' in ' . <place>, .2)] is <adjective>"
(let ((sentence ""))
(if (<= 5 (random 10))
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
(setq sentence (format "%s" (find-pos words "ADJECTIVE" 'false)))
)
(setq sentence (format "%s %s" sentence (find-pos words "NOUN" 'true)))
(if (<= 2 (random 10))
@ -1124,9 +1127,9 @@
"The [random(<adjective>, .5)] <noun> [random(' in ' . <place>, .2)] is not <adjective>"
(let ((sentence ""))
(if (<= 5 (random 10))
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
(setq sentence (format "%s" (find-pos words "ADJECTIVE" 'false)))
)
(setq sentence (format "%s %s" sentence (find-pos words "NOUN" 'true)))
(setq sentence (format "%s %s" sentence (find-noun-with-article words)))
(if (<= 2 (random 10))
(setq sentence (format "%s in %s" sentence (find-noun-with-article words)))
)
@ -1215,7 +1218,7 @@
(if (<= 5 (random 10))
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
)
(setq sentence (format "%s and %s %s" sentence (find-pos words "NOUN" 'true) (find-pos "PREPOSITION" 'false) (find-place-noun words)))
(setq sentence (format "%s and %s %s" sentence (find-pos words "NOUN" 'true) (find-pos words "PREPOSITION" 'false) (find-place-noun words)))
sentence
)))
)
@ -1224,7 +1227,7 @@
(setq sentence-structures (append sentence-structures '( (lambda ()
"<name> <action> the [random(<adjective>, .5)] <noun>"
(let ((sentence (find-noun-with-article words)))
(setq sentence (format "%s %s the" sentence (find-pos words "ACTION" 'false)))
(setq sentence (format "%s %s the" sentence (find-pos words "VERB" 'false)))
(if (<= 5 (random 10))
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
)
@ -1281,12 +1284,12 @@
(if (<= 3 (random 10))
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
)
(setq sentence (format "%s, %s %s %s %s %s!" sentence (find-noun-with-article words) (find-noun-with-article words) (find-pos words "VERB" 'false) (find-pos words "PREPOSITION" 'false) (find-place-noun words)))
(setq sentence (format "%s %s, %s %s %s %s!" 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
)))
)
)
(defalias 'func-to-call (nth (random (length sentence-structures)) sentence-structures))
(setq generated-sentence (funcall 'func-to-call))
(let ( (interjection (find-pos words "INTERJECTION" 'false)) )