This commit is contained in:
wareya committed 2018-02-07 08:15:44 -05:00
1 parent 78eb8734f2
commit f6ee856438
1 file changed
+35 -29
+35 -29
View File
@@ -845,8 +845,10 @@ function add_epwing_info(lookups)
let text = spelling.keb; let text = spelling.keb;
if (lookup_epwing_kan.has(text)) if (lookup_epwing_kan.has(text))
{ {
console.log("looking for epwing possibilities"); let possibilities = copy_gen(lookup_epwing_kan.get(text));
let possibilities = lookup_epwing_kan.get(text);
console.log(text);
console.log(possibilities);
// FIXME this is disgusting // FIXME this is disgusting
let priority = []; let priority = [];
@@ -868,58 +870,60 @@ function add_epwing_info(lookups)
possibilities = priority.concat(possibilities); possibilities = priority.concat(possibilities);
priority = []; priority = [];
console.log(possibilities);
for(let wing of possibilities) for(let wing of possibilities)
{ {
console.log("checking an epwing possibility"); let epw = copy(epwing[wing]);
if(epwing[wing] && epwing[wing]["l"]) if(epw && epw["l"])
{ {
if(epwing_data == undefined) if(epwing_data == undefined)
{ {
epwing_data = epwing[wing]; epwing_data = epw;
exact = epwing[wing]["r"].includes(foundtext); exact = epw["r"].includes(foundtext);
for(let spelling of epwing[wing]["s"]) for(let spelling of epw["s"])
exact |= spelling.includes(foundtext); exact |= spelling.includes(foundtext);
// FIXME duplicated below // FIXME duplicated below
if(exact) if(exact)
{ {
for(let reading of entry.r_ele) for(let reading of entry.r_ele)
{ {
let text = reading.reb; let rtext = reading.reb;
if(epwing[wing]["r"].includes(text)) if(epw["r"].includes(rtext))
exact = 2; exact = 2;
} }
} }
} }
else if(exact == 0) else if(exact == 0)
{ {
exact |= epwing[wing]["r"].includes(foundtext); exact |= epw["r"].includes(foundtext);
for(let spelling of epwing[wing]["s"]) for(let spelling of epw["s"])
exact |= spelling.includes(foundtext); exact |= spelling.includes(foundtext);
if(exact) if(exact)
{ {
for(let reading of entry.r_ele) for(let reading of entry.r_ele)
{ {
let text = reading.reb; let rtext = reading.reb;
if(epwing[wing]["r"].includes(text)) if(epw["r"].includes(rtext))
exact = 2; exact = 2;
} }
epwing_data = epwing[wing]; epwing_data = epw;
} }
} }
else if(exact == 1) else if(exact == 1)
{ {
let maybe_more_exact = epwing[wing]["r"].includes(foundtext); let maybe_more_exact = epw["r"].includes(foundtext);
for(let spelling of epwing[wing]["s"]) for(let spelling of epw["s"])
maybe_more_exact |= spelling.includes(foundtext); maybe_more_exact |= spelling.includes(foundtext);
if(maybe_more_exact) if(maybe_more_exact)
{ {
for(let reading of entry.r_ele) for(let reading of entry.r_ele)
{ {
let text = reading.reb; let text = reading.reb;
if(epwing[wing]["r"].includes(text)) if(epw["r"].includes(text))
{ {
exact = 2; exact = 2;
epwing_data = epwing[wing]; epwing_data = epw;
} }
} }
} }
@@ -935,33 +939,31 @@ function add_epwing_info(lookups)
{ {
let text = reading.reb; let text = reading.reb;
console.log(`checking if lookup ${text} in structure`);
if (lookup_epwing_kana.has(text)) if (lookup_epwing_kana.has(text))
{ {
console.log("looking for epwing possibilities"); let possibilities = copy_gen(lookup_epwing_kana.get(text));
let possibilities = lookup_epwing_kana.get(text);
for(let wing of possibilities) for(let wing of possibilities)
{ {
console.log("checking an epwing possibility"); let epw = copy(epwing[wing]);
if(epwing[wing] && epwing[wing]["l"]) if(epw && epw["l"])
{ {
if(epwing_data == undefined) if(epwing_data == undefined)
{ {
epwing_data = epwing[wing]; epwing_data = epw;
exact = epwing[wing]["r"].includes(foundtext); exact = epw["r"].includes(foundtext);
} }
else if(exact == 0) else if(exact == 0)
{ {
exact |= epwing[wing]["r"].includes(foundtext); exact |= epw["r"].includes(foundtext);
if(exact) if(exact)
epwing_data = epwing[wing]; epwing_data = epw;
} }
else if(exact == 1) else if(exact == 1)
{ {
if(epwing[wing]["s"].length == 1 && epwing[wing]["s"][0] === "" && epwing[wing]["r"].includes(foundtext)) if(epw["s"].length == 1 && epw["s"][0] === "" && epw["r"].includes(foundtext))
{ {
exact = 2; exact = 2;
epwing_data = epwing[wing]; epwing_data = epw;
} }
} }
} }
@@ -1157,6 +1159,10 @@ function copy(orig)
} }
return mine; return mine;
} }
function copy_gen(orig)
{
return orig.slice(0);
}
// Restrict the listed spellings/readings of a JMdict entry to the ones allowed by the looked-up text. // Restrict the listed spellings/readings of a JMdict entry to the ones allowed by the looked-up text.
function restrict_by_text(entry, text) function restrict_by_text(entry, text)
{ {