-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyllab_gen.html
166 lines (144 loc) · 6.53 KB
/
syllab_gen.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>English Syllable Generator</title>
</head>
<body>
<script>
Array.prototype.contains = function(obj) {
var i = this.length;
while (i--) {
if (this[i] === obj) {
return true;
}
}
return false;
}
var phonemes = {};
var vowels = {};
var consonants = {};
var places = {};
var manners = {};
var voiced = {};
var voiceless = {};
function Phoneme(ipa, attributes) {
this.ipa = ipa;
this.attributes = attributes;
phonemes[ipa] = this;
if (attributes.vowel) {
vowels[ipa] = this;
}
if (attributes.consonant) {
consonants[ipa] = this;
if (attributes.voice) {
voiced[ipa] = this;
} else {
voiceless[ipa] = this;
}
if (places[attributes.place] == undefined) {
places[attributes.place] = {};
}
if (manners[attributes.manner] == undefined) {
manners[attributes.manner] = {};
}
places[attributes.place][ipa] = this;
manners[attributes.manner][ipa] = this;
}
}
// ɑʌ
var nuclei = [
"ju", "jə",
"i", "u", "ɪ", "ʊ", "eɪ", "ə", "oʊ", "ɛ", "ʌ", "ɔɪ", "æ", "ɑ", "aɪ", "aʊ",
"ɪɹ", "ɚ", "ɛɹ", "ɝ", "ɔɹ", "ɑɹ"
];
new Phoneme("p", {consonant: true, vowel: false, place: "bilabial", manner: "plosive", voice: false});
new Phoneme("b", {consonant: true, vowel: false, place: "bilabial", manner: "plosive", voice: true});
new Phoneme("t", {consonant: true, vowel: false, place: "alveolar", manner: "plosive", voice: false});
new Phoneme("d", {consonant: true, vowel: false, place: "postalveolar", manner: "affricate", voice: true});
new Phoneme("ʧ", {consonant: true, vowel: false, place: "postalveolar", manner: "affricate", voice: false});
new Phoneme("ʤ", {consonant: true, vowel: false, place: "alveolar", manner: "plosive", voice: true});
new Phoneme("k", {consonant: true, vowel: false, place: "velar", manner: "plosive", voice: false});
new Phoneme("g", {consonant: true, vowel: false, place: "velar", manner: "plosive", voice: true});
new Phoneme("ʔ", {consonant: true, vowel: false, place: "glottal", manner: "plosive", voice: false});
new Phoneme("f", {consonant: true, vowel: false, place: "labiodental", manner: "fricative", voice: false});
new Phoneme("v", {consonant: true, vowel: false, place: "labiodental", manner: "fricative", voice: true});
new Phoneme("θ", {consonant: true, vowel: false, place: "interdental", manner: "fricative", voice: false});
new Phoneme("ð", {consonant: true, vowel: false, place: "interdental", manner: "fricative", voice: true});
new Phoneme("s", {consonant: true, vowel: false, place: "alveolar", manner: "fricative", voice: false});
new Phoneme("z", {consonant: true, vowel: false, place: "alveolar", manner: "fricative", voice: true});
new Phoneme("ʃ", {consonant: true, vowel: false, place: "postalveolar", manner: "fricative", voice: false});
new Phoneme("ʒ", {consonant: true, vowel: false, place: "postalveolar", manner: "fricative", voice: true});
new Phoneme("h", {consonant: true, vowel: false, place: "glottal", manner: "fricative", voice: false});
new Phoneme("w", {consonant: true, vowel: false, place: "labiovelar", manner: "approximate",voice: true});
new Phoneme("ɹ", {consonant: true, vowel: false, place: "alveolar", manner: "approximate",voice: true});
new Phoneme("l", {consonant: true, vowel: false, place: "alveolar", manner: "lateral", voice: true});
new Phoneme("j", {consonant: true, vowel: false, place: "palatal", manner: "approximate",voice: true});
new Phoneme("m", {consonant: true, vowel: false, place: "bilabial", manner: "nasal", voice: true});
new Phoneme("n", {consonant: true, vowel: false, place: "alveolar", manner: "nasal", voice: true});
new Phoneme("ŋ", {consonant: true, vowel: false, place: "velar", manner: "nasal", voice: true});
var sC = ["p", "t", "k", "f", "v", "w", "l", "m", "n"];
var Cw = [ "t", "d", "k", "g" ];
var Cr = ["p", "b", "t", "d", "k", "g", "f", "v", "θ", "ʃ"];
var Cl = ["p", "b", "k", "g", "f", "ʃ"];
var Cj = ["p", "b", "k", "f", "v", , "h", "m"]
var onsets = [];
for (var C in consonants) {
if (C != "ŋ") {
onsets.push(C);
}
if (sC.contains(C)) {
onsets.push("s" + C);
}
if (Cw.contains(C)) {
onsets.push(C + "w");
if (sC.contains(C)) {
onsets.push("s" + C + "w");
}
}
if (Cr.contains(C)) {
onsets.push(C + "r");
if (sC.contains(C)) {
onsets.push("s" + C + "r");
}
}
if (Cl.contains(C)) {
onsets.push(C + "l");
if (sC.contains(C)) {
onsets.push("s" + C + "l");
}
}
}
// N.B. onsets does not contain /C+j(?=u)/
var codas = [];
for (var C in consonants) {
var p = consonants[C];
if (p.attributes != undefined) {
if (p.attributes.place != "glottal" && p.attributes.manner != "approximate") {
codas.push(C);
}
if (p.attributes.manner != "approximate" && p.attributes.place != "glottal" && p.attributes.place != "lateral") {
codas.push("l" + C);
if (p.attributes.place.indexOf("labi") > -1) {
if (!p.attributes.voice)
codas.push("m" + C);
} else if (p.attributes.place == "velar") {
codas.push("ŋ" + C);
} else {
codas.push("n" + C);
}
}
}
}
var rhymes = [];
for (var iN in nuclei) {
var N = nuclei[iN];
for (var iC in codas) {
var C = codas[iC];
rhymes.push(N + C);
}
}
console.log(rhymes);
</script>
</body>
</html>