From 686b844233416b243c19fff8a4eb86a4e191fc9a Mon Sep 17 00:00:00 2001 From: remi Date: Wed, 8 Jun 2022 22:28:59 +0200 Subject: [PATCH] to roman --- main.js | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ wordlist.json | 32 ++++++++++++++---------- 2 files changed, 86 insertions(+), 13 deletions(-) diff --git a/main.js b/main.js index 218d51a..c395191 100644 --- a/main.js +++ b/main.js @@ -63,6 +63,73 @@ function stripWord(word) { return word.replace(/[^a-zA-Z]/g, ""); } +heonianVowels = { + "-1": "", + "0": "", + "1": "a", + "2": "e", + "3": "i", + "4": "o", + "5": "u", + "a": "a", + "b": "e", + "c": "i", + "d": "o", + "e": "u" +} + +heonianVowelsSeparate = { + "0": "a", + "1": "e", + "2": "i", + "3": "o", + "4": "u", + "a": "a", + "b": "e", + "c": "i", + "d": "o", + "e": "u" +} + +heonianConsonants = { + "00": "", + "01": "g", + "02": "sh", + "03": "r", + "04": "ny", + "05": "ch", + "06": "m", + "07": "j", + "07": "y", + "08": "f", + "09": "t", + "0a": "k", + "0b": "w", + "0c": "l", + "0d": "p", + "0e": "b", + "0f": "d", + "10": "h", +}; + +function heonianToRoman(text) { + let roman = ""; + for (let i = 0; i < text.length; i++) { + let h = text.codePointAt(i); + if (h >= 57344 && h <= 57606) { + h = text.codePointAt(i).toString(16).split(""); + if (h[1] == 0 && h[2] == 0) { + roman += heonianVowelsSeparate[h[3]]; + } else { + roman += heonianConsonants[h[1]+""+h[2]]+heonianVowels[h[3]-1]; + } + } else { + roman += text.charAt(i); + } + } + return roman; +} + function loadDictionary() { fetch("./wordlist.json").then((e) => { if (e.status === 200) { diff --git a/wordlist.json b/wordlist.json index 646198f..0b5ca1f 100644 --- a/wordlist.json +++ b/wordlist.json @@ -1,15 +1,21 @@ { - "a.bae": { - "translation": "young", - "type": "modifier" - }, - "a.e mo?": { - "translation": "isn't it right?", - "type": "expression" - }, - "a.ga.ka": { - "translation": "at, towards, for", - "type": "marker", - "notes": "also used like" - } + "": [ + { + "type": "noun", + "meaning": "snow", + "translation": "snow", + "notes": "ari is cute", + "examples": { + "     ": "i hope ari can see snow" + } + }, + { + "type": "noun", + "meaning": "safety", + "translation": "sfkjdjdsf", + "examples": { + "im safe with ari": ":3" + } + } + ] } \ No newline at end of file