1
0
mirror of https://github.com/kmein/niveum synced 2026-03-18 19:11:08 +01:00
Files
niveum/packages/scripts/xsampa-ipa.js
2020-05-15 08:04:18 +02:00

372 lines
3.4 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
"use strict";
const { createInterface } = require("readline");
const xsampa = [
"_R_F",
"J\\_<",
"_H_T",
"G\\_<",
"_B_L",
"|\\|\\",
"r\\`",
"<R>",
"g_<",
"<F>",
"d_<",
"b_<",
"_?\\",
"z\\",
"z`",
"X\\",
"x\\",
"_x",
"_X",
"_w",
"v\\",
"_v",
"U\\",
"t`",
"_t",
"_T",
"s\\",
"s`",
"r\\",
"r`",
"_r",
"R\\",
"_R",
"_q",
"p\\",
"_o",
"O\\",
"_O",
"n`",
"_n",
"N\\",
"_N",
"_m",
"M\\",
"_M",
"l\\",
"l`",
"_l",
"L\\",
"_L",
"_k",
"K\\",
"j\\",
"_j",
"J\\",
"I\\",
"h\\",
"_h",
"H\\",
"_H",
"G\\",
"_G",
"_F",
"_e",
"d`",
"_d",
"_c",
"B\\",
"_B",
"_a",
"_A",
"3\\",
"_0",
"@\\",
"?\\",
"!\\",
":\\",
"-\\",
"_+",
"_\\",
"_}",
'_"',
"_/",
"_-",
"_>",
"_=",
"_~",
"_^",
"|\\",
"||",
">\\",
"=\\",
"<\\",
"Z",
"z",
"y",
"Y",
"X",
"x",
"w",
"W",
"v",
"V",
"u",
"U",
"T",
"t",
"s",
"S",
"r",
"R",
"q",
"Q",
"p",
"P",
"O",
"o",
"N",
"n",
"m",
"M",
"l",
"L",
"k",
"K",
"j",
"J",
"i",
"I",
"h",
"H",
"g",
"G",
"f",
"F",
"E",
"e",
"@",
"D",
"d",
"C",
"c",
"B",
"b",
"{",
"a",
"A",
"9",
"8",
"7",
"6",
"5",
"4",
"3",
"2",
"1",
"%",
"&",
"}",
'"',
"'",
".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
"ʲ",
".",
"ʔ",
"ꜜ",
"ː",
"|",
"̩",
"̃",
"ꜛ",
"˞"
];
const convertChar = (inputList, outputList) => input => {
const index = inputList.findIndex(letter => letter == input);
return index ? outputList[index] : input;
};
const convertString = (inputList, outputList) => string =>
string
.split("")
.map(convertChar(inputList, outputList))
.join("");
const ipaToXsampa = convertString(ipa, xsampa);
const xsampaToIpa = convertString(xsampa, ipa);
const readlineInterface = createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
readlineInterface.on("line", line => console.log(xsampaToIpa(line)));