local cikart = {}
-- ]
local m_veri = mw.loadData('Modül:IPA/veri') -- ]
local m_semboller = mw.loadData('Modül:IPA/veri/semboller') -- ]
local m_heceleme -- ]; loaded below if needed
local sub = mw.ustring.sub
local find = mw.ustring.find
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local gmatch = mw.ustring.gmatch
local U = mw.ustring.char
function cikart.bicim_IPA_tam(dil, ogeler, hata, ayirici, siraAnahtari, sayim_yok)
local IPA_ana, ana_bag, hata_yazi, on_ek, IPAlar, kategori
local varmiAnahtar = m_veri.bilgi_sayfali_diller
local alanadi = mw.title.getCurrentTitle().nsText
if hata then
hata_yazi = '<span class="error">' .. hata .. '</span>'
else
if varmiAnahtar then
IPA_ana = "Ek:" .. dil:getirAsilAd() .. " söylenişi"
else
IPA_ana = "wikipedia:" .. dil:getirAsilAd()
end
ana_bag = "]"
end
local on_ek = "]<sup>(" .. ( ana_bag or hata_yazi ) .. ")</sup>: "
IPAlar = cikart.bicim_IPA_coklu(dil, ogeler, ayirici, sayim_yok)
if dil and (alanadi == "" or alanadi == "YeniKurum") then
siraAnahtari = siraAnahtari or dil:yapSiraAnahtari(mw.title.getCurrentTitle().text)
siraAnahtari = siraAnahtari and ("|" .. siraAnahtari) or ""
kategori = "]"
else
kategori = ""
end
return on_ek .. IPAlar .. kategori
end
local function determine_repr(soyl)
local repr_mark = {}
local repr, reconstructed
-- remove initial asterisk before representation marks, used on some Reconstruction pages
if find(soyl, "^%*") then
reconstructed = true
soyl = sub(soyl, 2)
end
local representation_types = {
= { right = '/', type = 'phonemic', },
= { right = ']', type = 'phonetic', },
= { right = '⟩', type = 'orthographic', },
= { type = 'rhyme' },
}
repr_mark.i, repr_mark.f, repr_mark.left, repr_mark.right = find(soyl, '^(.).-(.)$')
local representation_type = representation_types
if representation_type then
if representation_type.right then
if repr_mark.right == representation_type.right then
repr = representation_type.type
end
else
repr = representation_type.type
end
else
repr = nil
end
return repr, reconstructed
end
local function varmiGecersizAyirici(transcription)
if find(transcription, "%.") then
return true
else
return false
end
end
function cikart.bicim_IPA_coklu(dil, ogeler, ayirici, sayim_yok)
local notes = {}
local kategoriler = {}
ayirici = ayirici or ', '
-- Format
if not ogeler then
if mw.title.getCurrentTitle().nsText == "Şablon" then
table.insert(ogeler, {soyl = "/aɪ piː ˈeɪ/"})
else
table.insert(kategoriler, "]")
end
end
local bits = {}
for _, oge in ipairs(ogeler) do
local bit = cikart.bicim_IPA(dil, oge.soyl)
if oge.belirticiler and oge.belirticiler then
bit = require("Modül:belirtici").bicimlendir_belirtici(oge.belirticiler) .. " " .. bit
end
if oge.notlar then
bit = bit .. mw.getCurrentFrame():extensionTag("ref", oge.notlar)
end
table.insert(bits, bit)
-- The length or gemination symbol should not appear after a syllable break or stress symbol.
if find(oge.soyl, "") then
--
end
if dil then
-- Eğer dilin ikili ünlüleri ]de listelendiyse hece sayısı ekle.
if not sayim_yok and mw.title.getCurrentTitle().namespace == 0 then
m_heceleme = m_heceleme or require('Modül:heceleme')
if m_heceleme.varmiIkiliunlu(dil) then
if determine_repr(oge.soyl) == "phonemic" or dil:getirKod() == "ru" then
local syllable_count = m_heceleme.getirUnluler(oge.soyl, dil)
if syllable_count then
table.insert(kategoriler, "]")
end
end
end
end
if dil:getirKod() == "en" then
if varmiGecersizAyirici(oge.soyl) then
table.insert(kategoriler, "]")
end
end
end
end
return table.concat(bits, ayirici) .. table.concat(kategoriler)
end
-- Takes an IPA pronunciation and formats it and adds cleanup kategoriler.
function cikart.bicim_IPA(dil, soyl, split_output)
local hata = {}
local kategoriler = {}
-- Remove wikilinks, so that wikilink brackets are not misinterpreted as
-- indicating phonemic transcription
local str_gsub = string.gsub
local without_links = str_gsub(soyl, '%]+|(]+)%]%]', '%1')
without_links = str_gsub(without_links, '%]+%]%]', '%1')
-- Detect whether this is a phonemic or phonetic transcription
local repr, reconstructed = determine_repr(without_links)
if reconstructed then
soyl = sub(soyl, 2)
end
-- If valid, strip the representation marks
if repr == "phonemic" then
soyl = sub(soyl, 2, -2)
without_links = sub(without_links, 2, -2)
elseif repr == "phonetic" then
soyl = sub(soyl, 2, -2)
without_links = sub(without_links, 2, -2)
elseif repr == "orthographic" then
soyl = sub(soyl, 2, -2)
without_links = sub(without_links, 2, -2)
elseif repr == "rhyme" then
soyl = sub(soyl, 2)
without_links = sub(without_links, 2)
else
table.insert(kategoriler, "]")
end
if soyl == "" then
table.insert(kategoriler, "]")
end
-- Check for obsolete and nonstandard symbols
for i, symbol in ipairs(m_veri.standartolmayan) do
local result
for nonstandard in gmatch(soyl, symbol) do
if not result then
result = {}
end
table.insert(result, nonstandard)
table.insert(kategoriler, "]")
end
if result then
table.insert(hata, "obsolete or nonstandard characters (" .. table.concat(result) .. ")")
break
end
end
--[[ Check for invalid symbols after removing the following:
1. wikilinks (handled above)
2. paired HTML tags
3. bolding
4. italics
5. HTML entity for space
6. asterisk at beginning of transcription
7. comma followed by spacing characters
8. superscripts enclosed in superscript parentheses ]]
local found_HTML
local result = str_gsub(without_links, "<(%a+)*>(+)</%1>",
function(tagName, content)
found_HTML = true
return content
end)
result = str_gsub(result, "'''(*)'''", "%1")
result = str_gsub(result, "''(*)''", "%1")
result = str_gsub(result, "&+;", "") -- This may catch things that are not valid character entities.
result = str_gsub(result, "^%*", "")
result = gsub(result, ",%s+", "")
result = gsub(result, "⁽ .. "]+⁾", "")
result = gsub(result, ' .. ']', '')
if result ~= '' then
local suggestions = {}
mw.log(soyl, result)
local namespace = mw.title.getCurrentTitle().namespace
local kategori
if namespace == 0 then
-- main namespace
kategori = "Geçersiz IPA karakterli IPA okunuşları"
elseif namespace == 118 then
-- reconstruction namespace
kategori = "Geçersiz IPA karakterli IPA okunuşları/yenikurum"
else
kategori = "Geçersiz IPA karakterli IPA okunuşları/madde_dışı"
end
for character in gmatch(result, ".") do
local suggestion = m_semboller
if suggestion then
table.insert(suggestions, character .. " with " .. suggestion)
end
table.insert(kategoriler, "]")
end
table.insert(hata, "geçersiz IPA karakterleri (" .. result .. ")")
if suggestions then
table.insert(hata, "replace " .. table.concat(suggestions, ", "))
end
end
if found_HTML then
table.insert(kategoriler, "]")
end
if repr == "phonemic" or repr == "rhyme" then
if dil and m_veri.sesbirimleri then
local gecerli_sesbirimleri = m_veri.sesbirimleri
local rest = soyl
local sesbirimleri = {}
while mw.ustring.len(rest) > 0 do
local longestmatch = ""
if sub(rest, 1, 1) == "(" or sub(rest, 1, 1) == ")" then
longestmatch = sub(rest, 1, 1)
else
for _, sesbirimi in ipairs(gecerli_sesbirimleri) do
if mw.ustring.len(sesbirimi) > mw.ustring.len(longestmatch) and sub(rest, 1, mw.ustring.len(sesbirimi)) == sesbirimi then
longestmatch = sesbirimi
end
end
end
if mw.ustring.len(longestmatch) > 0 then
table.insert(sesbirimleri, longestmatch)
rest = sub(rest, mw.ustring.len(longestmatch) + 1)
else
local sesbirimi = sub(rest, 1, 1)
table.insert(sesbirimleri, "<span style=\"color: red\">" .. sesbirimi .. "</span>")
rest = sub(rest, 2)
table.insert(kategoriler, "]")
end
end
soyl = table.concat(sesbirimleri)
end
if repr == "phonemic" then
soyl = "/" .. soyl .. "/"
else
soyl = "-" .. soyl
end
elseif repr == "phonetic" then
soyl = ""
elseif repr == "orthographic" then
soyl = "⟨" .. soyl .. "⟩"
end
if reconstructed then
soyl = "*" .. soyl
end
if hata then
hata = '<span class="previewonly error" style="font-size: small;> ' .. table.concat(hata, ', ') .. '</span>'
else
hata = ""
end
if split_output then -- for use of IPA in links
return '<span class="IPA">' .. soyl .. '</span>', table.concat(kategoriler), hata
else
return '<span class="IPA">' .. soyl .. '</span>' .. hata .. table.concat(kategoriler)
end
end
return cikart