hacky support for looking up words with no jmdict entries, as long as they don't require deconjugation
This commit is contained in:
1 parent
c8b1f296fc
commit
2d80feeae9
2 files changed
+45
-13
No files matched your search
+39
-11
@@ -128,6 +128,25 @@ async function migrate_legacy_then_refresh()
|
|||||||
|
|
||||||
migrate_legacy_then_refresh();
|
migrate_legacy_then_refresh();
|
||||||
|
|
||||||
|
function json_lookup_arbitrary_as_is(dict, text)
|
||||||
|
{
|
||||||
|
let index = dict.lookup_json_kan.get(text);
|
||||||
|
if(index === undefined)
|
||||||
|
index = dict.lookup_json_kana.get(text);
|
||||||
|
if(index === undefined)
|
||||||
|
return undefined;
|
||||||
|
return copy(dict.entries[index]);
|
||||||
|
}
|
||||||
|
function json_dict_any_as_is(text)
|
||||||
|
{
|
||||||
|
for(let dict of json_dicts)
|
||||||
|
{
|
||||||
|
let ret = json_lookup_arbitrary_as_is(dict, text);
|
||||||
|
if(ret !== undefined)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
let dict = [];
|
let dict = [];
|
||||||
let lookup_kan = new Map();
|
let lookup_kan = new Map();
|
||||||
@@ -404,6 +423,26 @@ function search(text)
|
|||||||
if(ret) return ret;
|
if(ret) return ret;
|
||||||
ret = search_inner(replace_kata_with_hira(text));
|
ret = search_inner(replace_kata_with_hira(text));
|
||||||
if(ret) return ret;
|
if(ret) return ret;
|
||||||
|
ret = json_dict_any_as_is(text);
|
||||||
|
if(ret)
|
||||||
|
{
|
||||||
|
let r_ele = [{reb: ret.r}];
|
||||||
|
let k_ele = [];
|
||||||
|
let seq = "NONE_"+text;
|
||||||
|
let sense = [{gloss: [], pos: []}];
|
||||||
|
for(let spelling of ret.s)
|
||||||
|
{
|
||||||
|
if(spelling == "" || is_kana(spelling))
|
||||||
|
continue;
|
||||||
|
k_ele.push({keb: spelling});
|
||||||
|
}
|
||||||
|
let re_ret = undefined;
|
||||||
|
if(k_ele != [])
|
||||||
|
re_ret = [{k_ele: k_ele, r_ele: r_ele, seq: seq, sense: sense, from: text, found: k_ele[0]}];
|
||||||
|
else
|
||||||
|
re_ret = [{r_ele: r_ele, seq: seq, sense: sense, from: text, found: r_ele[0]}];
|
||||||
|
return re_ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// deconjugation rules
|
// deconjugation rules
|
||||||
@@ -841,16 +880,6 @@ function json_lookup_kana_inexact(dict, kana)
|
|||||||
return possibilities;
|
return possibilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
function json_lookup_arbitrary_as_is(dict, text)
|
|
||||||
{
|
|
||||||
let index = dict.lookup_json_kan.get(text);
|
|
||||||
if(index === undefined)
|
|
||||||
index = dict.lookup_json_kana.get(text);
|
|
||||||
if(index === undefined)
|
|
||||||
return undefined;
|
|
||||||
return copy(dict.entries[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_json_info(lookups, other_settings)
|
function add_json_info(lookups, other_settings)
|
||||||
{
|
{
|
||||||
for(let lookup of lookups)
|
for(let lookup of lookups)
|
||||||
@@ -935,7 +964,6 @@ function add_json_info(lookups, other_settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function is_kana(object)
|
function is_kana(object)
|
||||||
{
|
{
|
||||||
if(object.seq && object.k_ele)
|
if(object.seq && object.k_ele)
|
||||||
|
|||||||
+6
-2
@@ -437,7 +437,7 @@ function elementize_jmdict_defs(goodsenses)
|
|||||||
else
|
else
|
||||||
lastpos = sense.pos;
|
lastpos = sense.pos;
|
||||||
|
|
||||||
if(sense.pos)
|
if(sense.pos && sense.pos.length > 0)
|
||||||
{
|
{
|
||||||
let part = document.createElement("span");
|
let part = document.createElement("span");
|
||||||
part.className = "nazeka_pos";
|
part.className = "nazeka_pos";
|
||||||
@@ -985,7 +985,11 @@ function build_div_inner(text, result, moreText, index, first_of_many = false)
|
|||||||
let definition = document.createElement("div");
|
let definition = document.createElement("div");
|
||||||
definition.className = "nazeka_definitions";
|
definition.className = "nazeka_definitions";
|
||||||
|
|
||||||
let jmdict_div = elementize_jmdict_defs(term.sense);
|
let jmdict_div = undefined;
|
||||||
|
if(typeof term.seq == "string" && term.seq.startsWith("NONE_"))
|
||||||
|
jmdict_div = document.createElement("div");
|
||||||
|
else
|
||||||
|
jmdict_div = elementize_jmdict_defs(term.sense);
|
||||||
let json_div = elementize_json_defs(term.json);
|
let json_div = elementize_json_defs(term.json);
|
||||||
|
|
||||||
if (settings.definitions_mode == 0 || (settings.normal_definitions_in_mining && mining_ui_exists())) // normal
|
if (settings.definitions_mode == 0 || (settings.normal_definitions_in_mining && mining_ui_exists())) // normal
|
||||||
|
|||||||
Reference in new issue
Block a user