fixup bananza
This commit is contained in:
1 parent
bdb7c02b9d
commit
14892beed9
5 files changed
+104
-173
No files matched your search
+18
-23
@@ -379,18 +379,9 @@ load_deconjugation_rules("dict/deconjugator.json");
|
||||
// return deconjugated form if stdrule applies to form, return otherwise
|
||||
function stdrule_deconjugate_inner(my_form, my_rule)
|
||||
{
|
||||
// can't deconjugate nothingness
|
||||
if(my_form.text == "")
|
||||
return;
|
||||
// ending doesn't match
|
||||
if(!my_form.text.endsWith(my_rule.con_end))
|
||||
return;
|
||||
// deconjugated form too much longer than conjugated form
|
||||
if(my_form.text.length > my_form.original_text.length+10)
|
||||
return;
|
||||
// impossibly information-dense
|
||||
if(my_form.tags.length > my_form.original_text.length+6)
|
||||
return;
|
||||
// tag doesn't match
|
||||
if(my_form.tags.length > 0 && my_form.tags[my_form.tags.length-1] != my_rule.con_tag)
|
||||
return;
|
||||
@@ -421,6 +412,19 @@ function stdrule_deconjugate_inner(my_form, my_rule)
|
||||
};
|
||||
function stdrule_deconjugate(my_form, my_rule)
|
||||
{
|
||||
// can't deconjugate nothingness
|
||||
if(my_form.text == "")
|
||||
return;
|
||||
// deconjugated form too much longer than conjugated form
|
||||
if(my_form.text.length > my_form.original_text.length+10)
|
||||
return;
|
||||
// impossibly information-dense
|
||||
if(my_form.tags.length > my_form.original_text.length+6)
|
||||
return;
|
||||
// blank detail mean it can't be the last (first applied, but rightmost) rule
|
||||
if(my_rule.detail == "" && my_form.tags.length == 0)
|
||||
return;
|
||||
|
||||
let array = undefined;
|
||||
// pick the first one that is an array
|
||||
// FIXME: use minimum length for safety reasons? assert all arrays equal length?
|
||||
@@ -496,19 +500,11 @@ neverfinalrule: neverfinalrule_deconjugate,
|
||||
contextrule: contextrule_deconjugate,
|
||||
};
|
||||
|
||||
function adjspecial_check(my_form, my_rule)
|
||||
function v1inftrap_check(my_form, my_rule)
|
||||
{
|
||||
if(my_form.tags.length != 2) return true;
|
||||
let my_tag = my_form.tags[my_form.tags.length-2];
|
||||
if(my_tag == "stem-adj-base")
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
function tetrap_check(my_form, my_rule)
|
||||
{
|
||||
if(my_form.tags.length < 2) return true;
|
||||
let my_tag = my_form.tags[my_form.tags.length-2];
|
||||
if(my_tag == "stem-te")
|
||||
if(my_form.tags.length != 1) return true;
|
||||
let my_tag = my_form.tags[0];
|
||||
if(my_tag == "stem-ren")
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
@@ -523,8 +519,7 @@ function saspecial_check(my_form, my_rule)
|
||||
};
|
||||
|
||||
let context_functions = {
|
||||
adjspecial: adjspecial_check,
|
||||
tetrap: tetrap_check,
|
||||
v1inftrap: v1inftrap_check,
|
||||
saspecial: saspecial_check,
|
||||
};
|
||||
|
||||
|
||||
+73
-31
@@ -83,7 +83,9 @@
|
||||
"る",
|
||||
"る",
|
||||
"う",
|
||||
"く"
|
||||
"く",
|
||||
"くる",
|
||||
"来る"
|
||||
],
|
||||
"con_end": [
|
||||
"け",
|
||||
@@ -99,7 +101,9 @@
|
||||
"ろ",
|
||||
"よ",
|
||||
"え",
|
||||
"け"
|
||||
"け",
|
||||
"こい",
|
||||
"来い"
|
||||
],
|
||||
"dec_tag": [
|
||||
"v5k",
|
||||
@@ -115,7 +119,9 @@
|
||||
"v1",
|
||||
"v1",
|
||||
"v5u-s",
|
||||
"v5k-s"
|
||||
"v5k-s",
|
||||
"vk",
|
||||
"vk"
|
||||
],
|
||||
"con_tag": "uninflectable",
|
||||
"detail": "imperative"
|
||||
@@ -275,8 +281,7 @@
|
||||
},
|
||||
"ones that need the te trap",
|
||||
{
|
||||
"type": "contextrule",
|
||||
"contextrule": "tetrap",
|
||||
"type": "stdrule",
|
||||
"dec_end": [
|
||||
"す",
|
||||
"る"
|
||||
@@ -297,15 +302,22 @@
|
||||
"type": "neverfinalrule",
|
||||
"dec_end": [
|
||||
"",
|
||||
"る"
|
||||
"る",
|
||||
"くる",
|
||||
"来る"
|
||||
],
|
||||
"con_end": [
|
||||
"",
|
||||
""
|
||||
"",
|
||||
"こ",
|
||||
"来"
|
||||
],
|
||||
"dec_tag": [
|
||||
"stem-a",
|
||||
"v1"
|
||||
"v1",
|
||||
"vk",
|
||||
"vk",
|
||||
"vk"
|
||||
],
|
||||
"con_tag": "stem-mizenkei",
|
||||
"detail": "(mizenkei)"
|
||||
@@ -473,8 +485,8 @@
|
||||
"tag alias",
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
"con_end": "",
|
||||
"dec_end": ["て", "で"],
|
||||
"con_end": ["て", "で"],
|
||||
"dec_tag": "stem-te-verbal",
|
||||
"con_tag": "stem-te",
|
||||
"detail": ""
|
||||
@@ -516,8 +528,7 @@
|
||||
},
|
||||
"negatives",
|
||||
{
|
||||
"type": "contextrule",
|
||||
"contextrule": "adjspecial",
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
"con_end": "ない",
|
||||
"dec_tag": "stem-mizenkei",
|
||||
@@ -557,8 +568,7 @@
|
||||
"detail": "archaic negative"
|
||||
},
|
||||
{
|
||||
"type": "contextrule",
|
||||
"contextrule": "adjspecial",
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
"con_end": "ない",
|
||||
"dec_tag": "stem-ku",
|
||||
@@ -794,6 +804,15 @@
|
||||
"con_tag": "v1",
|
||||
"detail": "teiru"
|
||||
},
|
||||
{
|
||||
"type": "contextrule",
|
||||
"contextrule": "v1inftrap",
|
||||
"dec_end": "",
|
||||
"con_end": "る",
|
||||
"dec_tag": "stem-te",
|
||||
"con_tag": "v1",
|
||||
"detail": "teru (teiru)"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
@@ -802,6 +821,14 @@
|
||||
"con_tag": "v5r",
|
||||
"detail": "teoru"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": ["て", "で"],
|
||||
"con_end": ["とる", "どる"],
|
||||
"dec_tag": "stem-te",
|
||||
"con_tag": "v5r",
|
||||
"detail": "toru (teoru)"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
@@ -818,6 +845,14 @@
|
||||
"con_tag": "v5k-s",
|
||||
"detail": "teiku"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
"con_end": "く",
|
||||
"dec_tag": "stem-te",
|
||||
"con_tag": "v5k-s",
|
||||
"detail": "teku (teiku)"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
@@ -834,22 +869,30 @@
|
||||
"con_tag": "v5k",
|
||||
"detail": "for now"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": ["て", "で"],
|
||||
"con_end": ["とく", "どく"],
|
||||
"dec_tag": "stem-te",
|
||||
"con_tag": "v5k",
|
||||
"detail": "toku (for now)"
|
||||
},
|
||||
"nonverbal functions of the te form",
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
"con_end": "は",
|
||||
"dec_tag": "stem-te",
|
||||
"con_tag": "uninflectable",
|
||||
"detail": "topic"
|
||||
"con_tag": "topic-condition",
|
||||
"detail": "topic/condition"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
"con_end": "は",
|
||||
"dec_tag": "stem-te-defective",
|
||||
"con_tag": "uninflectable",
|
||||
"detail": "topic"
|
||||
"con_tag": "topic-condition",
|
||||
"detail": "topic/condition"
|
||||
},
|
||||
"TODO: ても too?",
|
||||
"===ren'youkei based forms===",
|
||||
@@ -902,8 +945,7 @@
|
||||
"detail": "tari"
|
||||
},
|
||||
{
|
||||
"type": "contextrule",
|
||||
"contextrule": "adjspecial",
|
||||
"type": "stdrule",
|
||||
"dec_end": "",
|
||||
"con_end": "たい",
|
||||
"dec_tag": "stem-ren",
|
||||
@@ -925,7 +967,7 @@
|
||||
"con_end": "ちゃう",
|
||||
"dec_tag": "v5u",
|
||||
"con_tag": "v5u",
|
||||
"detail": "(contraction)"
|
||||
"detail": "contracted"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
@@ -933,7 +975,7 @@
|
||||
"con_end": "じゃう",
|
||||
"dec_tag": "v5u",
|
||||
"con_tag": "v5u",
|
||||
"detail": "(contraction)"
|
||||
"detail": "contracted"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
@@ -941,7 +983,7 @@
|
||||
"con_end": "ちまう",
|
||||
"dec_tag": "v5u",
|
||||
"con_tag": "v5u",
|
||||
"detail": "(contraction)"
|
||||
"detail": "contracted"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
@@ -949,23 +991,23 @@
|
||||
"con_end": "じまう",
|
||||
"dec_tag": "v5u",
|
||||
"con_tag": "v5u",
|
||||
"detail": "(contraction)"
|
||||
"detail": "contracted"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": "ては",
|
||||
"con_end": "ちゃ",
|
||||
"dec_tag": "stem-te",
|
||||
"dec_tag": "topic-condition",
|
||||
"con_tag": "uninflectable",
|
||||
"detail": "(contraction)"
|
||||
"detail": "contracted"
|
||||
},
|
||||
{
|
||||
"type": "stdrule",
|
||||
"dec_end": "では",
|
||||
"con_end": "じゃ",
|
||||
"dec_tag": "stem-te",
|
||||
"dec_tag": "topic-condition",
|
||||
"con_tag": "uninflectable",
|
||||
"detail": "(contraction)"
|
||||
"detail": "contracted"
|
||||
},
|
||||
{
|
||||
"type": "onlyfinalrule",
|
||||
@@ -973,7 +1015,7 @@
|
||||
"con_end": "けりゃ",
|
||||
"dec_tag": "uninflectable",
|
||||
"con_tag": "uninflectable",
|
||||
"detail": "(contraction)"
|
||||
"detail": "contracted"
|
||||
},
|
||||
{
|
||||
"type": "onlyfinalrule",
|
||||
@@ -981,7 +1023,7 @@
|
||||
"con_end": "きゃ",
|
||||
"dec_tag": "uninflectable",
|
||||
"con_tag": "uninflectable",
|
||||
"detail": "(contraction)"
|
||||
"detail": "contracted"
|
||||
},
|
||||
"other",
|
||||
{
|
||||
@@ -1016,5 +1058,5 @@
|
||||
"con_tag": "uninflectable",
|
||||
"detail": "slurred"
|
||||
},
|
||||
"// TODO: a bunch of missing contractions, and support for other verb types like vk (くる), vs_i (true する verbs), v5aru (なさる, くださる, etc), v4r (ござる, etc), ..."
|
||||
"// TODO: support for other verb types like vk (くる) (started, incomplete), vs_i (true する verbs), v5aru (なさる, くださる, etc), v4r (ござる, etc), ..."
|
||||
]
|
||||
@@ -1,76 +0,0 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "nazeka",
|
||||
"version": "0.2.5.0",
|
||||
"author": "Wareya",
|
||||
"homepage_url": "https://github.com/wareya/nazeka",
|
||||
"description": "A rikai replacement.",
|
||||
|
||||
"permissions": [
|
||||
"contextMenus",
|
||||
"storage",
|
||||
"tabs",
|
||||
"clipboardRead",
|
||||
"https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?*"
|
||||
],
|
||||
|
||||
"background": {
|
||||
"page": "background.html"
|
||||
},
|
||||
|
||||
"web_accessible_resources": [
|
||||
"include/browser-polyfill.min.js",
|
||||
"img/closebutton24.png",
|
||||
"img/leftarrow24.png",
|
||||
"img/rightarrow24.png",
|
||||
"dict/JMdict1.json",
|
||||
"dict/JMdict2.json",
|
||||
"dict/JMdict3.json",
|
||||
"dict/JMdict4.json",
|
||||
"dict/JMdict5.json",
|
||||
"dict/JMdict6.json",
|
||||
"dict/JMdict7.json",
|
||||
"dict/JMdict8.json",
|
||||
"dict/JMdict9.json",
|
||||
"dict/JMdict10.json",
|
||||
"dict/JMdict11.json",
|
||||
"dict/jdic audio.txt",
|
||||
"dict/deconjugator.json",
|
||||
"reader.js",
|
||||
"reader.html",
|
||||
"mining.js",
|
||||
"mining.html",
|
||||
"livemining.js",
|
||||
"livemining.html",
|
||||
"jmdictabbreviations.html"
|
||||
],
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["http://*/*", "https://*/*", "ftp://*/*", "file:///*"],
|
||||
"js": ["include/browser-polyfill.min.js", "texthook.js"],
|
||||
"all_frames": true
|
||||
}
|
||||
],
|
||||
|
||||
"options_ui": {
|
||||
"page": "options.html"
|
||||
},
|
||||
|
||||
"browser_action": {
|
||||
"browser_style": false,
|
||||
"default_icon": {
|
||||
"16": "img/action16.png",
|
||||
"32": "img/action32.png",
|
||||
"512": "img/action512.png"
|
||||
},
|
||||
"default_title": "Nazeka (disabled)",
|
||||
"default_area": "navbar"
|
||||
},
|
||||
|
||||
"icons": {
|
||||
"16": "img/enabled16.png",
|
||||
"32": "img/enabled32.png",
|
||||
"512": "img/enabled512.png"
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+13
-43
@@ -3,14 +3,9 @@
|
||||
/*
|
||||
* TODO:
|
||||
*
|
||||
* ! Finish porting the underlay's deconjugation rules
|
||||
* - Add an option for "hide unfitting senses/spellings/readings" vs "show everything but with details about what can be what"
|
||||
* - Fix katakana-hiragana matching (only happens in lookups right now, not display generation)
|
||||
* - More configurability
|
||||
* - VNstats frequency data
|
||||
* - Integrate frequency into priority handling
|
||||
* - Load deconjugation rules from an advanced setting, with a reset button
|
||||
* ? Export/import settings with json
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -686,8 +681,11 @@ function build_div_inner(text, result, moreText, index, first_of_many = false)
|
||||
|
||||
// deconjugations
|
||||
|
||||
|
||||
if(term.deconj)
|
||||
{
|
||||
console.log(term.deconj);
|
||||
|
||||
let deconj = "";
|
||||
let first = true;
|
||||
for(let form of term.deconj)
|
||||
@@ -702,7 +700,7 @@ function build_div_inner(text, result, moreText, index, first_of_many = false)
|
||||
if(info.startsWith("(") && info.endsWith(")") && f != 0)
|
||||
continue;
|
||||
if(added > 0)
|
||||
formtext += "―";
|
||||
formtext += "→";
|
||||
added++;
|
||||
formtext += info;
|
||||
}
|
||||
@@ -735,6 +733,7 @@ function build_div_inner(text, result, moreText, index, first_of_many = false)
|
||||
temptag.appendChild(main_reb);
|
||||
if(term.deconj)
|
||||
{
|
||||
console.log(term.deconj);
|
||||
let deconj = "";
|
||||
let first = true;
|
||||
for(let form of term.deconj)
|
||||
@@ -749,7 +748,7 @@ function build_div_inner(text, result, moreText, index, first_of_many = false)
|
||||
if(info.startsWith("(") && info.endsWith(")") && f != 0)
|
||||
continue;
|
||||
if(added > 0)
|
||||
formtext += "―";
|
||||
formtext += "→";
|
||||
added++;
|
||||
formtext += info;
|
||||
}
|
||||
@@ -1075,11 +1074,9 @@ browser.storage.onChanged.addListener((updates, storageArea) =>
|
||||
|
||||
let last_lookup = undefined;
|
||||
let last_manual_interaction = Date.now();
|
||||
let lookup_last_time = Date.now();
|
||||
|
||||
async function send_lookup(lookup)
|
||||
{
|
||||
lookup_last_time = Date.now();
|
||||
last_lookup = lookup;
|
||||
|
||||
let response = await browser.runtime.sendMessage(
|
||||
@@ -1113,12 +1110,9 @@ async function send_lookup(lookup)
|
||||
lookup_cancel();
|
||||
}
|
||||
function lookup_enqueue(text, x, y, x2, y2, moreText, index)
|
||||
{
|
||||
if(lookup_last_time+settings.lookuprate < Date.now())
|
||||
{
|
||||
send_lookup([text, x, y, x2, y2, moreText, index]);
|
||||
}
|
||||
}
|
||||
|
||||
function lookup_cancel()
|
||||
{
|
||||
@@ -1359,8 +1353,8 @@ function update(event)
|
||||
if((settings.popup_requires_key == 2 && !shift_down)
|
||||
|| (settings.popup_requires_key == 1 && !ctrl_down))
|
||||
{
|
||||
function sqr(n) {return n*n;}
|
||||
if(Math.sqrt(sqr(last_display_x-event.pageX) + sqr(last_display_y-event.pageY)) > 20)
|
||||
function sq(n) {return n*n;}
|
||||
if(Math.sqrt(sq(last_display_x-event.pageX) + sq(last_display_y-event.pageY)) > 20)
|
||||
lookup_cancel();
|
||||
return;
|
||||
}
|
||||
@@ -1420,10 +1414,9 @@ function update(event)
|
||||
yoffset = searchoffset;
|
||||
else
|
||||
xoffset = searchoffset;
|
||||
// firefox
|
||||
if (document.caretPositionFromPoint)
|
||||
{
|
||||
|
||||
let caretdata = document.caretPositionFromPoint(x+xoffset, y+yoffset);
|
||||
|
||||
if(caretdata)
|
||||
{
|
||||
textNode = caretdata.offsetNode;
|
||||
@@ -1434,30 +1427,6 @@ function update(event)
|
||||
hitrect = range.getBoundingClientRect();
|
||||
range.detach();
|
||||
}
|
||||
}
|
||||
// chrome
|
||||
else if (document.caretRangeFromPoint)
|
||||
{
|
||||
let range = document.caretRangeFromPoint(x+xoffset, y+yoffset);
|
||||
if(range)
|
||||
{
|
||||
try
|
||||
{
|
||||
range.setEnd(range.endContainer, range.endOffset+1);
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
try
|
||||
{
|
||||
range.setEnd(true_next_sibling(range.endContainer), 0);
|
||||
}
|
||||
catch(err){}
|
||||
}
|
||||
textNode = range.startContainer;
|
||||
offset = range.startOffset;
|
||||
hitrect = range.getBoundingClientRect();
|
||||
}
|
||||
}
|
||||
// sticky mode and android need to break out on parent detection
|
||||
if(ele && !ele.contains(textNode) && platform != "android" && (!settings.sticky || get_doc().body.getElementsByClassName("nazeka_mining_ui").length != 0))
|
||||
{
|
||||
@@ -1487,7 +1456,7 @@ function update(event)
|
||||
return;
|
||||
}
|
||||
|
||||
if(textNode !== undefined)
|
||||
if(false && textNode !== undefined)
|
||||
{
|
||||
// we hit an node, see if it's a transparent element and try to move it under everything temporarily if it is
|
||||
try
|
||||
@@ -1496,7 +1465,8 @@ function update(event)
|
||||
{
|
||||
let style = getComputedStyle(textNode)
|
||||
let bg_color = style.getPropertyValue("background-color");
|
||||
if(bg_color == "rgba(0, 0, 0, 0)")
|
||||
let position = style.getPropertyValue("position");
|
||||
if(bg_color == "rgba(0, 0, 0, 0)" && (position == "absolute" || (position != "static" && textNode.tagName == "A")))
|
||||
{
|
||||
nodeIsBad = true;
|
||||
nodeResetList.unshift([textNode, style.getPropertyValue("z-index")]);
|
||||
|
||||
Reference in new issue
Block a user