From 3385e7fd15a8cc356ac200ce708ab9710d13424e Mon Sep 17 00:00:00 2001 From: Eric Ihli Date: Thu, 24 Jun 2021 13:23:38 -0500 Subject: [PATCH] Add stress manipulation functions Useful for comparing the phonetics in a more flexible manner. --- src/com/owoga/phonetics/stress_manip.clj | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/com/owoga/phonetics/stress_manip.clj diff --git a/src/com/owoga/phonetics/stress_manip.clj b/src/com/owoga/phonetics/stress_manip.clj new file mode 100644 index 0000000..e9cbfd9 --- /dev/null +++ b/src/com/owoga/phonetics/stress_manip.clj @@ -0,0 +1,64 @@ +(ns com.owoga.phonetics.stress-manip + (:require [clojure.string :as string])) + +(defn primary-stress? + [phone] + (re-find #"1" phone)) + +(defn non-primary-stress? + [phone] + (re-find #"[2-9]" phone)) + +(defn unstressed? + [phone] + (re-find #"0" phone)) + +(defn remove-any-stress-signifiers + [phones] + (map #(string/replace % #"\d" "") phones)) + +(defn remove-non-primary-stress-signifiers + [phones] + (map #(string/replace % #"[02-9]" "") phones)) + +(defn unify-stressed + [phones] + (map #(string/replace % #"[2-9]" "1") phones)) + +(def consonant-unification-map + "This almost aligns with the phonemap that maps phones to whether they are vowels, aspirates, nasals, etc... + Slight but possibly important difference in stops. For example, I think T and D + are more unified than T and G; and G and K are more unifide than G and T." + {"T" "T" + "CH" "CH" + "K" "K" + "HH" "HH" + "L" "L" + "JH" "CH" ;; <- + "G" "K" ;; <- + "M" "M" ;; <- + "S" "S" + "Y" "Y" + "Z" "S" ;; <- + "R" "R" + "F" "F" + "B" "B" + "SH" "CH" ;; <- + "P" "B" ;; <- + "V" "F" ;; <- + "TH" "T" ;; <- + "N" "M" ;; <- + "DH" "T" ;; <- + "W" "Y" ;; <- + "ZH" "S" ;; <- + "NG" "M" ;; <- + "D" "T" ;; <- + }) + +(defn unify-consonants + [phones] + (mapv #(get consonant-unification-map % %) phones)) + +(defn remove-unstressed-signifiers + [phones] + (map #(string/replace % #"0" "")))