Created
May 7, 2012 12:22
-
-
Save manuelkiessling/2627485 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn m | |
"Measures the number of consonant sequences between | |
the start of word and position j. If c is a consonant | |
sequence and v a vowel sequence, and <...> indicates | |
arbitrary presence, | |
<c><v> -> 0 | |
<c>vc<v> -> 1 | |
<c>vcvc<v> -> 2 | |
<c>vcvcvc<v> -> 3 | |
... | |
" | |
([stemmer] | |
(m stemmer 0 0)) | |
([stemmer num-c num-cs] | |
(if (not (seq (:word stemmer))) ; Is the word empty? Then we reached the beginning of the stemmer | |
(if (> num-c 1) ; THEN1: More than 2 consonants in current counting? | |
(inc num-cs) ; THEN2: we have one more consonant sequence, and we return the number of sequences found plus 1 | |
num-cs) ; ELSE2: Return the number of sequences found | |
(if (consonant? stemmer) ; ELSE1: Is there a consonant at the current index? | |
(recur (pop-word stemmer) (inc num-c) num-cs) ; THEN3: increase the number of currently consecutice consonants, recur | |
(if (> num-c 1) ; ELSE3: If not, check if we found more than 1 consecutive consonants | |
(recur (pop-word stemmer) 0 (inc num-cs)) ; THEN4: If yes, we found one more sequence | |
(recur (pop-word stemmer) 0 num-cs)))))) ; ELSE4: If not, then we found only one, and start anew |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment