Skip to content

Commit

Permalink
Update style, format code
Browse files Browse the repository at this point in the history
  • Loading branch information
kbseah committed Dec 30, 2024
1 parent 733046f commit 07aecff
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 32 deletions.
64 changes: 45 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,27 @@ <h2>Input • 輸入</h2>
<fieldset>
<legend>Dictionary for character readings</legend>
<div class="radio">
<input type="radio" id="dict_lim_1997" name="choose_dict" value="lim_1997" checked />
<label for="dict_lim_1997">《新編潮州音字典》林倫倫主編,汕頭大學出版社(1997修訂本)</label>
<input
type="radio"
id="dict_lim_1997"
name="choose_dict"
value="lim_1997"
checked
/>
<label for="dict_lim_1997"
>《新編潮州音字典》林倫倫主編,汕頭大學出版社(1997修訂本)</label
>
</div>
<div class="radio">
<input type="radio" id="dict_ghou_1983" name="choose_dict" value="ghou_1983" />
<label for="dict_ghou_1983">《潮州音字典》吳華重、林適民主編,廣東人民出版社(1983)</label>
<input
type="radio"
id="dict_ghou_1983"
name="choose_dict"
value="ghou_1983"
/>
<label for="dict_ghou_1983"
>《潮州音字典》吳華重、林適民主編,廣東人民出版社(1983)</label
>
</div>
</fieldset>
</div>
Expand All @@ -67,12 +82,14 @@ <h2>Input • 輸入</h2>

<div class="lightpink">
<h2>Output • 輸出</h2>
<div id="outputdiv">
<div class="outputdiv" id="outputdiv">
<span style="color: grey">[output will appear here]</span>
</div>
<p>Colors: <span style="color:blue">literary reading 文讀音</span>; <span style="color:green">semantic gloss reading 訓讀音</span>.</p>
<div id="outputdiv2">
</div>
<p>
Colors: <span style="color: blue">literary reading 文讀音</span>;
<span style="color: green">semantic gloss reading 訓讀音</span>.
</p>
<div class="outputdiv" id="outputdiv2"></div>
</div>
<div>
<h2>Details</h2>
Expand All @@ -82,18 +99,27 @@ <h2>Details</h2>
entry in <a href="https://en.wiktionary.org/">Wiktionary</a>.
</p>

<p>
Data sources • 資料來源:
<ul>
<li>《潮州音字典》吳華重、林適民主編,廣東人民出版社(1983), digitized by 騰達 (<a href="https://github.com/kahaani/dieghv">source</a>). Teochew prefectural city pronunciation; literary/gloss reading data not available.</li>
<li>《新編潮州音字典》林倫倫主編,汕頭大學出版社(1997修訂本). Swatow pronunciation; literary/gloss reading data available.</li>
<li>Word data is from English Wiktionary (version 2022-01-01), which is released under a CC-BY-SA 4.0 license; refer to linked entries for contributor information.</li>
</ul>
</p>
<p>Data sources • 資料來源:</p>
<ul>
<li>
《潮州音字典》吳華重、林適民主編,廣東人民出版社(1983), digitized by
騰達 (<a href="https://github.com/kahaani/dieghv">source</a>). Teochew
prefectural city pronunciation; literary/gloss reading data not
available.
</li>
<li>
《新編潮州音字典》林倫倫主編,汕頭大學出版社(1997修訂本). Swatow
pronunciation; literary/gloss reading data available.
</li>
<li>
Word data is from
<a href="https://en.wiktionary.org/">English Wiktionary</a> (version
2022-01-01), which is released under a CC-BY-SA 4.0 license; refer to
linked entries for contributor information.
</li>
</ul>

<p>
Example text is from 《潮州方言》李永明著,中華書局(1959年).
</p>
<p>Example text is from 《潮州方言》李永明著,中華書局(1959年).</p>
<p>
<strong>NB: Still in beta testing!</strong>
</p>
Expand Down
10 changes: 5 additions & 5 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ div {
background: lightpink;
}

#outputdiv {
.outputdiv {
font-size: 1.2em;
background: white;
background: floralwhite;
padding: 0.5em;
}

#outputdiv a:link {
.outputdiv a:link {
color: darkblue;
text-decoration: none;
}

#outputdiv a:visited {
.outputdiv a:visited {
color: darkblue;
text-decoration: none;
}

#outputdiv a:hover {
.outputdiv a:hover {
color: lightblue;
text-decoration: none;
}
Expand Down
25 changes: 17 additions & 8 deletions webscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function processLine(line, chardict) {
for (const r of chardict[c]) {
// readings.push(r[0]);
if (r[1] && r[1].includes("文")) {
readings.push('<span style="color:blue;">' + r[0] + '</span>');
readings.push('<span style="color:blue;">' + r[0] + "</span>");
} else if (r[1] && r[1].includes("訓")) {
readings.push('<span style="color:green;">' + r[0] + '</span>');
readings.push('<span style="color:green;">' + r[0] + "</span>");
} else {
readings.push(r[0]);
}
Expand Down Expand Up @@ -48,9 +48,9 @@ function processLine(line, chardict) {
function scan_input(text, n, dictionary) {
let indices = [];
let num_chunks = text.length - n + 1;
for (let i = 0; i < num_chunks; i++ ) {
let slice = text.slice(i, i+n);
if ( slice in dictionary ) {
for (let i = 0; i < num_chunks; i++) {
let slice = text.slice(i, i + n);
if (slice in dictionary) {
let pron = dictionary[slice].map((x) => x[0]);
indices.push([i, slice, pron]);
}
Expand All @@ -68,11 +68,19 @@ function scan_input_range(text, dictionary, n_min = 2, n_max = 5) {
return all_output;
}

function annotate_words(text, dictionary, n_max=5) {
function annotate_words(text, dictionary, n_max = 5) {
let raw = scan_input_range(text, dictionary, 2, n_max);
let out = [];
for (var elem of raw) {
out.push('<li><a href="https://en.wiktionary.org/wiki/' + elem[1] + '">' + elem[1] + '</a> : ' + elem[2].join(" / ") + "</li>\n");
out.push(
'<li><a href="https://en.wiktionary.org/wiki/' +
elem[1] +
'">' +
elem[1] +
"</a> : " +
elem[2].join(" / ") +
"</li>\n",
);
}
return out;
}
Expand All @@ -98,5 +106,6 @@ button.addEventListener("click", function () {
document.getElementById("outputdiv").innerHTML = out.join("<br/>");
let out2 = annotate_words(input, wd.chardict, 5);
console.log(input);
document.getElementById("outputdiv2").innerHTML = "<ul>" + out2.join("") + "</ul>";
document.getElementById("outputdiv2").innerHTML =
"Potential words found: <ul>" + out2.join("") + "</ul>";
});

0 comments on commit 07aecff

Please sign in to comment.