summaryrefslogtreecommitdiff
path: root/src/language.ts
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2024-05-06 23:54:37 -0500
committersanine <sanine.not@pm.me>2024-05-06 23:54:37 -0500
commit5ce6a8f7b30b54b1d728c0571de799e99c79934c (patch)
tree37ee9fc5320f4dcae0502c451c0104fc110330a8 /src/language.ts
parent3c5c5ef59088a96b7988652f2dfef3d8a771f464 (diff)
add nice vowel positionsmain
Diffstat (limited to 'src/language.ts')
-rw-r--r--src/language.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/language.ts b/src/language.ts
index c0360b8..dd96b8d 100644
--- a/src/language.ts
+++ b/src/language.ts
@@ -20,6 +20,36 @@ export interface VowelFeatures {
nasal: boolean;
}
+
+// convert a vowel height/depth combo to an x/y position
+// (for use in creating nicely spaced vowel inventories)
+export function _vowelXY(
+ height: VowelHeight,
+ depth: VowelDepth
+): [number, number] {
+ const y = {
+ [VowelHeight.Open]: 0,
+ [VowelHeight.NearOpen]: 1,
+ [VowelHeight.OpenMid]: 2,
+ [VowelHeight.Mid]: 3,
+ [VowelHeight.CloseMid]: 4,
+ [VowelHeight.NearClose]: 5,
+ [VowelHeight.Close]: 6,
+ }[height];
+
+ const slope = {
+ [VowelDepth.Front]: 1,
+ [VowelDepth.Central]: 2,
+ [VowelDepth.Back]: 3,
+ }[depth];
+
+ if (slope === 3) { return [ 0, y ]; }
+
+ const x = (y + 2) / slope;
+ return [x, y];
+}
+
+
// convert a set of vowel features to an IPA representation
export function vowelFeaturesToIpa(features: VowelFeatures): string {
const ipa = () => {
@@ -141,6 +171,8 @@ export interface ConsonantFeatures {
}
+// convert a set of consonant features to IPA
+// returns the empty string if the proposed consonant does not exist
export function consonantFeaturesToIpa(features: ConsonantFeatures): string {
switch (features.place) {
case ConsonantPlace.Bilabial: