Module:User:AmazingJus/kri

Hello, you have come here looking for the meaning of the word Module:User:AmazingJus/kri. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:AmazingJus/kri, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:AmazingJus/kri in singular and plural. Everything you need to know about the word Module:User:AmazingJus/kri you have here. The definition of the word Module:User:AmazingJus/kri will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:AmazingJus/kri, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local m_str_utils = require("Module:string utilities")

local decomp = mw.ustring.toNFD
local find = m_str_utils.find
local gmatch = m_str_utils.gmatch
local gsub = m_str_utils.gsub
local len = m_str_utils.len
local lower = m_str_utils.lower

local lang = require("Module:languages").getByCode("kri")  -- Krio language object
local ipa = require("Module:IPA")  -- IPA display module

local U = require("Module:string/char")
local acute = U(0x0301)  -- acute accent
local grave = U(0x0300)  -- grave accent
local circ = U(0x0302)  -- circumflex accent

local C = "bcdfgɠhjkƙlmnŋɲpqrsʃtʧvwxyzʒBCDFGHJKLMNŊPQRSTVWXYZ"  -- consonants
local V = "aeɛioɔuAEƐIOƆU"  -- vowels
local T = acute .. grave .. circ  -- tones

local syll = "‧"  -- syllabification marker
local bound = "#" .. syll  -- syllable boundary

-- Syllabify the term
local function syllablify(term, hide_borders)
	-- Mark all word borders with #
	term = gsub(term, "(+)", "#%1#")

	-- Split the term into syllables
	term = gsub(term, "(-)(??)", "%1" .. syll .. "%2")

	-- Shift syllable marker for certain digraphs
	term = gsub(term, "()" .. syll .. "()", syll .. "%1%2")  -- ch/sh/zh
	term = gsub(term, "()" .. syll .. "()", syll .. "%1%2")  -- gb
	term = gsub(term, "()" .. syll .. "()", syll .. "%1%2")  -- kp
	term = gsub(term, "()" .. syll .. "()", syll .. "%1%2")  -- ny

	-- Remove leading syllable boundaries at the beginning of words or explicitly marked syllables
	term = gsub(term, "(%-?*)" .. syll, "%1")

	-- Convert explicitly marked boundaries
	term = gsub(term, "%.", syll)

	-- Remove word borders if requested
	return hide_borders and gsub(term, "#", "") or term
end

-- Get pronunciation from syllablified term
function export.toIPA(term)
	-- Decompose entry
	term = decomp(term)

	-- Syllabify the term
	term = syllablify(term, false)

	-- Make it lowercase
	term = lower(term)

	-- Substitute digraphs
	local digraphs = {
		 = "ʧ",
		 = "ɠ",
		 = "ƙ",
		 = "ɲ",
		 = "t",
		 = "ʃ",
		 = "ʒ",
	}
	term = gsub(term, "+", digraphs)

	-- Perform respelling substitutions
	term = gsub(term, "h(*)", "%1")  -- syllable-final ⟨h⟩ is silent
	term = gsub(term, "c()", "s%1")  -- ⟨c⟩ before front vowels is pronounced /s/ before ⟨e⟩ and ⟨i⟩
	term = gsub(term, "()i", "%1y")  -- ⟨i⟩ after a vowel is treated as a consonant ⟨y⟩
	term = gsub(term, "()u", "%1w")  -- ⟨u⟩ after a vowel is treated as a consonant ⟨w⟩

	-- Substitute single characters
	local chars = {
		 = "k",
		 = "t͡ʃ",
		 = "ɡ͡b",
		 = "ɡ",
		 = "k͡p",
		 = "(h)",  -- syllable-initial ⟨h⟩ is mostly silent
		 = "d͡ʒ",
		 = "k",
		 = "ʁ",
		 = "ks",
		 = "j",
	}
	term = gsub(term, "", chars)

	-- Convert syllable boundaries to dots and remove word borders
	return gsub(gsub(term, syll, "."), "#", "")
end

-- Main export function
function export.show(term)
	-- get user input as table
	if type(term) == "table" then
		term = term.args
	end

	return export.toIPA(term)
end

return export