Jump to content

Module:az-harmony

From Wiktionary, the free dictionary


local export = {}

local get_last_vowel = require("Module:az-last-vowel")._main

function export._main(str, type)
  local harmony_table = {
    ["A"] = { ["open"] = "a", ["close"] = "ı" },
    ["I"] = { ["open"] = "a", ["close"] = "ı" },
    ["O"] = { ["open"] = "a", ["close"] = "u" },
    ["U"] = { ["open"] = "a", ["close"] = "u" },
    ["E"] = { ["open"] = "ə", ["close"] = "i" },
    ["Ə"] = { ["open"] = "ə", ["close"] = "i" },
    ["İ"] = { ["open"] = "ə", ["close"] = "i" },
    ["Ö"] = { ["open"] = "ə", ["close"] = "ü" },
    ["Ü"] = { ["open"] = "ə", ["close"] = "ü" },
    ["a"] = { ["open"] = "a", ["close"] = "ı" },
    ["ı"] = { ["open"] = "a", ["close"] = "ı" },
    ["o"] = { ["open"] = "a", ["close"] = "u" },
    ["u"] = { ["open"] = "a", ["close"] = "u" },
    ["e"] = { ["open"] = "ə", ["close"] = "i" },
    ["ə"] = { ["open"] = "ə", ["close"] = "i" },
    ["i"] = { ["open"] = "ə", ["close"] = "i" },
    ["ö"] = { ["open"] = "ə", ["close"] = "ü" },
    ["ü"] = { ["open"] = "ə", ["close"] = "ü" },
  }

  return harmony_table[get_last_vowel(str)][type]
end

function export.main(frame)
  return export._main(frame.args[1], frame.args[2])
end

return export