forked from amundo/indexdiachronica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.html
251 lines (219 loc) · 5.17 KB
/
helper.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Modeling Index Diachronica Changesets</title>
<style>
html {
display:flex;
min-height:100vh
flex-direction: column;
}
* {
font-family: 'Fira Sans';
}
main {
margin-right: 20%;
}
.comparison {
display:flex;
}
.comparison pre#changeset {
white-space: pre-wrap;
}
.comparison div ,
.comparison pre#changeset ,
.comparison pre#renderedChangeset {
flex: 1;
display:flex;
}
div#image img {
width: 100%;
align-self: flex-start;
}
.comparison div pre ,
.comparison div textarea {
width: 80%;
padding: 1em;
font-family: 'Fira Mono';
white-space: pre-wrap;
}
</style>
</head>
<body >
<p>
These representations are valid <a title="JSON" href="http://json.org/">JSON</a>.
You might be wondering why we should want to convert rules into JSON — the answer is,
then the rules are <em>data</em>, and we can do all kinds of neat things with them.
For one thing, we can render them in whatever format we want.
</p>
<p>
But cooler than that, once we have some rules in place, and we have some text in <em>any</em>
language in IPA, we can <em>run</em> the rules on text. How cool would it be to run a
Chapai changeset on… say, Irathient, <em>just because</em>?
</p>
<section class=comparison>
<div id=sampleRule>
<textarea style=min-height:10em; spellcheck=false>
{
"parent": "Proto-Pai",
"child": "Chapai",
"before": "tʃ",
"after": "∅",
"environment": "_w"
}
</textarea>
</div>
<pre id=renderedRule class=render>
</pre>
</section>
<h2>From Changes to Changeset</h2>
<p>So just to wrap up this little intro, I suggest representing this whole changeset
(ordered list of changes) for Proto-Pai to Chapai in the following way:</p>
<section class="comparison">
<pre id=changeset>
{
"metadata": {
"parent": "Proto-Pai",
"child": "Chapai",
"contributor": "Pogostick Man",
"source": "Wares, Alan C. (1954?) “Three Pai Dialects of Lower California”. Summer Institute of Linguistics Collection of Unpublished Materials.",
"family": "Yuman-Cochimí",
"subfamily": "Pai",
"notes": [
"The last rule, “Stress lost?” should probably checked in the original source."
]
},
"changeset": [
{
"before": "tʃ",
"after": "ʃ",
"environment": "_w"
},
{
"before": "tʃ",
"after": "ʃ",
"environment": "_i"
},
{
"before": "tʃ",
"after": "∅",
"environment": "_xʷ"
},
{
"before": "tʃ",
"after": "s",
"environment": null
},
{
"before": "t",
"after": "tʃ",
"environment": "! n_"
},
{
"before": "kʷ",
"after": "k",
"environment": "_#"
},
{
"before": "b",
"after": "p",
"environment": null
},
{
"before": "o",
"after": "u",
"environment": null
},
{
"before": "s",
"after": "ʂ",
"environment": null
},
{
"before": "ʔ",
"after": "∅",
"environment": "_j"
},
{
"before": "ʔ",
"after": "∅",
"environment": "_ɲ"
},
{
"before": "w",
"after": "∅",
"environment": "a_"
},
{
"before": "j",
"after": "∅",
"environment": "a_"
},
{
"before": "Vː",
"after": "V",
"environment": null
}
]
}
</pre>
<pre id=renderedChangeset>
</pre>
</section>
<p>
I left out the last rule, because it’s kind of unclear what it means.
I’ve added a note in the metadata to this effect. The idea is that someone
who comes along and wants to check this file could go off and verify that
rule in the original source.
</p>
<p>
There are many details left out here, we’ll continue to work through them
as we continue to work on the project.
</p>
<blockquote>
<em>Please note — we’re not going to write out all these data files by hand!
We’ll take several steps to get the database bootstrapped. We’ll extract
as much data automatically as we can, and then we’ll build a simple user interface
to allow contributors to check and update the information. More soon.</em>
</blockquote>
</main>
<script>
var renderRule = rule => `
{
${rule.before} → ${rule.after}
${rule.env ? '/ ' + rule.env : ''}
"id": "",
"before": "dz ʃ tʃ",
"after": "ʒ s1 s2",
"env": "",
"rel": "unchecked",
"tag": [""],
"note": [
""
],
"type": "",
"subtype": "",
"name": "",
"link": [""]
}
`;
var render = () => {
var
rule = JSON.parse(document.querySelector('#sampleRule textarea').value),
changeset = JSON.parse(document.querySelector('#changeset').innerHTML);
document.querySelector('#renderedRule').innerHTML = renderRule(rule);
document.querySelector('#renderedChangeset').innerHTML = changeset.changeset.map(renderRule).join('');
}
var listen = () => {
var renderedRule = document.querySelector('#renderedRule');
var ruleTA = document.querySelector('#sampleRule textarea');
var ruleText = JSON.parse(ruleTA.value);
ruleTA.addEventListener('input', render);
ruleTA.addEventListener('change', render);
render();
}
listen();
</script>
</body>
</html>