-
Notifications
You must be signed in to change notification settings - Fork 0
/
poetic.h
260 lines (244 loc) · 9 KB
/
poetic.h
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#ifndef POETIC_H
#define POETIC_H
#include "dictionary.h"
#include <unordered_map>
std::vector<std::vector<int>> techniques(std::vector<int> line, Dictionary& dictionary);
bool vowel_phenome_pred(std::string& str);
std::vector<std::string>::iterator vowel(std::vector<std::string>& syllable);
int num_shared_constants(std::vector<std::string> syllable1, std::vector<std::string> syllable2);
double cord_dist(const std::pair<int,int>& c1, const std::pair<int,int>& c2);
double vowel_dist(const std::string& vowel1, const std::string& vowel2);
// SCIENCE!
// The positioning of the jaw and tounge create a unique resonance cavity for the vibrations generated by the vocal chords
// This cavity produces a forment (natural mode) frequency spectra
// Place theory suggests that the ear distinguishes pitches based on the location of maximum excitation along the basilar membrane
// Thus we can distinguish formants and thus vowel sounds
// We can analyze the similarity of vowel sounds by how close their formants are
int techniques(std::vector<std::string>& syllable1, std::vector<std::string>& syllable2, const Stress stress1, const Stress stress2);
// VOWELS
// ARARPABET F1 F2
// AY dipthong 850 1610 and IH
// AW dipthong 850 1610 and UH
// EY dipthong 390 2300 and IH
// IY 240 2400
// OW dipthong 460 1310 and UH
// UW 250 595
// AE 900 2000
// AA 750 940
// AO 500 700
// OY dipthong AH and IH
// EH 610 1900
// ER 450 1600
// IH 400 2250
// UH 475 1250
// AH 600 1170
//CONST
// ARAPABET
// B 0
// CH 12
// D 1
// DH 9
// F 16
// G 2
// HH
// JH 11
// K 19
// L 4
// M 7
// N 6
// NG 5
// P 17
// R 3
// S 14
// SH 13
// T 18
// TH 15
// V 8
// W
// Y
// Z 10
// ZH
struct pair_hasher
{
template <class T1, class T2>
std::size_t operator() (const std::pair<T1, T2> &pair) const
{
return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
}
};
static std::unordered_map<std::pair<std::string, std::string>, int, pair_hasher> create_constanant_map_initial(){
std::unordered_map<std::pair<std::string, std::string>, int, pair_hasher> m;
m[std::make_pair("B","V")] = 57;
m[std::make_pair("D","G")] = 76;
m[std::make_pair("D","Z")] = 51;
m[std::make_pair("D","G")] = 76;
m[std::make_pair("D","JH")] = 85;
m[std::make_pair("T","G")] = 47;
m[std::make_pair("G","D")] = 110;
m[std::make_pair("G","R")] = 85;
m[std::make_pair("G","JH")] = 78;
m[std::make_pair("R","L")] = 50;
m[std::make_pair("R","N")] = 45;
m[std::make_pair("R","M")] = 43;
m[std::make_pair("L","B")] = 50;
m[std::make_pair("L","D")] = 73;
m[std::make_pair("L","G")] = 62;
m[std::make_pair("L","R")] = 206;
m[std::make_pair("L","N")] = 303;
m[std::make_pair("L","M")] = 203;
m[std::make_pair("L","V")] = 61;
m[std::make_pair("L","DH")] = 193;
m[std::make_pair("L","JH")] = 53;
m[std::make_pair("L","T")] = 42;
m[std::make_pair("N","M")] = 106;
m[std::make_pair("M","R")] = 62;
m[std::make_pair("M","L")] = 48;
m[std::make_pair("M","N")] = 170;
m[std::make_pair("V","B")] = 266;
m[std::make_pair("V","D")] = 74;
m[std::make_pair("V","G")] = 78;
m[std::make_pair("V","R")] = 114;
m[std::make_pair("V","L")] = 150;
m[std::make_pair("V","N")] = 77;
m[std::make_pair("V","M")] = 127;
m[std::make_pair("V","DH")] = 499;
m[std::make_pair("V","Z")] = 54;
m[std::make_pair("V","S")] = 39;
m[std::make_pair("V","F")] = 120;
m[std::make_pair("DH","V")] = 102;
m[std::make_pair("Z","DH")] = 41;
m[std::make_pair("Z","JH")] = 45;
m[std::make_pair("Z","S")] = 424;
m[std::make_pair("Z","T")] = 39;
m[std::make_pair("JH","Z")] = 66;
m[std::make_pair("JH","CH")] = 253;
m[std::make_pair("JH","SH")] = 278;
m[std::make_pair("JH","S")] = 47;
m[std::make_pair("CH","JH")] = 138;
m[std::make_pair("CH","SH")] = 451;
m[std::make_pair("CH","S")] = 52;
m[std::make_pair("CH","T")] = 41;
m[std::make_pair("SH","CH")] = 67;
m[std::make_pair("S","Z")] = 53;
m[std::make_pair("TH","DH")] = 54;
m[std::make_pair("TH","S")] = 42;
m[std::make_pair("TH","F")] = 196;
m[std::make_pair("F","B")] = 69;
m[std::make_pair("F","S")] = 64;
m[std::make_pair("F","TH")] = 455;
m[std::make_pair("P","B")] = 58;
m[std::make_pair("P","G")] = 41;
m[std::make_pair("P","T")] = 92;
m[std::make_pair("P","K")] = 116;
m[std::make_pair("P","HH")] = 176;
m[std::make_pair("T","CH")] = 42;
m[std::make_pair("T","S")] = 58;
m[std::make_pair("T","K")] = 41;
m[std::make_pair("K","JH")] = 49;
m[std::make_pair("K","CH")] = 43;
m[std::make_pair("K","S")] = 39;
m[std::make_pair("K","P")] = 58;
m[std::make_pair("K","T")] = 165;
m[std::make_pair("K","HH")] = 51;
m[std::make_pair("HH","B")] = 128;
m[std::make_pair("HH","D")] = 67;
m[std::make_pair("HH","G")] = 141;
m[std::make_pair("HH","R")] = 62;
m[std::make_pair("HH","N")] = 56;
m[std::make_pair("HH","M")] = 57;
m[std::make_pair("HH","Z")] = 44;
m[std::make_pair("HH","JH")] = 45;
m[std::make_pair("HH","SH")] = 38;
m[std::make_pair("HH","S")] = 69;
m[std::make_pair("HH","P")] = 328;
m[std::make_pair("HH","T")] = 175;
m[std::make_pair("HH","K")] = 177;
return m;
}
static const std::unordered_map<std::pair<std::string, std::string>, int, pair_hasher> constanant_map_initial = create_constanant_map_initial();
static std::unordered_map<std::pair<std::string, std::string>, int, pair_hasher> create_constanant_map_final(){
std::unordered_map<std::pair<std::string, std::string>, int, pair_hasher> m;
m[std::make_pair("B","D")] = 103;
m[std::make_pair("B","G")] = 122;
m[std::make_pair("B","L")] = 51;
m[std::make_pair("B","V")] = 64;
m[std::make_pair("B","P")] = 112;
m[std::make_pair("D","B")] = 94;
m[std::make_pair("D","G")] = 91;
m[std::make_pair("D","R")] = 47;
m[std::make_pair("D","JH")] = 68;
m[std::make_pair("D","T")] = 40;
m[std::make_pair("G","B")] = 91;
m[std::make_pair("G","D")] = 135;
m[std::make_pair("G","R")] = 112;
m[std::make_pair("G","L")] = 84;
m[std::make_pair("G","Z")] = 62;
m[std::make_pair("G","JH")] = 66;
m[std::make_pair("G","S")] = 57;
m[std::make_pair("G","K")] = 59;
m[std::make_pair("R","L")] = 123;
m[std::make_pair("L","R")] = 128;
m[std::make_pair("L","NG")] = 42;
m[std::make_pair("NG","N")] = 90;
m[std::make_pair("NG","N")] = 78;
m[std::make_pair("N","R")] = 44;
m[std::make_pair("N","L")] = 48;
m[std::make_pair("N","NG")] = 390;
m[std::make_pair("N","M")] = 182;
m[std::make_pair("M","L")] = 42;
m[std::make_pair("M","NG")] = 281;
m[std::make_pair("M","N")] = 159;
m[std::make_pair("V","B")] = 184;
m[std::make_pair("V","D")] = 97;
m[std::make_pair("V","G")] = 128;
m[std::make_pair("V","R")] = 74;
m[std::make_pair("V","L")] = 141;
m[std::make_pair("V","NG")] = 69;
m[std::make_pair("V","N")] = 54;
m[std::make_pair("V","DH")] = 714;
m[std::make_pair("V","Z")] = 70;
m[std::make_pair("V","S")] = 42;
m[std::make_pair("V","F")] = 67;
m[std::make_pair("DH","B")] = 56;
m[std::make_pair("DH","D")] = 87;
m[std::make_pair("DH","G")] = 54;
m[std::make_pair("DH","V")] = 131;
m[std::make_pair("Z","S")] = 177;
m[std::make_pair("JH","R")] = 65;
m[std::make_pair("JH","Z")] = 144;
m[std::make_pair("JH","CH")] = 285;
m[std::make_pair("JH","SH")] = 221;
m[std::make_pair("JH","S")] = 82;
m[std::make_pair("CH","Z")] = 40;
m[std::make_pair("CH","JH")] = 75;
m[std::make_pair("CH","SH")] = 214;
m[std::make_pair("CH","S")] = 59;
m[std::make_pair("SH","CH")] = 146;
m[std::make_pair("SH","S")] = 106;
m[std::make_pair("S","Z")] = 61;
m[std::make_pair("S","SH")] = 40;
m[std::make_pair("TH","S")] = 76;
m[std::make_pair("TH","F")] = 394;
m[std::make_pair("TH","T")] = 46;
m[std::make_pair("TH","K")] = 60;
m[std::make_pair("F","S")] = 44;
m[std::make_pair("F","TH")] = 337;
m[std::make_pair("F","P")] = 49;
m[std::make_pair("F","K")] = 48;
m[std::make_pair("P","B")] = 60;
m[std::make_pair("P","T")] = 99;
m[std::make_pair("P","K")] = 149;
m[std::make_pair("T","Z")] = 72;
m[std::make_pair("T","CH")] = 65;
m[std::make_pair("T","S")] = 111;
m[std::make_pair("T","P")] = 114;
m[std::make_pair("T","K")] = 90;
m[std::make_pair("K","G")] = 57;
m[std::make_pair("K","SH")] = 43;
m[std::make_pair("K","S")] = 46;
m[std::make_pair("K","P")] = 217;
m[std::make_pair("K","T")] = 132;
return m;
}
static const std::unordered_map<std::pair<std::string, std::string>, int, pair_hasher> constanant_map_final = create_constanant_map_final();
#endif //POETIC_H