Skip to content
Merged

Test #274

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions scriptshifter/hooks/tibetan/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from logging import getLogger
from os import path

from yaml import load as yload
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader


logger = getLogger(__name__)

MOD_BASEDIR = path.dirname(__file__)

with open(path.join(MOD_BASEDIR, "tibetan_roman_preprocess.yml")) as fh:
pre_map = yload(fh, Loader=Loader)


def post_normalize(ctx):
"""
Preprocess Roman input to convert legacy mappings.

Occurrences of ṅ, ñ, ś, and ź are converted to ng, ny, sh, and zh,
respectively.
"""
for k, v in pre_map.items():
ctx.src = ctx.src.replace(k, v)

if ctx.orig != ctx.src:
logger.debug(f"Corrected Roman source: {ctx.orig} -> {ctx.src}")
12 changes: 12 additions & 0 deletions scriptshifter/hooks/tibetan/tibetan_roman_preprocess.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
# Tibetan 2015 changes (R2R)
# Corrects transliteration of ng, ny, sh, zh and alif
"\u02BE": "\u02BC"
"N\u0303": "Ny"
"n\u0303": "ny"
"N\u0307": "Ng"
"n\u0307": "ng"
"S\u0301": "Sh"
"s\u0301": "sh"
"Z\u0301": "Zh"
"z\u0301": "zh"
Loading