Skip to content

Commit

Permalink
⟦lexicon.html⟧: Adding line breaks and replacing space intentation wi…
Browse files Browse the repository at this point in the history
…th tabs.
  • Loading branch information
Ntsekees committed Nov 30, 2023
1 parent 078773b commit d1b4156
Showing 1 changed file with 94 additions and 85 deletions.
179 changes: 94 additions & 85 deletions lexicon.html
Original file line number Diff line number Diff line change
@@ -1,88 +1,97 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Nahaıwa lexicon</title>
<style type="text/css">
table {
border-collapse: collapse;
border: 1px solid black;
}
td {
border: 1px solid black;
padding: 3px;
}
</style>
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.2/d3.js">
</script>
<script type="text/javascript">
function is_array(v) {
return Object.prototype.toString.call(v) === '[object Array]';
}
function is_undefined(v) {
return Object.prototype.toString.call(v) === '[object Undefined]';
}
g_lexicon = [];
</script>
</head>
<body>
<input type="checkbox" id="sorting_checkbox" name="sorting_checkbox" checked=false onchange="proceed(g_lexicon);" />
<label for="sorting_checkbox">Sort by semantic category</label>
<br /><br />
<span id="lexemes_stats"></span>
<br /><br />
<div id="content">(LEXICON NOT YET LOADED!)</div>
<script type="text/javascript">
function compare(a, b) {
if(a === "") {
return 1;
} else if(b === "") {
return -1;
} else {
return a < b ? -1 : a > b ? 1 : 0;
}
}
function proceed(lexicon) {
shall_sort_by_semantic_tags =
document.getElementById("sorting_checkbox").checked;
lexicon = lexicon.sort((a, b) => {
if (shall_sort_by_semantic_tags)
return (
a.type.localeCompare(b.type)
|| compare(a.tags, b.tags)
|| compare(a.morpheme, b.morpheme))
else
return (
a.type.localeCompare(b.type)
|| compare(a.morpheme, b.morpheme))
});
s = "";
lexicon.forEach((e, i, l) => {
s += "<tr>\n";
s += "<td>" + e.morpheme + "</td>\n";
s += "<td>" + e.type + "</td>\n";
s += "<td>" + e.subtype + "</td>\n";
s += "<td>" + e.eng + "</td>\n";
s += "<td>" + e.tags + "</td>\n";
s += "<td>" + e.predilex_id + "</td>\n";
s += "</tr>\n";
});
content = "<table cellspacing='2px'>\n<thead>\n<td>Morpheme</td><td>Type</td><td>Subtype</td><td>Meaning</td><td>Tags</td><td>Predilex ID</td>\n</thead>\n<tbody>\n";
content += (s + "\n</tbody>\n</table>\n");
document.getElementById("content").innerHTML = content;
n_roots = lexicon.filter(e => e.type === "root").length;
n_extensions = lexicon.filter(e => e.type === "ext").length;
document.getElementById('lexemes_stats').innerHTML =
"Number of lexemes: " + (n_roots + n_extensions) +
" (" + n_roots + " roots, " + n_extensions +
" extensional prefixes).";
}
d3.tsv("lexicon.tsv", (tsv) => {
g_lexicon = tsv;
proceed(tsv);
});
</script>
</body>
<head>
<meta charset="UTF-8">
<title>Nahaıwa lexicon</title>
<style type="text/css">
table {
border-collapse: collapse;
border: 1px solid black;
}
td {
border: 1px solid black;
padding: 3px;
}
</style>
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.2/d3.js">
</script>
<script type="text/javascript">
function is_array(v) {
return Object.prototype.toString.call(v) === '[object Array]';
}
function is_undefined(v) {
return Object.prototype.toString.call(v) ===
'[object Undefined]';
}
g_lexicon = [];
</script>
</head>
<body>
<input
type="checkbox"
id="sorting_checkbox"
name="sorting_checkbox"
checked=false
onchange="proceed(g_lexicon);" />
<label for="sorting_checkbox">Sort by semantic category</label>
<br /><br />
<span id="lexemes_stats"></span>
<br /><br />
<div id="content">(LEXICON NOT YET LOADED!)</div>
<script type="text/javascript">
function compare(a, b) {
if(a === "") {
return 1;
} else if(b === "") {
return -1;
} else {
return a < b ? -1 : a > b ? 1 : 0;
}
}
function proceed(lexicon) {
shall_sort_by_semantic_tags =
document.getElementById("sorting_checkbox").checked;
lexicon = lexicon.sort((a, b) => {
if (shall_sort_by_semantic_tags)
return (
a.type.localeCompare(b.type)
|| compare(a.tags, b.tags)
|| compare(a.morpheme, b.morpheme))
else
return (
a.type.localeCompare(b.type)
|| compare(a.morpheme, b.morpheme))
});
s = "";
lexicon.forEach((e, i, l) => {
s += "<tr>\n";
s += "<td>" + e.morpheme + "</td>\n";
s += "<td>" + e.type + "</td>\n";
s += "<td>" + e.subtype + "</td>\n";
s += "<td>" + e.eng + "</td>\n";
s += "<td>" + e.tags + "</td>\n";
s += "<td>" + e.predilex_id + "</td>\n";
s += "</tr>\n";
});
content =
"<table cellspacing='2px'>\n<thead>\n<td>Morpheme</td>" +
"<td>Type</td><td>Subtype</td><td>Meaning</td>" +
"<td>Tags</td><td>Predilex ID</td>\n</thead>\n<tbody>\n";
content += (s + "\n</tbody>\n</table>\n");
document.getElementById("content").innerHTML = content;
n_roots = lexicon.filter(e => e.type === "root").length;
n_extensions = lexicon.filter(e => e.type === "ext").length;
document.getElementById('lexemes_stats').innerHTML =
"Number of lexemes: " + (n_roots + n_extensions) +
" (" + n_roots + " roots, " + n_extensions +
" extensional prefixes).";
}
d3.tsv("lexicon.tsv", (tsv) => {
g_lexicon = tsv;
proceed(tsv);
});
</script>
</body>
</html>

0 comments on commit d1b4156

Please sign in to comment.