sane-tag-music: better romanization
This commit is contained in:
@@ -148,6 +148,7 @@ class MediaType(Enum):
|
|||||||
Other = "other"
|
Other = "other"
|
||||||
|
|
||||||
def maybe_romanize(a: str) -> str|None:
|
def maybe_romanize(a: str) -> str|None:
|
||||||
|
if a == "( ͡° ͜ʖ ͡°)": return "Lenny"
|
||||||
if a == "かめりあ": return "Camellia"
|
if a == "かめりあ": return "Camellia"
|
||||||
if a == "お握り": return "onigiri"
|
if a == "お握り": return "onigiri"
|
||||||
if a == "存流": return "ARU"
|
if a == "存流": return "ARU"
|
||||||
@@ -172,7 +173,12 @@ def romanize(a: str) -> str:
|
|||||||
romanized = ""
|
romanized = ""
|
||||||
index = 0
|
index = 0
|
||||||
while index < len(a):
|
while index < len(a):
|
||||||
for segment_len in range(10, 0, -1):
|
if a[index].lower() in "abcdefghijklmnopqrstuvwxyz0123456789._-":
|
||||||
|
# fast path
|
||||||
|
romanized += a[index]
|
||||||
|
index += 1
|
||||||
|
continue
|
||||||
|
for segment_len in range(16, 0, -1):
|
||||||
r = maybe_romanize(a[index : index+segment_len])
|
r = maybe_romanize(a[index : index+segment_len])
|
||||||
if r is not None:
|
if r is not None:
|
||||||
if len(r) > 1:
|
if len(r) > 1:
|
||||||
|
Reference in New Issue
Block a user