diff --git a/src/com/owoga/phonetics.clj b/src/com/owoga/phonetics.clj index 46862ef..e3b725c 100644 --- a/src/com/owoga/phonetics.clj +++ b/src/com/owoga/phonetics.clj @@ -156,6 +156,34 @@ two different ways of getting phonemes." (CMULexicon/getInstance true)) + +;; This sonority hierarchy may not be perfect. +;; It stems from: http://www.glottopedia.org/index.php/Sonority_hierarchy +;; I tried to match the phones provided by the CMU dict to the hierarchies +;; listed on that page: +;; vowels > liquids > nasals > voiced fricatives +;; > voiceless fricatives = voiced plosives +;; > voiceless plosives (Anderson & Ewen 1987) +(def ^clojure.lang.PersistentVector sonority-hierarchy + ;; more sonorous < < < vowel < < < (maximal onset) vowel > > > less sonorous + ["vowel" "liquid" "semivowel" "aspirate" "affricate" "nasal" "fricative" "stop"]) + +(def lax-vowels #{"EH" "IH" "AE" "AH" "UH"}) + +(defn sonority [phone] + (.indexOf sonority-hierarchy (phonemap phone))) + +(defn vowel? [phone] + (vowel (string/replace phone #"\d" ""))) + +(def consonant? (complement vowel?)) + +(defn >sonorous [a b] + (< (sonority a) (sonority b))) + +(defn (sonority a) (sonority b))) + (defn remove-stress [phonemes] (mapv #(string/replace % #"\d" "") phonemes)) diff --git a/src/com/owoga/phonetics/syllabify.clj b/src/com/owoga/phonetics/syllabify.clj index 17d5b61..e81dc17 100644 --- a/src/com/owoga/phonetics/syllabify.clj +++ b/src/com/owoga/phonetics/syllabify.clj @@ -5,38 +5,11 @@ #_(set! *warn-on-reflection* true) -;; This sonority hierarchy may not be perfect. -;; It stems from: http://www.glottopedia.org/index.php/Sonority_hierarchy -;; I tried to match the phones provided by the CMU dict to the hierarchies -;; listed on that page: -;; vowels > liquids > nasals > voiced fricatives -;; > voiceless fricatives = voiced plosives -;; > voiceless plosives (Anderson & Ewen 1987) -(def ^clojure.lang.PersistentVector sonority-hierarchy - ;; more sonorous < < < vowel < < < (maximal onset) vowel > > > less sonorous - ["vowel" "liquid" "semivowel" "aspirate" "affricate" "nasal" "fricative" "stop"]) - -(def lax-vowels #{"EH" "IH" "AE" "AH" "UH"}) - -(defn sonority [phone] - (.indexOf sonority-hierarchy (phonetics/phonemap phone))) - -(defn vowel? [phone] - (phonetics/vowel phone)) - -(def consonant? (complement vowel?)) - -(defn >sonorous [a b] - (< (sonority a) (sonority b))) - -(defn (sonority a) (sonority b))) - (defn slurp-rime "Expects the phones in reverse order. Returns a vector of the rime (in forwards order) and the remaining phones to process." [phones] - (let [splits (util/take-through vowel? phones)] + (let [splits (util/take-through phonetics/vowel? phones)] [(vec (reverse (first splits))) (vec (flatten (rest splits)))])) (comment