Large diffs are not rendered by default.

@@ -0,0 +1,33 @@
var translit = require("../helpers/translit.js").translit,
db = require("../helpers/db.js").db;

function do_translit(word, dont_check_base_form)
{
return translit(word, dont_check_base_form ? undefined : function (word)
{
var data = db.query_sync("SELECT `lexicon_greek`.base_word FROM `bible_original`, `lexicon_greek` WHERE `bible_original`.word like \"" + word + "\" AND `lexicon_greek`.strongs = `bible_original`.strongs LIMIT 1");

if (data && data[0] && data[0].word) {
return data[0].word;
}

return word;
});
}

///TODO: Confirm correct results.

console.log(do_translit("Α", true));
console.log(do_translit("Ω", true));
//process.exit();
console.log(do_translit("אֵלִיָּהוּ׃", true));
console.log(do_translit("אֵֽלִיָּֽהוּ׃", true));
console.log(do_translit("אֵֽלִיָּֽהוּפַּ֥", true));
console.log(do_translit("בְּרֵאשִׁ֖ית", true));
console.log(do_translit("תִּרְצָה", true));
console.log(do_translit("Ἑλληνιστί", true));
console.log(do_translit("ἐπυνθάνετο", true));
console.log(do_translit("ἐπυνθάνετο")); /// Should split after the Epsilon.
console.log(do_translit("ἐπαγγελλομέναις")); /// Should split after the Pi.
console.log(do_translit("תִּרְצָה ἐπυνθάνετο", true));
console.log(do_translit("תִּרְצָה ἐπυνθάνετο"));
@@ -0,0 +1,94 @@
<html>
<head>
<meta charset="utf-8">
<title>Translit.js</title>
<style>
#type_here {
width: 100%;
height: 200px;
font-family: "Ezra SIL", "SBL Hebrew", "Galatia SIL", "SBL Greek";
font-size: 24px;
}

p {
margin: 0;
font-family: Gentium, "Charis SIL", "Doulos SIL";
font-size: 18px;
}
</style>
</head>
<body>
Enter Greek and/or Hebrew below.
<textarea id=type_here>בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃
Βίβλος γενέσεως Ἰησοῦ Χριστοῦ, υἱοῦ Δαβίδ, υἱοῦ Ἀβραάμ</textarea>
<select id=trans_type>
<option value=dic>Biblical Reconstructed Dictionary Form</option>
<option value=ipa>Biblical Reconstructed IPA</option>
<option value=dic_mod>Modern Dictionary Form</option>
<option value=ipa_mod>Modern IPA</option>
<option value=sbl>Society of Biblical Languages Transliteration</option>
<select>
<div id=results></div>
</body>
<script src="../helpers/translit.js"></script>
<script>
var last_text,
last_type,
trans_type = document.getElementById("trans_type"),
type_here = document.getElementById("type_here"),
results_div = document.getElementById("results");

function show_results()
{
var data = {dic: "", ipa: "", dic_mod: "", ipa_mod: "", sbl: ""},
i,
len,
text = type_here.value,
text_arr,
tmp_data,
type = trans_type.value;

if (text === last_text && last_type === type) {
return;
}

last_text = text;
last_type = type;

text_arr = text.split(/\n/g);

len = text_arr.length;
for (i = 0; i < len; i += 1) {
tmp_data = translit(text_arr[i].replace(/\s+/g, " ").trim());
data.dic += "<p>" + tmp_data.dic + "</p>";
data.ipa += "<p>" + tmp_data.ipa + "</p>";
data.dic_mod += "<p>" + tmp_data.dic_mod + "</p>";
data.ipa_mod += "<p>" + tmp_data.ipa_mod + "</p>";
data.sbl += "<p>" + tmp_data.sbl + "</p>";
}


switch (type) {
case "dic":
results_div.innerHTML = data.dic;
break;
case "ipa":
results_div.innerHTML = data.ipa;
break;
case "dic_mod":
results_div.innerHTML = data.dic_mod;
break;
case "ipa_mod":
results_div.innerHTML = data.ipa_mod;
break;
case "sbl":
results_div.innerHTML = data.sbl;
break;
}
}

window.setInterval(show_results, 100);

show_results();
</script>
</html>
@@ -0,0 +1,79 @@
var translit = require("./translit.js").translit,
dbmysql = require("db-mysql"),
db = require("../helpers/db.js").db,
res;

function update_lexicon(type)
{
var amt = 200,
i = 0,
j,
json;

for (;;) {
res = db.query_sync("SELECT id, base_word, data FROM lexicon_" + type + " WHERE id >= " + i + " AND id < " + (i + amt));

if (!res || !res.length) {
break;
}

for (j = res.length - 1; j >= 0; j -= 1) {
json = JSON.parse(res[j].data);
///NOTE: Since these are all base forms, there is no need to look up another form.
json.pronun = translit(res[j].base_word.replace(/[\-\(\)]/g, ""));
json = JSON.stringify(json);

if (json !== res[j].data) {
console.log(res[j].id);
db.query_sync("UPDATE lexicon_" + type + " SET data = \"" + json.replace(/[\?\\"']/g, '\\$&') + "\" WHERE id = " + res[j].id);
}
}

i += amt;
}
}

console.log("Updating the Hebrew Lexicon");
update_lexicon("hebrew");
console.log("Updating the Greek Lexicon");
update_lexicon("greek");

console.log("Updating the Original Languages");
(function ()
{
var amt = 200,
i = 0,
j,
json;

for (;;) {
res = db.query_sync("SELECT id, word, pronun, strongs FROM bible_original WHERE id >= " + i + " AND id < " + (i + amt));

if (!res || !res.length) {
break;
}

for (j = res.length - 1; j >= 0; j -= 1) {
json = res[j].pronun === "" ? "" : JSON.parse(res[j].pronun);
json = translit(res[j].word, function ()
{
var base_res = db.query_sync("SELECT base_word FROM lexicon_greek WHERE strongs = " + res[j].strongs);

if (base_res && base_res[0].base_word) {
return base_res[0].base_word;
}

console.log("Could not find base form.");
return res[j].word;
});
json = JSON.stringify(json);

if (json !== res[j].pronun) {
console.log(res[j].id);
db.query_sync("UPDATE bible_original SET pronun = \"" + json.replace(/[\?\\"']/g, '\\$&') + "\" WHERE id = " + res[j].id);
}
}

i += amt;
}
}());