summaryrefslogtreecommitdiff
path: root/packages/db/src/types.ts
blob: 66c2826a1e78bc7f9b7c618fe961d26f4d99176a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
export type Tone = {
  letters: string;
  numbers: number;
  name: string;
};

export type Phoneme = {
  ipa: string;
  spelling: string;
};
export type Syllable = {
  stressed: boolean;
  long: boolean;
  spelling: string;
  ipa: string;
  nucleus: Phoneme;
  onset: Phoneme;
  medial: Phoneme;
  coda: Phoneme;
  rhyme: Phoneme;
  tone: Tone;
};

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,
};

export type FullWordDataDB = {
  word_id: number;
  tone_sequence: string;
  syllable_count: number;
  syl_seq: string;
  spelling: string;
  ipa: string;
  frequency: number;
  senses_array: string;
};
export type FullWordData = {
  word_id: number;
  tone_sequence: string;
  syllable_count: number;
  syl_seq: string;
  spelling: string;
  ipa: string;
  frequency: number;
  senses: Sense[];
};
export type Sense = {
  confidence: number;
  examples: Example[];
  categories: string[];
  etymology: string;
  derivation: Derivation[];
  pos: string;
  forms: Array<{ form: string; tags: string[] }>;
  glosses: string[];
};
export type Example = { ref: string; text: string };
export type Derivation = { type: string; text: string; tags: any };