Selaa lähdekoodia

Add decompose script manually.

scossu 2 kuukautta sitten
vanhempi
commit
69b556f896

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 558 - 475
scriptshifter/tables/data/greek_classical.yml


+ 25 - 24
scriptshifter/tables/data/greek_modern.yml

@@ -1,32 +1,33 @@
+---
 general:
   name: Greek (modern)
   parents:
     - greek_classical
 
-script_to_roman:
+roman_to_script:
   map:
-    "\u0392": "V"
-    "\u03B2": "v"
+    Ha: "\u0391"
+    He: "\u0395"
+    "He\u0304": "\u0397"
+    Hi: "\u0399"
+    Ho: "\u039F"
+    Hou: "\u039F\u03C5"
+    "Ho\u0304": "\u03A9"
+    Hui: "\u03A5\u03B9"
+    Hy: "\u03A5"
+    V: "\u0392"
+    ha: "\u03B1"
+    he: "\u03B5"
+    "he\u0304": "\u03B7"
+    hi: "\u03B9"
+    ho: "\u03BF"
+    hou: "\u03BF\u03C5"
+    "ho\u0304": "\u03C9"
+    hui: "\u03C5\u03B9"
+    hy: "\u03C5"
+    v: "\u03B2"
 
-roman_to_script:
+script_to_roman:
   map:
-    "V": "\u0392"
-    "v": "\u03B2"
-    "Ha": "\u0391"
-    "ha": "\u03B1"
-    "He": "\u0395"
-    "he": "\u03B5"
-    "H\u0113": "\u0397"
-    "h\u0113": "\u03B7"
-    "Hi": "\u0399"
-    "hi": "\u03B9"
-    "Ho": "\u039F"
-    "ho": "\u03BF"
-    "Hou": "\u039F\u03C5"
-    "hou": "\u03BF\u03C5"
-    "H\u014D": "\u03A9"
-    "h\u014D": "\u03C9"
-    "Hy": "\u03A5"
-    "Hui": "\u03A5\u03B9"
-    "hy": "\u03C5"
-    "hui": "\u03C5\u03B9"
+    "\u0392": V
+    "\u03B2": v

+ 45 - 0
scriptshifter/tables/decompose_tables.py

@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+__doc__ = """
+Usage: decompose_tables.py [CONFIG_FILE_PATH]
+
+Use this script to normalize Roman map keys to use combining characters
+(decomposed glyphs) vs. pre-composed glyphs.
+
+The script will create a new YAML file named according to the source.
+E.g. `myscript.yml` → `myscript_norm.yml`.
+
+NOTE: Check the YAML syntax as issues with indentation have been detected.
+Also, the original key order may be displaced, and whitespace and comments may
+disappear.
+"""
+
+from argparse import ArgumentParser
+from os import path
+from unicodedata import normalize
+from yaml import load, dump
+try:
+    from yaml import CLoader as Loader
+except ImportError:
+    from yaml import Loader
+
+
+parser = ArgumentParser()
+parser.add_argument("src_fname")
+args = parser.parse_args()
+
+dest_fname = path.splitext(args.src_fname)[0] + "_norm.yml"
+with open(args.src_fname) as fh:
+    data = load(fh, Loader=Loader)
+
+data["roman_to_script"]["map"] = {
+        normalize("NFD", k): v
+        for k, v in data["roman_to_script"]["map"].items()}
+data["script_to_roman"]["map"] = {
+        k: normalize("NFD", v)
+        for k, v in data["script_to_roman"]["map"].items()}
+
+with open(dest_fname, "w") as fh:
+    dump(data, fh, indent=2)
+
+print("Done.")

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä