fix epwing lookup reading priority
This commit is contained in:
1 parent
33725e603f
commit
031ae7c5c6
1 file changed
+79
-32
+79
-32
@@ -9,6 +9,7 @@
|
|||||||
// Seriously.
|
// Seriously.
|
||||||
|
|
||||||
let epwing = [
|
let epwing = [
|
||||||
|
// Fill this out with some testing data from a json file generated by zero-epwing so that it looks something like this screenshot: https://i.imgur.com/waTYH1i.png
|
||||||
];
|
];
|
||||||
let lookup_epwing_kan = new Map();
|
let lookup_epwing_kan = new Map();
|
||||||
let lookup_epwing_kana = new Map();
|
let lookup_epwing_kana = new Map();
|
||||||
@@ -41,6 +42,7 @@ function add_epwing_id(id, i)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this is almost certainly only the format of the kenkyuusha epwing dictionary. others might be completely different.
|
||||||
for (let i = 0; i < epwing.length; i++)
|
for (let i = 0; i < epwing.length; i++)
|
||||||
{
|
{
|
||||||
let heading = epwing[i]["heading"];
|
let heading = epwing[i]["heading"];
|
||||||
@@ -272,15 +274,6 @@ function search_inner(text)
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
function search_inner_epwing(text)
|
|
||||||
{
|
|
||||||
if (lookup_epwing_kan.has(text))
|
|
||||||
return epwing[lookup_epwing_kan.get(text)];
|
|
||||||
else if (lookup_epwing_kana.has(text))
|
|
||||||
return epwing[lookup_epwing_kana.get(text)];
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function search(text)
|
function search(text)
|
||||||
{
|
{
|
||||||
@@ -838,30 +831,8 @@ function build_lookup_comb (forms)
|
|||||||
{
|
{
|
||||||
for(let entry of result)
|
for(let entry of result)
|
||||||
{
|
{
|
||||||
//console.log("testing A");
|
|
||||||
//print_object(entry);
|
|
||||||
if(entry.deconj)
|
if(entry.deconj)
|
||||||
{
|
{
|
||||||
let epwing_data = "";
|
|
||||||
if(entry.k_ele)
|
|
||||||
{
|
|
||||||
for(let spelling of entry.k_ele)
|
|
||||||
{
|
|
||||||
let res = search_inner_epwing(spelling.keb);
|
|
||||||
if(res && res["text"])
|
|
||||||
epwing_data = res["text"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(epwing_data == "" && entry.r_ele)
|
|
||||||
{
|
|
||||||
for(let spelling of entry.r_ele)
|
|
||||||
{
|
|
||||||
let res = search_inner_epwing(spelling.reb);
|
|
||||||
if(res && res["text"])
|
|
||||||
epwing_data = res["text"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry.epwing = epwing_data;
|
|
||||||
merger.push(entry);
|
merger.push(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -873,6 +844,82 @@ function build_lookup_comb (forms)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function add_epwing_info(lookups)
|
||||||
|
{
|
||||||
|
for(let lookup of lookups)
|
||||||
|
{
|
||||||
|
for(let entry of lookup.result)
|
||||||
|
{
|
||||||
|
// look for an epwing entry that matches this lookup and jmdict entry
|
||||||
|
let epwing_data = "";
|
||||||
|
let foundtext = undefined;
|
||||||
|
if(entry.orig_found.keb)
|
||||||
|
foundtext = entry.orig_found.keb;
|
||||||
|
else
|
||||||
|
foundtext = entry.orig_found.reb;
|
||||||
|
|
||||||
|
let exact = false;
|
||||||
|
if(entry.k_ele)
|
||||||
|
{
|
||||||
|
for(let spelling of entry.k_ele)
|
||||||
|
{
|
||||||
|
let text = spelling.keb;
|
||||||
|
if (lookup_epwing_kan.has(text))
|
||||||
|
{
|
||||||
|
let possibilities = lookup_epwing_kan.get(text);
|
||||||
|
for(let wing of possibilities)
|
||||||
|
{
|
||||||
|
if(epwing[wing] && epwing[wing]["text"])
|
||||||
|
{
|
||||||
|
if(epwing_data == "")
|
||||||
|
{
|
||||||
|
epwing_data = epwing[wing]["text"];
|
||||||
|
// FIXME: using .includes() is too loose. just simpler than adding real arrays of spellings/readings to the epwing data on load.
|
||||||
|
exact = (epwing[wing]["heading"].includes(foundtext) || epwing[wing]["text"].includes(foundtext));
|
||||||
|
}
|
||||||
|
else if(!exact && (epwing[wing]["heading"].includes(foundtext) || epwing[wing]["text"].includes(foundtext)))
|
||||||
|
{
|
||||||
|
epwing_data = epwing[wing]["text"];
|
||||||
|
exact = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(epwing_data == "" && entry.r_ele)
|
||||||
|
{
|
||||||
|
for(let spelling of entry.r_ele)
|
||||||
|
{
|
||||||
|
let text = spelling.reb;
|
||||||
|
if (lookup_epwing_kana.has(text))
|
||||||
|
{
|
||||||
|
let possibilities = lookup_epwing_kana.get(text);
|
||||||
|
for(let wing of possibilities)
|
||||||
|
{
|
||||||
|
if(epwing[wing] && epwing[wing]["text"])
|
||||||
|
{
|
||||||
|
if(epwing_data == "")
|
||||||
|
{
|
||||||
|
epwing_data = epwing[wing]["text"];
|
||||||
|
exact = (epwing[wing]["heading"].includes(foundtext) || epwing[wing]["text"].includes(foundtext));
|
||||||
|
}
|
||||||
|
else if(!exact && (epwing[wing]["heading"].includes(foundtext) || epwing[wing]["text"].includes(foundtext)))
|
||||||
|
{
|
||||||
|
epwing_data = epwing[wing]["text"];
|
||||||
|
exact = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry.epwing = epwing_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lookups;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function is_kana(object)
|
function is_kana(object)
|
||||||
@@ -1223,7 +1270,7 @@ function skip_rereferenced_entries(results)
|
|||||||
if(newlookup.length > 0)
|
if(newlookup.length > 0)
|
||||||
newresults.push({text:lookup.text, result:newlookup});
|
newresults.push({text:lookup.text, result:newlookup});
|
||||||
}
|
}
|
||||||
return newresults;
|
return add_epwing_info(newresults); // add epwing entries now
|
||||||
}
|
}
|
||||||
|
|
||||||
let last_lookup = "";
|
let last_lookup = "";
|
||||||
|
|||||||
Reference in new issue
Block a user