fix hiragana-katakana conversion

This commit is contained in:
wareya committed 2019-06-29 10:01:47 -04:00
1 parent 0408da797d
commit de47e41c33
7 files changed
+89159 -4730

No files matched your search

+7 -3
View File
@@ -397,7 +397,9 @@ function replace_hira_with_kata(text)
for(let i = 0; i < text.length; i++) for(let i = 0; i < text.length; i++)
{ {
let codepoint = text.codePointAt(i); let codepoint = text.codePointAt(i);
if(codepoint >= 0x3040 && codepoint <= 0x309F) if(codepoint >= 0x3040 && codepoint <= 0x3096)
codepoint += (0x30A0 - 0x3040);
else if(codepoint >= 0x309D && codepoint <= 0x309E)
codepoint += (0x30A0 - 0x3040); codepoint += (0x30A0 - 0x3040);
newtext += String.fromCodePoint(codepoint); newtext += String.fromCodePoint(codepoint);
} }
@@ -410,7 +412,9 @@ function replace_kata_with_hira(text)
for(let i = 0; i < text.length; i++) for(let i = 0; i < text.length; i++)
{ {
let codepoint = text.codePointAt(i); let codepoint = text.codePointAt(i);
if(codepoint >= 0x30A0 && codepoint <= 0x30FF) if(codepoint >= 0x30A0 && codepoint <= 0x30F6)
codepoint -= (0x30A0 - 0x3040);
else if(codepoint >= 0x30FD && codepoint <= 0x30FE)
codepoint -= (0x30A0 - 0x3040); codepoint -= (0x30A0 - 0x3040);
newtext += String.fromCodePoint(codepoint); newtext += String.fromCodePoint(codepoint);
} }
@@ -1531,7 +1535,7 @@ function add_extra_info(results, other_settings)
entry.freq = []; entry.freq = [];
for(let r of entry.r_ele) for(let r of entry.r_ele)
{ {
let reading = r.reb; let reading = replace_kata_with_hira(r.reb);
let freq = undefined; let freq = undefined;
if(settings.freqlist_mode == 1) if(settings.freqlist_mode == 1)
freq = freq_vns; freq = freq_vns;
+2951 -2951
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+1775 -1775
View File
File diff suppressed because it is too large. Load diff
+35894
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -24,6 +24,7 @@
["会", "かい", 40], ["会", "かい", 40],
["行く", "いく", 40], ["行く", "いく", 40],
["来る", "くる", 40], ["来る", "くる", 40],
["他", "ほか", 100],
["為る", "する", 100], ["為る", "する", 100],
+3 -1
View File
@@ -7,7 +7,9 @@ def replace_kata_with_hira(text):
newtext = "" newtext = ""
for c in text: for c in text:
codepoint = ord(c) codepoint = ord(c)
if codepoint >= 0x30A0 and codepoint <= 0x30FF: if codepoint >= 0x30A0 and codepoint <= 0x30F6:
codepoint -= (0x30A0 - 0x3040)
elif codepoint >= 0x30FD and codepoint <= 0x30FE:
codepoint -= (0x30A0 - 0x3040) codepoint -= (0x30A0 - 0x3040)
newtext += chr(codepoint) newtext += chr(codepoint)
return newtext return newtext