diff options
author | polwex <polwex@sortug.com> | 2025-08-16 15:50:10 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-08-16 15:50:10 +0700 |
commit | 7f2cdbe5da583010466d725197137f503e1fb771 (patch) | |
tree | 09e10e50aed0fe3fc11139163fbca165fb9fe814 /src/lib | |
parent | 274a7bbb1f82e99cdc9876f6d0de430585282797 (diff) |
damn good
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/db/prosodydb.ts | 4 | ||||
-rw-r--r-- | src/lib/types/phonetics.ts | 25 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/lib/db/prosodydb.ts b/src/lib/db/prosodydb.ts index fdadafb..513b195 100644 --- a/src/lib/db/prosodydb.ts +++ b/src/lib/db/prosodydb.ts @@ -1,5 +1,5 @@ import Database from "bun:sqlite"; -import { MutationOrder, Phoneme, Tone } from "../types/phonetics"; +import { MutationOrder, Phoneme, PhoneticData, Tone } from "../types/phonetics"; import { ProsodyWord, ProsodyWordDB } from "../types/cards"; type Str = string | null; type ItemType = "word" | "syllable" | "idiom"; @@ -101,7 +101,7 @@ class DatabaseHandler { return query.all(onset) as any[]; } // tones - fetchWordsByToneAndSyls(tones: Array<string | null>) { + fetchWordsByToneAndSyls(tones: Array<string | null>): PhoneticData[] { const toneString = tones .reduce((acc: string, item) => { if (!item) return `${acc},%`; diff --git a/src/lib/types/phonetics.ts b/src/lib/types/phonetics.ts index f7289c7..1d0db5a 100644 --- a/src/lib/types/phonetics.ts +++ b/src/lib/types/phonetics.ts @@ -24,3 +24,28 @@ export type Syllable = { export type ToneQuery = Array<string | null>; export type MutationType = { change: string } | { keep: string }; export type MutationOrder = MutationType[]; + +export type PhoneticData = { + word_id: number; + tone_sequence: string; + syllable_count: number; + syl_seq: string; + spelling: string; + ipa: string; + frequency: number; +}; + +export const thaiTones: Record<string, string> = { + "˧": "mid", + "˨˩": "low", + "˥˩": "falling", + "˦˥": "high", + "˩˩˦": "rising", +}; +export const thaiToneNums: Record<string, number> = { + "˧": 33, + "˨˩": 21, + "˥˩": 41, + "˦˥": 45, + "˩˩˦": 214, +}; |