Module:User:AmazingJus/turkish/narrow

From blackwiki
Jump to navigation Jump to search

24 tests failed.

test_phonemic
Text Expected Actual
  1. REDIRECT Template:Xmark
ordu [oɾˈdu] [oɾdu]
  1. REDIRECT Template:Xmark
gâvur [ɟaˈvuɾ] [ɟaːvuɾ]
  1. REDIRECT Template:Xmark
düğün [dyˈɰyn] [dyɰyn]
  1. REDIRECT Template:Xmark
benim [beˈnim] [benim]
  1. REDIRECT Template:Xmark
benim [ˈbe.nim] [benim]
  1. REDIRECT Template:Xmark
Türkçe [ˈtyɾk.t͡ʃe] [tyɾkt͡ʃe]
  1. REDIRECT Template:Xmark
nerede [ˈne.ɾe.de] [neɾede]
  1. REDIRECT Template:Xmark
sükûnet [sy.cuːˈnet] [sycuːnet]
  1. REDIRECT Template:Xmark
iktisâden [ic.tiˈsaː.den] [ictisaːden]
  1. REDIRECT Template:Xmark
kendi [cenˈdi] [cendi]
  1. REDIRECT Template:Xmark
seviyorum [se.viˈjo.ɾum] [sevijoɾum]
  1. REDIRECT Template:Xmark
Vaşington [vaˈʃink.ton] [vaʃinkton]
test_phonetic
Text Expected Actual
  1. REDIRECT Template:Xmark
ordu [o̞ɾˈd̪ʊ] [o̞rd̪ʊ]
  1. REDIRECT Template:Xmark
gâvur [ɟɑˈβ̞uɾ̞̊] [gâβur]
  1. REDIRECT Template:Xmark
düğün [d̪yˈɰ̟yn̪] [d̪üːn̪]
  1. REDIRECT Template:Xmark
benim [be̞ˈn̪im] [bæn̪im]
  1. REDIRECT Template:Xmark
benim [ˈbe̞.n̪im] [bæn̪im]
  1. REDIRECT Template:Xmark
Türkçe [ˈt̪ʰyɾ̞̊k.t͡ʃɛ] [Türkçɛ]
  1. REDIRECT Template:Xmark
nerede [ˈn̪e̞.ɾe̞.d̪ɛ] [n̪e̞re̞d̪ɛ]
  1. REDIRECT Template:Xmark
sükûnet [s̪y.cʰuːˈn̪e̞t̪] [s̪ükûn̪e̞t̪]
  1. REDIRECT Template:Xmark
iktisâden [ic.t̪ʰiˈs̪ɑː.d̪æn̪] [ikt̪is̪âd̪æn̪]
  1. REDIRECT Template:Xmark
kendi [cʰæn̪ˈd̪ɪ] [kʰæn̪dɪ]
  1. REDIRECT Template:Xmark
seviyorum [s̪e̞.viˈjo̞.ɾum] [s̪e̞viyo̞rum]
  1. REDIRECT Template:Xmark
Vaşington [vɑˈʃiŋk.t̪ʰo̞n̪] [Vɑşin̪gt̪o̞n̪]
test_sezer
Text Expected Actual
☑Y Vaşington vaşˈington vaşˈington
☑Y Ankara ˈankara ˈankara
☑Y Oregon orˈegon orˈegon
☑Y Ordu ˈordu ˈordu
☑Y Edirne edˈirne edˈirne


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:AmazingJus/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