update jmdict, fix minor bugs

This commit is contained in:
wareya committed 2018-05-29 07:21:49 -04:00
1 parent c761cee0ac
commit 8be6ca0f61
3 files changed
+67 -14

No files matched your search

+46 -6
View File
@@ -69,6 +69,8 @@ let dictsloaded = 0;
function builddict() function builddict()
{ {
console.log("load");
console.log(this);
if (this.readyState === 4) if (this.readyState === 4)
{ {
if (this.status === 200) if (this.status === 200)
@@ -81,6 +83,32 @@ function builddict()
} }
} }
/*
function handle_error()
{
console.log("error");
console.log(this.responseURL);
}
function handle_progress()
{
console.log("progress");
console.log(this.responseURL);
}
function handle_abort()
{
console.log("abort");
console.log(this.responseURL);
}
function handle_timeout()
{
console.log("timeout");
console.log(this.responseURL);
}
*/
// Having a >4MB flat text file with stupid adhoc formatting is okay // Having a >4MB flat text file with stupid adhoc formatting is okay
// but having a >4MB json file with nothing weird in it isn't // but having a >4MB json file with nothing weird in it isn't
// Thanks, linter team! // Thanks, linter team!
@@ -88,10 +116,17 @@ function load_part_of_dictionary(filename)
{ {
let req = new XMLHttpRequest(); let req = new XMLHttpRequest();
req.addEventListener("load", builddict); req.addEventListener("load", builddict);
/*
req.addEventListener("error", handle_error);
req.addEventListener("progress", handle_progress);
req.addEventListener("abort", handle_abort);
req.addEventListener("timeout", handle_timeout);
*/
req.open("GET", browser.extension.getURL(filename)); req.open("GET", browser.extension.getURL(filename));
req.send(); req.send();
return req; return req;
} }
load_part_of_dictionary("dict/JMdict1.json"); load_part_of_dictionary("dict/JMdict1.json");
load_part_of_dictionary("dict/JMdict2.json"); load_part_of_dictionary("dict/JMdict2.json");
load_part_of_dictionary("dict/JMdict3.json"); load_part_of_dictionary("dict/JMdict3.json");
@@ -102,6 +137,7 @@ load_part_of_dictionary("dict/JMdict7.json");
load_part_of_dictionary("dict/JMdict8.json"); load_part_of_dictionary("dict/JMdict8.json");
load_part_of_dictionary("dict/JMdict9.json"); load_part_of_dictionary("dict/JMdict9.json");
load_part_of_dictionary("dict/JMdict10.json"); load_part_of_dictionary("dict/JMdict10.json");
load_part_of_dictionary("dict/JMdict11.json");
function buildlookups() function buildlookups()
{ {
@@ -142,7 +178,7 @@ function buildlookups()
let waiter = undefined; let waiter = undefined;
function waittobuildlookups() function waittobuildlookups()
{ {
if(dictsloaded == 10) if(dictsloaded == 11)
{ {
clearInterval(waiter); clearInterval(waiter);
waiter = undefined; waiter = undefined;
@@ -391,8 +427,8 @@ rules.push({type: "stdrule", dec_end:"", con_end:"だ", dec_tag:"stem-ren-less-v
// rules.push({type: "stdrule", dec_end:"", con_end:"て", dec_tag:"stem-ren", con_tag:"stem-te", detail:"(te form)"}); // unusual but real but don't necessarily want it yet // rules.push({type: "stdrule", dec_end:"", con_end:"て", dec_tag:"stem-ren", con_tag:"stem-te", detail:"(te form)"}); // unusual but real but don't necessarily want it yet
rules.push({type: "stdrule", dec_end:"", con_end:"った", dec_tag:"stem-ka", con_tag:"stem-past", detail:"past"}); rules.push({type: "stdrule", dec_end:"", con_end:"った", dec_tag:"stem-ka", con_tag:"stem-past", detail:"past"});
// we want some te forms to only apply to verbs, not adjectives // we may want some te forms to only apply to verbs, not adjectives
// FIXME: need a way to not break ~ないでください, ~ないでいく, etc // FIXME: need a way to not break ~ないでください, ~ないでいく, etc before we actually do it
rules.push({type: "stdrule", dec_end:"", con_end:"て", dec_tag:"stem-ren-less", con_tag:"stem-te-verbal", detail:"(te form)"}); rules.push({type: "stdrule", dec_end:"", con_end:"て", dec_tag:"stem-ren-less", con_tag:"stem-te-verbal", detail:"(te form)"});
rules.push({type: "stdrule", dec_end:"", con_end:"で", dec_tag:"stem-ren-less-v", con_tag:"stem-te-verbal", detail:"(te form)"}); rules.push({type: "stdrule", dec_end:"", con_end:"で", dec_tag:"stem-ren-less-v", con_tag:"stem-te-verbal", detail:"(te form)"});
// tag alias // tag alias
@@ -404,6 +440,7 @@ rules.push({type: "stdrule", dec_end:"", con_end:"で", dec_tag:"stem-ku", con_t
// doesn't have anywhere else to go // doesn't have anywhere else to go
rules.push({type: "rewriterule", dec_end:"です", con_end:"でした", dec_tag:"exp", con_tag:"stem-past", detail:"past"}); rules.push({type: "rewriterule", dec_end:"です", con_end:"でした", dec_tag:"exp", con_tag:"stem-past", detail:"past"});
rules.push({type: "rewriterule", dec_end:"です", con_end:"でして", dec_tag:"exp", con_tag:"stem-te-verbal", detail:"(te form)"});
// TODO: add te form of です? or would it be too confusing to have? // TODO: add te form of です? or would it be too confusing to have?
// e.g. it would let people find "でしている" in "自分でしている" as です instead of で + conjugated する // e.g. it would let people find "でしている" in "自分でしている" as です instead of で + conjugated する
@@ -465,11 +502,12 @@ rules.push({type: "contextrule", contextrule: "saspecial", dec_end:"", con_end:"
//////////////////// ////////////////////
// mere te auxiliaries // mere te auxiliaries
rules.push({type: "stdrule", dec_end:"", con_end:"しまう", dec_tag:"stem-te", con_tag:"v5u", detail:"completely/end up/perfect"}); rules.push({type: "stdrule", dec_end:"", con_end:"しまう", dec_tag:"stem-te", con_tag:"v5u", detail:"finish/completely/end up"});
// personal te auxiliaries // personal te auxiliaries
rules.push({type: "stdrule", dec_end:"", con_end:"ください", dec_tag:"stem-te", con_tag:"adj-i", detail:"polite request"}); rules.push({type: "stdrule", dec_end:"", con_end:"ください", dec_tag:"stem-te", con_tag:"adj-i", detail:"polite request"});
rules.push({type: "stdrule", dec_end:"", con_end:"あげる", dec_tag:"stem-te", con_tag:"v5r", detail:"do for someone"}); rules.push({type: "stdrule", dec_end:"", con_end:"あげる", dec_tag:"stem-te", con_tag:"v5r", detail:"do for someone"});
// garmmatical aspect forms // grammatical aspect forms
// FIXME: add the てる とる etc. conjugations; though the てる conjugation needs a bunch of annoying traps
rules.push({type: "stdrule", dec_end:"", con_end:"いる", dec_tag:"stem-te", con_tag:"v1", detail:"teiru"}); rules.push({type: "stdrule", dec_end:"", con_end:"いる", dec_tag:"stem-te", con_tag:"v1", detail:"teiru"});
rules.push({type: "stdrule", dec_end:"", con_end:"おる", dec_tag:"stem-te", con_tag:"v5r", detail:"teoru"}); rules.push({type: "stdrule", dec_end:"", con_end:"おる", dec_tag:"stem-te", con_tag:"v5r", detail:"teoru"});
rules.push({type: "stdrule", dec_end:"", con_end:"ある", dec_tag:"stem-te", con_tag:"v5r-i", detail:"tearu"}); rules.push({type: "stdrule", dec_end:"", con_end:"ある", dec_tag:"stem-te", con_tag:"v5r-i", detail:"tearu"});
@@ -509,6 +547,7 @@ rules.push({type: "stdrule", dec_end:"でしまう", con_end:"じまう", dec_ta
rules.push({type: "stdrule", dec_end:"ては", con_end:"ちゃ", dec_tag:"stem-te", con_tag:"uninflectable", detail:"(contraction)"}); rules.push({type: "stdrule", dec_end:"ては", con_end:"ちゃ", dec_tag:"stem-te", con_tag:"uninflectable", detail:"(contraction)"});
rules.push({type: "stdrule", dec_end:"では", con_end:"じゃ", dec_tag:"stem-te", con_tag:"uninflectable", detail:"(contraction)"}); rules.push({type: "stdrule", dec_end:"では", con_end:"じゃ", dec_tag:"stem-te", con_tag:"uninflectable", detail:"(contraction)"});
rules.push({type: "onlyfinalrule", dec_end:"ければ", con_end:"けりゃ", dec_tag:"uninflectable", con_tag:"uninflectable", detail:"(contraction)"});
rules.push({type: "onlyfinalrule", dec_end:"ければ", con_end:"きゃ", dec_tag:"uninflectable", con_tag:"uninflectable", detail:"(contraction)"}); rules.push({type: "onlyfinalrule", dec_end:"ければ", con_end:"きゃ", dec_tag:"uninflectable", con_tag:"uninflectable", detail:"(contraction)"});
// other // other
@@ -1106,7 +1145,7 @@ function sort_results(text, results)
if(weird_lookup(entry.found)) if(weird_lookup(entry.found))
entry.priority -= 50; entry.priority -= 50;
if(reading_kana == result_kana) if(reading_kana == result_kana && !entry.deconj) // !entry.deconj fixes なって
entry.priority += 100; entry.priority += 100;
if(has_pri(entry)) if(has_pri(entry))
entry.priority += 30; entry.priority += 30;
@@ -1128,6 +1167,7 @@ function sort_results(text, results)
// FIXME: prefer short deconjugations to long deconjugations, not just no deconjugations to any deconjugations // FIXME: prefer short deconjugations to long deconjugations, not just no deconjugations to any deconjugations
if(entry.deconj) if(entry.deconj)
entry.priority -= 1; entry.priority -= 1;
console.log(entry);
} }
results.sort((a,b)=> results.sort((a,b)=>
+1
View File
@@ -38,6 +38,7 @@
"dict/JMdict8.json", "dict/JMdict8.json",
"dict/JMdict9.json", "dict/JMdict9.json",
"dict/JMdict10.json", "dict/JMdict10.json",
"dict/JMdict11.json",
"reader.js", "reader.js",
"reader.html", "reader.html",
"mining.js", "mining.js",
+20 -8
View File
@@ -49,9 +49,17 @@ let platform = "win";
async function get_real_platform() async function get_real_platform()
{ {
let my_platform = await browser.runtime.sendMessage({type:"platform"});
while(my_platform == "") let my_platform = undefined;
try {
my_platform = await browser.runtime.sendMessage({type:"platform"}); my_platform = await browser.runtime.sendMessage({type:"platform"});
}catch(err){}
while(my_platform == "")
{
try {
my_platform = await browser.runtime.sendMessage({type:"platform"});
}catch(err){}
}
platform = my_platform; platform = my_platform;
} }
get_real_platform(); get_real_platform();
@@ -487,16 +495,18 @@ function build_div_inner (text, result, moreText, index, first_of_many = false)
} }
if(formtext != "") if(formtext != "")
{ {
temptag.appendChild(document.createElement("wbr"));
if(first) if(first)
deconj += "~"; deconj = "~";
else else
deconj += "・"; deconj = "・";
deconj += formtext; temptag.appendChild(document.createTextNode(deconj));
temptag.appendChild(document.createElement("wbr"));
deconj = formtext;
temptag.appendChild(document.createTextNode(deconj));
} }
first = false; first = false;
} }
temptag.appendChild(document.createElement("wbr"));
temptag.appendChild(document.createTextNode(deconj));
} }
if(k_ele.inf) if(k_ele.inf)
{ {
@@ -1422,7 +1432,9 @@ function keytest(event)
document.body.getElementsByClassName("nazeka_mining_ui")[0].remove(); document.body.getElementsByClassName("nazeka_mining_ui")[0].remove();
}); });
mydiv.firstChild.firstChild.prepend(newheader); mydiv.firstChild.firstChild.prepend(newheader);
mydiv.style.zIndex = 1000000000000000000000-1; mydiv.style.zIndex = 1000000000000000000000;
// do not compound! z-index can be range limited by the browser
mydiv.style.zIndex -= 1;
for(let keb of mydiv.getElementsByClassName("nazeka_main_keb")) for(let keb of mydiv.getElementsByClassName("nazeka_main_keb"))
{ {