From 771b8dba3d2c45513f304aff4d062d41f6de14a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B8vbr=C3=B8tte=20Olsen?= Date: Thu, 28 Feb 2019 13:08:25 +0100 Subject: [PATCH] Add Inuktitut Syllabics --- x2i/i-keys.yaml | 367 ++++++++++++++++++++++++++++++++++++++++++++++++ x2i/index.js | 101 ------------- x2i/index.ts | 3 + 3 files changed, 370 insertions(+), 101 deletions(-) create mode 100644 x2i/i-keys.yaml delete mode 100644 x2i/index.js diff --git a/x2i/i-keys.yaml b/x2i/i-keys.yaml new file mode 100644 index 0000000..6322fdd --- /dev/null +++ b/x2i/i-keys.yaml @@ -0,0 +1,367 @@ +--- +- raw: + - "[iI]{2}" + - "ᐄ" +- raw: + - "[iI]{1}" + - "ᐃ" +- raw: + - "[uU]{2}" + - "ᐆ" +- raw: + - "[uU]{1}" + - "ᐅ" +- raw: + - "[aA]{2}" + - "ᐋ" +- raw: + - "[aA]{1}" + - "ᐊ" + + +- raw: + - "[pP][iI][iI]" + - "ᐲ" +- raw: + - "[pP][iI]" + - "ᐱ" +- raw: + - "[pP][uU][uU]" + - "ᐴ" +- raw: + - "[pP][uU]" + - "ᐳ" +- raw: + - "[pP][aA][aA]" + - "ᐹ" +- raw: + - "[pP][aA]" + - "ᐸ" +- raw: + - "[pP]" + - "ᑉ" + +- raw: + - "[tT][iI][iI]" + - "ᑏ" +- raw: + - "[tT][iI]" + - "ᑎ" +- raw: + - "[tT][uU][uU]" + - "ᑑ" +- raw: + - "[tT][uU]" + - "ᑐ" +- raw: + - "[tT][aA][aA]" + - "ᑖ" +- raw: + - "[tT][aA]" + - "ᑕ" +- raw: + - "[pP]" + - "ᑦ" + + +- raw: + - "[kK][iI][iI]" + - "ᑮ" +- raw: + - "[kK][iI]" + - "ᑭ" +- raw: + - "[kK][uU][uU]" + - "ᑰ" +- raw: + - "[kK][uU]" + - "ᑯ" +- raw: + - "[kK][aA][aA]" + - "ᑳ" +- raw: + - "[kK][aA]" + - "ᑲ" +- raw: + - "[kK]" + - "ᒃ" + +- raw: + - "[gG][iI][iI]" + - "ᒌ" +- raw: + - "[gG][iI]" + - "ᒋ" +- raw: + - "[gG][uU][uU]" + - "ᒎ" +- raw: + - "[gG][uU]" + - "ᒍ" +- raw: + - "[gG][aA][aA]" + - "ᒑ" +- raw: + - "[gG][aA]" + - "ᒐ" +- raw: + - "[gG]" + - "ᒡ" + +- raw: + - "[mM][iI][iI]" + - "ᒦ" +- raw: + - "[mM][iI]" + - "ᒥ" +- raw: + - "[mM][uU][uU]" + - "ᒨ" +- raw: + - "[mM][uU]" + - "ᒧ" +- raw: + - "[mM][aA][aA]" + - "ᒫ" +- raw: + - "[mM][aA]" + - "ᒪ" +- raw: + - "[mM]" + - "ᒻ" + +- raw: + - "[nN][iI][iI]" + - "ᓃ" +- raw: + - "[nN][iI]" + - "ᓂ" +- raw: + - "[nN][uU][uU]" + - "ᓅ" +- raw: + - "[nN][uU]" + - "ᓄ" +- raw: + - "[nN][aA][aA]" + - "ᓈ" +- raw: + - "[nN][aA]" + - "ᓇ" +- raw: + - "[nN][gG][iI][iI]" + - "ᖐ" +- raw: + - "[nN][gG][iI]" + - "ᖏ" +- raw: + - "[nN][gG][uU][uU]" + - "ᖒ" +- raw: + - "[nN][gG][uU]" + - "ᖑ" +- raw: + - "[nN][gG][aA][aA]" + - "ᖔ" +- raw: + - "[nN][gG][aA]" + - "ᖓ" +- raw: + - "[nN][gG]" + - "ᖕ" +- raw: + - "[nN][n][g][iI][iI]" + - "ᙲ" +- raw: + - "[nN][n][g][iI]" + - "ᙱ" +- raw: + - "[nN][n][g][uU][uU]" + - "ᙴ" +- raw: + - "[nN][n][g][uU]" + - "ᙳ" + - raw: + - "[nN][n][g][aA][aA]" + - "ᙶ" +- raw: + - "[nN][n][g][aA]" + - "ᙵ" +- raw: + - "[nN][n][g]" + - "ᖖ" +- raw: + - "[nN]" + - "ᓐ" + +- raw: + - "[sS][iI][iI]" + - "ᓰ" +- raw: + - "[sS][iI]" + - "ᓯ" +- raw: + - "[sS][uU][uU]" + - "ᓲ" +- raw: + - "[sS][uU]" + - "ᓱ" +- raw: + - "[sS][aA][aA]" + - "ᓵ" +- raw: + - "[sS][aA]" + - "ᓴ" +- raw: + - "[sS]" + - "ᔅ" + +- raw: + - "[lL][iI][iI]" + - "ᓖ" +- raw: + - "[lL][iI]" + - "ᓕ" +- raw: + - "[lL][uU][uU]" + - "ᓘ" +- raw: + - "[lL][uU]" + - "ᓗ" +- raw: + - "[lL][aA][aA]" + - "ᓛ" +- raw: + - "[lL][aA]" + - "ᓚ" +- raw: + - "[lL]" + - "ᓪ" + +- raw: + - "[jJyY][iI][iI]" + - "ᔩ" +- raw: + - "[jJyY][iI]" + - "ᔨ" +- raw: + - "[jJyY][uU][uU]" + - "ᔫ" +- raw: + - "[jJyY][uU]" + - "ᔪ" +- raw: + - "[jJyY][aA][aA]" + - "ᔮ" +- raw: + - "[jJyY][aA]" + - "ᔭ" +- raw: + - "[jJyY]" + - "ᔾ" + +- raw: + - "[vV][iI][iI]" + - "ᕖ" +- raw: + - "[vV][iI]" + - "ᕕ" +- raw: + - "[vV][uU][uU]" + - "ᕘ" +- raw: + - "[vV][uU]" + - "ᕗ" +- raw: + - "[vV][aA][aA]" + - "ᕚ" +- raw: + - "[vV][aA]" + - "ᕙ" +- raw: + - "[vV]" + - "ᕝ" + +- raw: + - "[rR][iI][iI]" + - "ᕇ" +- raw: + - "[rR][iI]" + - "ᕆ" +- raw: + - "[rR][uU][uU]" + - "ᕉ" +- raw: + - "[rR][uU]" + - "ᕈ" +- raw: + - "[rR][aA][aA]" + - "ᕌ" +- raw: + - "[rR][aA]" + - "ᕋ" +- raw: + - "[rR]" + - "ᕐ" + +- raw: + - "[qQ][iI][iI]" + - "ᖀ" +- raw: + - "[qQ][iI]" + - "ᕿ" +- raw: + - "[qQ][uU][uU]" + - "ᖂ" +- raw: + - "[qQ][uU]" + - "ᖁ" +- raw: + - "[qQ][aA][aA]" + - "ᖄ" +- raw: + - "[qQ][aA]" + - "ᖃ" +- raw: + - "[qQ][qQ][iI][iI]" + - "ᖅᑮ" +- raw: + - "[qQ][qQ][iI]" + - "ᖅᑭ" +- raw: + - "[qQ][qQ][uU][uU]" + - "ᖅᑰ" +- raw: + - "[qQ][qQ][uU]" + - "ᖅᑯ" +- raw: + - "[qQ][qQ][aA][aA]" + - "ᖅᑳ" +- raw: + - "[qQ][aA][aA]" + - "ᖅᑲ" +- raw: + - "[qQ]" + - "ᖅ" + +- raw: + - "[łŁ&][iI][iI]" + - "ᖡ" +- raw: + - "[łŁ&][iI]" + - "ᖠ" +- raw: + - "[łŁ&][uU][uU]" + - "ᖣ" +- raw: + - "[łŁ&][uU]" + - "ᖢ" +- raw: + - "[łŁ&][aA][aA]" + - "ᖥ" +- raw: + - "[łŁ&][aA]" + - "ᖤ" +- raw: + - "[łŁ&]" + - "ᖦ" \ No newline at end of file diff --git a/x2i/index.js b/x2i/index.js deleted file mode 100644 index f22c733..0000000 --- a/x2i/index.js +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; -exports.__esModule = true; -var fs = require("fs"); -var yaml = require("js-yaml"); -var OuterXRegExp = require("xregexp"); -var regex = OuterXRegExp("(?:(^|[`\\p{White_Space}])) # must be preceded by whitespace or surrounded by code brackets\n ([A-Za-z]*) # key, to lower (2)\n ([/[]) # bracket left (3)\n (\\S|\\S.*?\\S) # body (4)\n ([/\\]]) # bracket right (5)\n (?=$|[`\\p{White_Space}\\pP]) # must be followed by a white space or punctuation", "gmx"); -var defaultMatchAction = function (left, match, right) { return left + match + right; }; -var matchType = { - p: { - join: function (_, match) { return "*" + match; }, - keys: readKeys("./x2i/apie-keys.yaml") - }, - x: { - keys: readKeys("./x2i/x2i-keys.yaml") - }, - z: { - keys: readKeys("./x2i/z2i-keys.yaml") - } -}; -/** - * Read translation keys from file. Escapes strings first. - * - * @param fpath File to key definitions. (yaml, utf8) - * @returns Compiled keys. - */ -function readKeys(fpath) { - return yaml - .safeLoad(fs.readFileSync(fpath, "utf8")) - .map(compileKey) - .filter(Boolean); -} -/** - * Compiles a plain object into a regexp thing. - * - * @param entry Regex and replacement pair, or delimited match object. - */ -function compileKey(entry) { - if (Array.isArray(entry)) { - var key = entry[0], val = entry[1]; - return [OuterXRegExp(OuterXRegExp.escape(key)), val, "all"]; - } - // don't escape key - if ("raw" in entry) { - var _a = entry.raw, key = _a[0], val = _a[1]; - return [OuterXRegExp(key), val, "all"]; - } - // is a dict - try { - var _b = entry.delimiters, left = _b[0], right = _b[1], translations_1 = entry.translations; - return [ - OuterXRegExp(OuterXRegExp.escape(left) + "(?.*?)" + OuterXRegExp.escape(right)), - function (m) { return OuterXRegExp.replaceEach(m.inside, translations_1.map(compileKey)); }, - "all" - ]; - } - catch (e) { - console.log(entry + " is not an array or a proper object, ignoring"); - } -} -/** - * Convert four-tuple of Strings into a specified "official" representation - * - * @param key What kind of conversion key is appropriate - * @param left Left bracket - * @param match Body - * @param right Right bracket - * @returns Converted item, if any. - */ -function force(key, left, match, right) { - var lowerKey = key.toLowerCase(); - if (!(lowerKey in matchType)) - return; - var _a = matchType[lowerKey], keys = _a.keys, join = _a.join; - if (keys) { - var action = join || defaultMatchAction; - // need to use `as (RegExp | string)[][]` because the provided typings are too generic - return action(left, OuterXRegExp.replaceEach(match, keys), right); - } -} -exports.force = force; -/** - * Grab all x2i strings in message string. - * - * @param content Full message that may or may not contain x2i strings - * @returns Converted representations - */ -function x2i(content) { - var results = []; - OuterXRegExp.forEach(content, regex, function (match) { - var parts = match.slice(2, 6); - if (parts.length === 4) { - var k = parts[0], l = parts[1], m = parts[2], r = parts[3]; - var converted = force(k, l, m, r); // eg x, [, text, ] - if (converted) { - results.push(converted); - } - } - }); - return results.join(" "); -} -exports["default"] = x2i; diff --git a/x2i/index.ts b/x2i/index.ts index 73717fd..580e9ee 100644 --- a/x2i/index.ts +++ b/x2i/index.ts @@ -47,6 +47,9 @@ const matchType: { [key: string]: IMatchInstructions } = { z: { keys: readKeys("./x2i/z2i-keys.yaml"), }, + i: { + keys: readKeys("./x2i/i-keys.yaml"), + }, }; /**