Module:ábḫ-ipa/remake: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 25: Line 25:
local export = {}
local export = {}


local vowels = "[aäeɛʊiɪɔɐ]"
local vowels = "[aäeɛʊiɪɔɐ" .. NONSYLL .. "]"
local consonants = "[βðɺɕθʑɲjxɦDGPTKBmnpkɟt]"
local consonants = "[βðɺɕθʑɲjxɦDGPTKBmnpkɟt]"
local tones = "[ˆˇ´]"
local tones = "[ˆˇ´]"
Line 51: Line 51:


local end_rules = {
local end_rules = {
{"", ""},
{"g", "f"},
}
}


Line 57: Line 57:
local syllables = {}
local syllables = {}
word = gsub(word, "(" .. consonants .. vowels .. ")", "·%1")
word = gsub(word, "(" .. consonants .. vowels .. ")", "·%1")
--word = word:gsub("^([mnjɲβDGPpTtKkBθdɕʑxɦɺ]?" .. vowels .. "ː?" .. tones .. ")", "ˈ%1")
word = gsub(word, "^·", "")
syllables = split(word, "·")
if match(syllables[1], "^[mnjɲβDGPpTtKkBθðɕʑxɦɺ]?" .. vowels .. "ː?" .. tones) then
syllables[1] = "x" .. syllables[1] --table.insert(syllables, 1, "ˈ")
else
end
return word
return table.concat(syllables, "-")
end
end



Latest revision as of 22:35, 11 April 2021



--[[
	Hi! If you ever happen to read this, I'm trying to friendly *deobfuscate* your module.
	I've learned some Scribunto Lua the hard way, after months of messing with it for Avendonian, Siwa, and High Valyrian modules.
	You can check out my Module:siwa-pron and Module:qhv-pron if you're curious; let's say it took me many many
	attempts to make them functional :þ. Thanks for adding your language to Linguifex, cheers!
]]

local sub = mw.ustring.sub
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local u = mw.ustring.char
local split = mw.text.split
local gsplit = mw.text.gsplit

local PAGENAME = mw.title.getCurrentTitle().text
local CIRCUMFLEX = u(0x0302)
local HACEK = u(0x030C)
local ACUTE = u(0x0301)
local NONSYLL = u(0x032F)
local DENTAL = u(0x032A)
local SYLL = u(0x030D)

local export = {}

local vowels = "[aäeɛʊiɪɔɐ" .. NONSYLL .. "]"
local consonants = "[βðɺɕθʑɲjxɦDGPTKBmnpkɟt]"
local tones = "[ˆˇ´]"

local start_rules = {
	{"á", "a´"},
		
	{"aá", "aaˇ"}, {"áa", "aaˆ"}, {"ií", "iiˇ"}, {"íi", "iiˆ"},
	{"eí", "eːˇi"}, {"oú", "oːˇu"}, {"aa", "aː"}, {"ii", "iː"}, {"o", "ɔ"},
	
	{"(" .. vowels .. "ː?" .. tones .. "?).", "%1ɪ" .. NONSYLL}, 	{"(" .. vowels .. "ː?" .. tones .. "?o)", "%1" .. NONSYLL},
	{"(" .. vowels .. "ː?" .. tones .. "?)u", "%1ʊ" .. NONSYLL},
	
	{"r", "ɺ"}, {"b", "β"}, {"g", "ɡ"}, {"o", "ɔ"}, {"a", "ä"}, {"s", "ɕ"}, {"z", "θ"}, {"d", "ð"},
	{"jh", "ʑ"}, {"j", "ɲ"}, {"y", "j"}, {"ḫ", "x"}, {"h", "ɦ"}, {"nð", "D"}, 
	{"nɡ", "G"}, {"mp", "P"}, {"nt", "T"}, {"nk", "K"}, {"^mβ", "B"},



	{"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, 
	{"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""},
	{"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"´", "˦"}, {"ˆ", "˥˩"}, {"ˇ", "˩˥"},
	 
}

local end_rules = {
	{"g", "f"},
}

local function syllable_and_stress(word)
	local syllables = {}
	word = gsub(word, "(" .. consonants .. vowels .. ")", "·%1")
	word = gsub(word, "^·", "")
	syllables = split(word, "·")
	
	if match(syllables[1], "^[mnjɲβDGPpTtKkBθðɕʑxɦɺ]?" .. vowels .. "ː?" .. tones) then
		syllables[1] = "x" .. syllables[1] --table.insert(syllables, 1, "ˈ")
	else
		
	end
	
	return table.concat(syllables, "-")
end

function export.show(word)
	--local word = frame.args[1] or word
	
	for _, srule in ipairs(start_rules) do
		word = word:gsub(srule[1], srule[2])	
	end
	
	word = syllable_and_stress(word)
	
	for _, erule in ipairs(end_rules) do
		word = word:gsub(erule[1], erule[2])	
	end
	
	return word
end



return export