Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun cut-to-first-vowel (word)
- "Returns a word that (in most cases) is trimmed to the first vowel.
- Handles cases where <y> or <w> is the *only* vowel in the word.
- Returns a word as-is if none of <aeiouyw> can be found."
- (let ((word-as-list (concatenate 'list word)))
- (concatenate 'string
- (if (some #'(lambda (p) (member char '(#\a #\e #\i #\o #\u))) word)
- (member (first (some #'(lambda (p) (member char '(#\a #\e #\i #\o #\u))) word)) word-as-list)
- (or (member #\y word-as-list)
- (member #\w word-as-list)
- word)))))
- ;; Known issue: the case where <y> is considered a vowel but is not the only vowel in the entire word is handled incorrectly,
- ;; Such as "synthesis" (should be "ynthesis", but instead is "esis"),
- ;; "cymbal" (should be "ymbal", but instead is "al")
- ;; This is unlikely to be fixed until a word list WITH pronunciations is found.
Advertisement
Add Comment
Please, Sign In to add comment