Update with refactoring
This commit is contained in:
parent
249b0b5119
commit
13e7990f53
33
splork.el
33
splork.el
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defun sentence-case (sentence)
|
(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))
|
(format "%s%s" (upcase (substring sentence 0 1)) (substring sentence 1))
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -42,13 +43,12 @@
|
|||||||
|
|
||||||
(if (string-match-p "PROPER" (nth 2 word))
|
(if (string-match-p "PROPER" (nth 2 word))
|
||||||
(nth 0 word)
|
(nth 0 word)
|
||||||
)
|
(if (string-match-p "PLACE" (nth 2 word))
|
||||||
(if (string-match-p "PLACE" (nth 2 word))
|
(nth 0 word)
|
||||||
(nth 0 word)
|
(format "the %s" (nth 0 word))
|
||||||
(format "the %s" (nth 0 word))
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(setq words '(
|
(setq words '(
|
||||||
("Chinese Communist Party" "NOUN" "")
|
("Chinese Communist Party" "NOUN" "")
|
||||||
("CCP" "NOUN" "")
|
("CCP" "NOUN" "")
|
||||||
@ -1102,13 +1102,11 @@
|
|||||||
))
|
))
|
||||||
|
|
||||||
(defun splork ()
|
(defun splork ()
|
||||||
(interactive)
|
|
||||||
(switch-to-buffer-other-window "*splork*")
|
|
||||||
(let ((sentence-structures '()))
|
(let ((sentence-structures '()))
|
||||||
|
|
||||||
(setq sentence-structures (append sentence-structures '( (lambda ()
|
(setq sentence-structures (append sentence-structures '( (lambda ()
|
||||||
"The [random(<adjective>, .5)] <noun> [random(' in ' . <place>, .2)] is <adjective>"
|
"The [random(<adjective>, .5)] <noun> [random(' in ' . <place>, .2)] is <adjective>"
|
||||||
(let ((sentence "the"))
|
(let ((sentence ""))
|
||||||
(if (<= 5 (random 10))
|
(if (<= 5 (random 10))
|
||||||
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
|
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
|
||||||
)
|
)
|
||||||
@ -1124,7 +1122,7 @@
|
|||||||
|
|
||||||
(setq sentence-structures (append sentence-structures '( (lambda ()
|
(setq sentence-structures (append sentence-structures '( (lambda ()
|
||||||
"The [random(<adjective>, .5)] <noun> [random(' in ' . <place>, .2)] is not <adjective>"
|
"The [random(<adjective>, .5)] <noun> [random(' in ' . <place>, .2)] is not <adjective>"
|
||||||
(let ((sentence "the"))
|
(let ((sentence ""))
|
||||||
(if (<= 5 (random 10))
|
(if (<= 5 (random 10))
|
||||||
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
|
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
|
||||||
)
|
)
|
||||||
@ -1141,7 +1139,7 @@
|
|||||||
|
|
||||||
(setq sentence-structures (append sentence-structures '( (lambda ()
|
(setq sentence-structures (append sentence-structures '( (lambda ()
|
||||||
"The <noun> from <place> will go to <place>"
|
"The <noun> from <place> will go to <place>"
|
||||||
(let ((sentence "the"))
|
(let ((sentence ""))
|
||||||
(setq sentence (format "%s %s from %s will go to %s" sentence (find-pos words "NOUN" 'false) (find-place-noun words) (find-place-noun words)))
|
(setq sentence (format "%s %s from %s will go to %s" sentence (find-pos words "NOUN" 'false) (find-place-noun words) (find-place-noun words)))
|
||||||
sentence
|
sentence
|
||||||
)))
|
)))
|
||||||
@ -1178,7 +1176,7 @@
|
|||||||
|
|
||||||
(setq sentence-structures (append sentence-structures '( (lambda ()
|
(setq sentence-structures (append sentence-structures '( (lambda ()
|
||||||
"The <noun> from the <place> <action> the <noun>"
|
"The <noun> from the <place> <action> the <noun>"
|
||||||
(let ((sentence "the"))
|
(let ((sentence ""))
|
||||||
(setq sentence (format "%s %s from the %s %s the %s" sentence (find-pos words "NOUN" 'true) (find-place-noun words) (find-pos words "VERB" 'false) (find-pos words "NOUN" 'true)))
|
(setq sentence (format "%s %s from the %s %s the %s" sentence (find-pos words "NOUN" 'true) (find-place-noun words) (find-pos words "VERB" 'false) (find-pos words "NOUN" 'true)))
|
||||||
sentence
|
sentence
|
||||||
)))
|
)))
|
||||||
@ -1187,7 +1185,7 @@
|
|||||||
|
|
||||||
(setq sentence-structures (append sentence-structures '( (lambda ()
|
(setq sentence-structures (append sentence-structures '( (lambda ()
|
||||||
"The [random(<adjective>, .5)] <noun> <action> the <adjective> <noun> [random('in ' . <place>, .2]"
|
"The [random(<adjective>, .5)] <noun> <action> the <adjective> <noun> [random('in ' . <place>, .2]"
|
||||||
(let ((sentence "the"))
|
(let ((sentence ""))
|
||||||
(if (<= 5 (random 10))
|
(if (<= 5 (random 10))
|
||||||
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
|
(setq sentence (format "%s %s" sentence (find-pos words "ADJECTIVE" 'false)))
|
||||||
)
|
)
|
||||||
@ -1304,9 +1302,16 @@
|
|||||||
(if (not (string-match-p "!" generated-sentence))
|
(if (not (string-match-p "!" generated-sentence))
|
||||||
(setq generated-sentence (format "%s." generated-sentence))
|
(setq generated-sentence (format "%s." generated-sentence))
|
||||||
)
|
)
|
||||||
(goto-char (point-max))
|
generated-sentence
|
||||||
(insert (format "%s\n" generated-sentence))
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(defun splork-generate ()
|
||||||
|
(interactive)
|
||||||
|
(switch-to-buffer-other-window "*splork*")
|
||||||
|
(setq sentence (splork))
|
||||||
|
(goto-char (point-max))
|
||||||
|
(insert (format "%s\n" sentence))
|
||||||
|
)
|
||||||
|
|
||||||
(provide 'splork)
|
(provide 'splork)
|
||||||
|
Loading…
Reference in New Issue
Block a user