Isoraqathedh

cut-to-first-vowel

May 14th, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.88 KB | None | 0 0
  1. (defun cut-to-first-vowel (word)
  2.   "Returns a word that (in most cases) is trimmed to the first vowel.
  3. Handles cases where <y> or <w> is the *only* vowel in the word.
  4. Returns a word as-is if none of <aeiouyw> can be found."
  5.   (let ((word-as-list (concatenate 'list word)))
  6.     (concatenate 'string
  7.          (if (some #'(lambda (p) (member char '(#\a #\e #\i #\o #\u))) word)
  8.              (member (first (some #'(lambda (p) (member char '(#\a #\e #\i #\o #\u))) word)) word-as-list)
  9.            (or (member #\y word-as-list)
  10.                (member #\w word-as-list)
  11.                word)))))
  12.  
  13. ;; Known issue: the case where <y> is considered a vowel but is not the only vowel in the entire word is handled incorrectly,
  14. ;; Such as "synthesis" (should be "ynthesis", but instead is "esis"),
  15. ;; "cymbal" (should be "ymbal", but instead is "al")
  16. ;; This is unlikely to be fixed until a word list WITH pronunciations is found.
Advertisement
Add Comment
Please, Sign In to add comment