Module:rad-pronunciation: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
 
(23 intermediate revisions by the same user not shown)
Line 6: Line 6:
local m_links = require("Module:links")
local m_links = require("Module:links")
local m_languages = require("Module:languages")
local m_languages = require("Module:languages")
local m_rhymes = require("Module:rhymes")
local m_table = require("Module:table")
local m_table = require("Module:table")


Line 21: Line 22:
     local register = {["colloquial"] = "colloquial", ["formal"] = "formal", ["humorous"] = "humorous"}
     local register = {["colloquial"] = "colloquial", ["formal"] = "formal", ["humorous"] = "humorous"}
     local dialect = {["hjádvanþs"] = "hjádvanþs", ["coastal"] = "coastal", ["insular"] = "insular"}
     local dialect = {["hjádvanþs"] = "hjádvanþs", ["coastal"] = "coastal", ["insular"] = "insular"}
    -- get automations --
    local auto_IPA = m_rad_IPA.generate({word})
    local auto_IPA_phon = m_rad_IPA.generate({word, "phon"})
    local auto_IPA_hj = m_rad_IPA.generate({word, "hj"})
    local auto_IPA_phon_hj = m_rad_IPA.generate({word, "hj", "phon"})
    local auto_syllables = m_rad_syllables.generate({word})


     -- create data arrays --
     -- create data arrays --
Line 58: Line 52:
     local working_syllables = ""
     local working_syllables = ""
     local manual_entry = false
     local manual_entry = false
   
    -- account for acronyms
    if mw.ustring.find(word, "[A-ZÀÁẢÂÈÌÍỈÒØÙÛÚỦÝỶỲŪ][A-ZÀÁẢÂÈÌÍỈÒØÙÛÚỦÝỶỲŪ]+") then
    syllables_no_auto = true
end


     -- turn off rhymes if affix
     -- turn off rhymes if affix
Line 65: Line 64:


     local function insert_rhyme(input, pos)
     local function insert_rhyme(input, pos)
        local new_rhyme = m_rad_IPA.get_rhyme(input)
    if show_rhymes then
        if not (new_rhyme == nil or m_table.contains(rhymes, new_rhyme)) and show_rhymes then
        local function insert_to_rhymes(rhyme)
            if pos == nil then
        if not (rhyme == nil or m_table.contains(rhymes, rhyme)) then
                table.insert(rhymes, new_rhyme)
            if pos == nil then
            else
                table.insert(rhymes, rhyme)
                table.insert(rhymes, pos, new_rhyme)
            else
            end
                table.insert(rhymes, pos, rhyme)
        -- mw.log("Rhyme registered: " .. new_rhyme)
                pos = pos + 1
        end
            end
        -- mw.log("Rhyme registered: " .. rhyme)
        end
        end
insert_to_rhymes(m_rad_IPA.get_rhyme(input))
local weak_rhymes = m_rad_IPA.get_weak_rhyme(input)
if weak_rhymes ~= nil and type(weak_rhymes) == "table" then
for _, weak_rhyme in ipairs(weak_rhymes) do
insert_to_rhymes(weak_rhyme)
end
end
end
     end
     end


Line 79: Line 89:


     while args[i] ~= nil or args[i + 1] ~= nil do
     while args[i] ~= nil or args[i + 1] ~= nil do
         mw.log("Processing argument " .. i .. ".")
         -- mw.log("Processing argument " .. i .. ".")
         if parameter[args[i]] ~= nil then -- mode changer
         if parameter[args[i]] ~= nil then -- mode changer
             mode = args[i]
             mode = args[i]
Line 105: Line 115:
             elseif args[i] ~= nil then
             elseif args[i] ~= nil then
                 local temp_arg = args[i]
                 local temp_arg = args[i]
               
                temp_arg = mw.ustring.gsub(temp_arg, "%*%(''(.*)''%)%*", "(%1)")
                local temp_note = mw.ustring.match(temp_arg, "%s*%*?%(.*%)%*?%s*")
                if temp_note then
                temp_arg = mw.ustring.gsub(temp_arg, "%s*%*?%(.*%)%*?%s*", "")
                temp_note = mw.ustring.match(temp_note, "%((.*)%)")
            end


                 if not mw.ustring.find(temp_arg, "%/(.*)%/") then
                 if not mw.ustring.find(temp_arg, "%/(.*)%/") then
Line 138: Line 155:
                 end
                 end


if temp_note then
temp_arg = temp_arg .. " *(''" .. temp_note .. "'')*"
end
                 table.insert(IPA[mode_dialect][mode_register], temp_arg)
                 table.insert(IPA[mode_dialect][mode_register], temp_arg)
                 mw.log("IPA: added '" .. temp_arg .. "' to IPA[" .. mode_dialect .. "][" .. mode_register .. "]")
                 -- mw.log("IPA: added '" .. temp_arg .. "' to IPA[" .. mode_dialect .. "][" .. mode_register .. "]")
                 manual_entry = true
                 manual_entry = true


Line 153: Line 174:
                 if mw.ustring.find(working_syllables, "(%|)") then
                 if mw.ustring.find(working_syllables, "(%|)") then
                     table.insert(syllables, working_syllables)
                     table.insert(syllables, working_syllables)
                     mw.log("Syllables: " .. working_syllables .. " registered.")
                     -- mw.log("Syllables: " .. working_syllables .. " registered.")
                 end
                 end
                 working_syllables = ""
                 working_syllables = ""
Line 159: Line 180:
                 working_syllables = working_syllables .. "|" .. args[i]
                 working_syllables = working_syllables .. "|" .. args[i]
                 table.insert(syllables, working_syllables)
                 table.insert(syllables, working_syllables)
                 mw.log("Syllables: " .. working_syllables .. " registered.")
                 -- mw.log("Syllables: " .. working_syllables .. " registered.")
                 working_syllables = ""
                 working_syllables = ""
             else
             else
Line 174: Line 195:
     end
     end


     i = nil
     -- get automations --
    local auto_IPA = IPA_no_auto == false and m_rad_IPA.generate({word})
    local auto_IPA_phon = IPA_no_auto == false and m_rad_IPA.generate({word, "phon"})
    local auto_IPA_hj = IPA_no_auto == false and m_rad_IPA.generate({word, "hj"})
    local auto_IPA_phon_hj = IPA_no_auto == false and m_rad_IPA.generate({word, "hj", "phon"})
    local auto_syllables = syllables_no_auto == false and m_rad_syllables.generate({word})


     -- add auto values --
     -- add auto values --
Line 303: Line 329:


     if #rhymes > 0 and show_rhymes then
     if #rhymes > 0 and show_rhymes then
        rhymes_show = "\n* Rhymes:"
    rhymes_show = "\n* " .. m_rhymes.generate("rad", rhymes)
 
        for num, rhyme in ipairs(rhymes) do
            if num > 1 then
                rhymes_show = rhymes_show .. ","
            end
            rhymes_show =
                rhymes_show ..
                " <span class=\"IPA\">[[:Category:Rhymes:Radestrian/" ..
                    rhyme .. "|-" .. rhyme .. "]]</span>[[Category:Rhymes:Radestrian/" .. rhyme .. "]] " ..
                "(" .. mw.site.stats.pagesInCategory("Rhymes:Radestrian/" .. rhyme, "pages") .. ")"
        end
     end
     end