Module:User:AmazingJus/turkish/narrow

From blackwiki
< Module:User:AmazingJus/turkish
Revision as of 23:39, 6 September 2019 by blackwiki>AmazingJus (AmazingJus moved page Module:User:Awesomemeeos/turkish/narrow to Module:User:AmazingJus/turkish/narrow without leaving a redirect)
Jump to navigation Jump to search

Lua error in package.lua at line 80: module 'Module:User:Awesomemeeos/turkish' not found.

Usage

{{#invoke:User:AmazingJus/turkish|function_name}}



local export = {}
-- local m_IPA = require("Module:IPA")
local U = mw.ustring.char
local match = mw.ustring.match
local gsub = mw.ustring.gsub
local m_broad = require("Module:User:Awesomemeeos/turkish")

local ring = U(0x30A)
local tack = U(0x31E)
local plus = U(0x31F)
local minus = U(0x320)
local bridge = U(0x32A)
local breve = U(0x361)

-- we need to use the broad transcription first in order for this to work properly


function export.phonetic(text)
	if type(text) == "table" then
		text = text.args[1]
	end

	local b = "ɯuɑo"
	local f = "iyeø"
	local r = "yuøo"
	local u = "ɯɑie"
	local v = "yuøoɯɑie"
	
	-- make all word borders have a space
	text = " " .. text .. " "

	-- consonants
	text = gsub(text, "([^" .. v .. "])\.%1", "%1ː") -- also broken up syllables are okay as well

	if match(text, "[" .. r .. "]") then
		text = gsub(text, "f([" .. r .. "])", "ɸ%1")
		text = gsub(text, "([" .. r .. "]ː?)([.ˈ]?)f", "%1%2v\/ɸ")
		text = gsub(text, "([" .. v .. "]ː?)([.ˈ]?)v([" .. r .. "])", "%1%2β" .. tack .. "%3")
		text = gsub(text, "([" .. r .. "]ː?)([.ˈ]?)v([" .. u .. "])", "%1%2v\/β" .. tack .. "%3")
		text = gsub(text, "([^" .. r .. "]ː?)([.ˈ]?)v([" .. r .. "])", "%1%2β%3")
		text = gsub(text, "([" .. r .. "]ː?)([.ˈ]?)v([^" .. v .. "])", "%1%2β%3")
	end
	
	text = gsub(text, "([.ˈ ][ptck])([^" .. breve .. "])", "%1ʰ%2")

	if match(text, "[ɾɫl][.ˈ]?[fcktsʃph]") then
		text = gsub(text, "[ɾɫl]", {["ɾ"] = "ɾ" .. tack .. ring, ["ɫ"] = "ɫ" .. bridge .. ring, ["l"] = "l" .. minus .. ring .. "ʲ"})
	end

	if match(text, "[ɾɫl] ") then
		text = gsub(text, "[ɾɫl]", {["ɾ"] = "ɾ" .. tack .. ring, ["ɫ"] = "ɫ" .. bridge .. ring, ["l"] = "l" .. minus .. ring .. "ʲ"})
	end
	
	text = gsub(text, "n([.ˈ]?)([kɡ])", "ŋ%1%2")
	text = gsub(text, "n([.ˈ]?)([cɟ])", "ɲ%1%2")
	text = gsub(text, "([ntdszɫ])([^" .. bridge .. "])", "%1" .. bridge .. "%2")
	text = gsub(text, "l([^" .. minus .. "])", "l" .. minus .. "ʲ%1")
	text = gsub(text, "([" .. f .. "]ː?)([.ˈ]?)h", "%1%2ç")
	text = gsub(text, "h ", "x ")
	text = gsub(text, "([" .. f .. "]ː?)([.ˈ]?)ɰ([" .. f .. "])", "%1%2ɰ" .. plus .. "\/j%3")
	text = gsub(text, "([" .. v .. "]?)ɰ ", "%1ː ")
	text = gsub(text, "ɰ([^" .. plus .. "])", "%1")
	text = gsub(text, " (ˈ?)ɾ([^" .. tack .. "])", " %1ɾ" .. tack .. "%2")

	-- vowels
	mw.logObject(text)
	text = gsub(text, "([iyɯueø]) $", {["i"] = "ɪ", ["y"] = "ʏ", ["ɯ"] = "ɯ" .. tack, ["u"] = "ʊ", ["e"] = "ɛ", ["ø"] = "œ"}) -- only at the end of phrases
	text = gsub(text, "e([mnlɾ])", "æ%1") -- put another parameter to that it can also be pronounced [e]
	text = gsub(text, "a", "ɑ")
	text = gsub(text, "([eoø])", "%1" .. tack)

	-- alternatives


	return mw.text.trim(text)
end

return export