From d0f5ed1733ae821404fb83346112b5f14aed1753 Mon Sep 17 00:00:00 2001 From: Eric Ihli Date: Wed, 28 Apr 2021 15:57:18 -0500 Subject: [PATCH] Fix bug incorrectly syllabifying steel If there are no vowels left when slurping an onset, then every remaining phone belongs to the syllable, regardless of any other rule. --- src/com/owoga/phonetics/syllabify.clj | 7 +++++++ test/com/owoga/phonetics/syllabify_test.clj | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/com/owoga/phonetics/syllabify.clj b/src/com/owoga/phonetics/syllabify.clj index e110b40..8ad3145 100644 --- a/src/com/owoga/phonetics/syllabify.clj +++ b/src/com/owoga/phonetics/syllabify.clj @@ -76,6 +76,10 @@ (recur (subvec phones 1) (into [(nth phones 0)] syllable)) + (not-any? vowel? phones) + (recur (subvec phones 1) + (into [(nth phones 0)] syllable)) + :else [syllable phones]))) (comment @@ -128,6 +132,9 @@ (recur phones'' (into [syllable] segments))))))) (comment + (syllabify ["S" "T" "IY" "L"]) + (slurp-rime (reverse ["S" "T" "IY" "L"])) + (slurp-onset-given-rime ["T" "S"] ["IY" "L"]) (phonetics/remove-stress ["AH" "L" "AE" "S" "K" "AH"]) (slurp-onset-given-rime ["L" "AE" "S" "K" "AH"] ["AH"]) (syllabify ["AH0" "L" "AE1" "S" "K" "AH0"]) diff --git a/test/com/owoga/phonetics/syllabify_test.clj b/test/com/owoga/phonetics/syllabify_test.clj index f7c4f28..3101279 100644 --- a/test/com/owoga/phonetics/syllabify_test.clj +++ b/test/com/owoga/phonetics/syllabify_test.clj @@ -38,4 +38,7 @@ ;; about handling ambisyllabic words. There's no such thing. (testing "pillow" (is (= '(("P" "IH") ("L" "OW")) - (syllabify ["P" "IH" "L" "OW"]))))) + (syllabify ["P" "IH" "L" "OW"])))) + (testing "steel" + (is (= [["S" "T" "IY1" "L"]] + (syllabify ["S" "T" "IY1" "L"])))))