Przeglądaj źródła

Modified hook function names to be more generic
Fixed bug which caused error if nested lowercase letters were not found

Changes to be committed:
modified: scriptshifter/hooks/adlam_hooks.py
modified: scriptshifter/tables/data/pulaar.yml

Neil S Patel 1 rok temu
rodzic
commit
fc28f17287

+ 7 - 3
scriptshifter/hooks/adlam_hooks.py

@@ -9,7 +9,8 @@ __doc__ = """ Process contextual substitutions for prenasalization. """
 logger = logging.getLogger(__name__)
 
 
-def scrub_nasal(ctx):
+def s2r_post(ctx):
+    # clean up word initial pre-nasalization
     regex1 = r"\b([Nn])([Nn])([dgjDGJ])"
     subst1 = r"\g<1>\g<3>"
     ctx.dest = re.sub(regex1, subst1, ctx.dest, 0)
@@ -18,13 +19,16 @@ def scrub_nasal(ctx):
     ctx.dest = re.sub(regex2, subst2, ctx.dest, 0)
     regex3 = r"\b(N)(b)"
     subst3 = r"M\g<2>"
+    # clean up nested lower case when source text is all caps
     ctx.dest = re.sub(regex3, subst3, ctx.dest, 0)
     regex4 = r"([ABƁCDƊEFGHIJKLMNŊÑOPQRSTUVWYƳZ])([abɓcdɗefghijklmnŋñopqrstuvwyƴz][bhp]?)([ABƁCDƊEFGHIJKLMNŊÑOPQRSTUVWYƳZ])"
     nested_lower = re.search(regex4, ctx.dest)
-    ctx.dest = re.sub(regex4, nested_lower.string.upper(), ctx.dest, 0)
+    if nested_lower:
+        ctx.dest = re.sub(regex4, nested_lower.string.upper(), ctx.dest, 0)
     return(None)
 
-def strip_nyondal(ctx):
+def r2s_post(ctx):
+    # clean up word initial pre-nasalization
     regex1 = r"\b([𞤲𞤐])𞥋([𞤄𞤁𞤘𞤔𞤦𞤣𞤺𞤶])"
     subst1 = r"\g<1>\g<2>"
     ctx.dest = re.sub(regex1, subst1, ctx.dest, 0)

+ 2 - 3
scriptshifter/tables/data/pulaar.yml

@@ -5,7 +5,7 @@ roman_to_script:
   hooks:
     post_assembly:
       -
-        - adlam_hooks.strip_nyondal
+        - adlam_hooks.r2s_post
 
   map:
     # Non-Nyondal Cases
@@ -428,7 +428,6 @@ roman_to_script:
     "\u00BF": "𞥟"
     "\u201C": "\u201D"
     "\u201D": "\u201C"
-    "\u007C": "𞥋"
 
 
 
@@ -436,7 +435,7 @@ script_to_roman:
   hooks:
     post_assembly:
       -
-        - adlam_hooks.scrub_nasal
+        - adlam_hooks.s2r_post
         
   map:
     # Medial nyondal Cases