Module:User:Sedataltundal/tr-noun

Hello, you have come here looking for the meaning of the word Module:User:Sedataltundal/tr-noun. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Sedataltundal/tr-noun, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Sedataltundal/tr-noun in singular and plural. Everything you need to know about the word Module:User:Sedataltundal/tr-noun you have here. The definition of the word Module:User:Sedataltundal/tr-noun will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Sedataltundal/tr-noun, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local lang = require("Module:languages").getByCode("tr")

local export = {}

local vowels = {
	 = {high = "ı", low = "a"},  = {high = "ı", low = "a"},
	 = {high = "i", low = "e"},
	 = {high = "ı", low = "a"},
	 = {high = "i", low = "e"},  = {high = "i", low = "e"},
	 = {high = "u", low = "a"},
	 = {high = "ü", low = "e"},
	 = {high = "u", low = "a"},  = {high = "u", low = "a"},
	 = {high = "ü", low = "e"},
}

-- Constants for declension cases
local CASES = {"nom", "def|acc", "dat", "loc", "abl", "gen"}
local NUMBERS = {"s", "p"}

-- Templates for table rendering
local TEMPLATES = {
    inflection_table_top = "inflection-table-top",
    inflection_table_bottom = "inflection-table-bottom",
    inflection_box_top = "inflection-box-top",
    inflection_box_bottom = "inflection-box-bottom",
}

-- Generate singular and plural stems
local function generate_stems(stem, vowel, n)
    local plstem = n == "p" and stem or stem .. "l" .. vowel.low .. "r"
    return stem, plstem
end

-- Determine if a word ends in a vowel
local function ends_in_vowel(stem)
    return mw.ustring.find(stem, "$") ~= nil
end

-- Apply suffixes based on the case and whether the stem ends in a vowel
local function apply_suffix(stem, case, vowel, is_vowel, dt)
    if case == "nom" then
        return stem
    elseif case == "def|acc" then
        return is_vowel and (stem .. "y" .. vowel.high) or (stem .. vowel.high)
    elseif case == "dat" then
        return is_vowel and (stem .. "y" .. vowel.low) or (stem .. vowel.low)
    elseif case == "loc" then
        local dt = is_vowel and "d" or (mw.ustring.find(stem, "$") and "t" or "d")
        return stem .. dt .. vowel.low
    elseif case == "abl" then
        local dt = is_vowel and "d" or (mw.ustring.find(stem, "$") and "t" or "d")
        return stem .. dt .. vowel.low .. "n"
    elseif case == "gen" then
        return is_vowel and (stem .. "n" .. vowel.high .. "n") or (stem .. vowel.high .. "n")
    else
        return stem
    end
end

-- Add possessive forms to the data table
local function add_possessive_forms(data, args, stem, plstem, vowel, is_vowel)
    local suffixes = {
         = "m",  -- 1st person singular
         = "n",  -- 2nd person singular
         = "",   -- 3rd person singular
         = "mız", -- 1st person plural
         = "nız", -- 2nd person plural
         = "ları", -- 3rd person plural
    }

    for key, suffix in pairs(suffixes) do
        local poss_stem = is_vowel and (stem .. "y") or stem
        local pl_poss_stem = plstem

        if key == "3|p" then
            -- 3rd person plural uses "ları" or "leri" based on vowel harmony
            suffix = vowel.low .. "r" .. vowel.high
        end

        -- Singular possessive forms
        data.forms = {poss_stem .. suffix}

        -- Plural possessive forms
        data.forms = {pl_poss_stem .. suffix}
    end
end

-- Add predicative forms to the data table
local function add_predicative_forms(data, args, stem, plstem, vowel, is_vowel)
    local suffixes = {
         = "y" .. vowel.high .. "m",  -- 1st person singular
         = "s" .. vowel.high .. "n", -- 2nd person singular
         = "",                       -- 3rd person singular
         = "y" .. vowel.high .. "z", -- 1st person plural
         = "s" .. vowel.high .. "n" .. vowel.high .. "z", -- 2nd person plural
         = "",                       -- 3rd person plural
    }

    for key, suffix in pairs(suffixes) do
        local pred_stem = is_vowel and (stem .. "y") or stem
        local pl_pred_stem = plstem

        -- Singular predicative forms
        data.forms = {pred_stem .. suffix}

        -- Plural predicative forms
        data.forms = {pl_pred_stem .. suffix}
    end
end

-- Declension function
function export.decl(frame)
    local params = {
         = {required = true, default = "u"},
         = {},
         = {},
         = {type = "boolean"},
         = {},
         = {type = "boolean"},
    }

    local args = require("Module:parameters").process(frame:getParent().args, params)
    local stem = args or mw.title.getCurrentTitle().text
    local vowel = vowels]
    local plvowel = vowels

    -- Determine if the stem ends in a vowel or consonant
    local is_vowel = ends_in_vowel(stem)

    -- Generate stems
    local plstem = args == "p" and stem or stem .. "l" .. vowel.low .. "r"
    

    -- Generate forms
    local data = {forms = {}, info = "Declension of ''" .. stem .. "''", categories = {}}
    for _, case in ipairs(CASES) do
        data.forms = {apply_suffix(stem, case, vowel, is_vowel, dt)}
    end
    -- Plural forms - plural stems always end in 'r' (consonant)
    data.forms = {plstem}
    data.forms = {plstem .. plvowel.high}  -- Always consonant-ending
    data.forms = {plstem .. plvowel.low}       -- Always consonant-ending
    data.forms = {plstem .. "d" .. plvowel.low}
    data.forms = {plstem .. "d" .. plvowel.low .. "n"}
    data.forms = {plstem .. plvowel.high .. "n"} -- Always consonant-ending

    -- Add possessive and predicative forms
    if args then
        add_possessive_forms(data, args, stem, plstem, vowel, is_vowel)
    end
    if args then
        add_predicative_forms(data, args, stem, plstem, vowel, is_vowel)
    end

    -- Postprocess and return
    postprocess(args, data)
    if args then
        return mw.text.jsonEncode(data)
    end
    return make_table(data)
end

function postprocess(args, data)
	data.has_poss = args
	data.has_pred = args
	data.n = args
	
	if args == "p" then
		table.insert(data.categories, lang:getCanonicalName() .. " pluralia tantum")
	elseif args == "s" then
		table.insert(data.categories, lang:getCanonicalName() .. " uncountable nouns")
	elseif args then
		error("args= must be \"s\" or \"p\".")
	end
	
	for key, form in pairs(data.forms) do
		-- Do not show singular or plural forms for nominals that don't have them
		if (args == "p" and key:find("|s$")) or (args == "s" and key:find("|p$")) then
			form = nil
		end
		
		data.forms = form
	end
	
	data.lemma = (data.forms)
	
	-- Check if the lemma form matches the page name
	if (lang:makeEntryName(data.lemma)) ~= mw.title.getCurrentTitle().text then
		table.insert(data.categories, lang:getCanonicalName() .. " entries with inflection not matching pagename")
	end
end

-- Make the table
function make_table(data)
    local function repl(param)
        local accel = true
        local no_store = false
        
        if param == "info" then
            return mw.getContentLanguage():ucfirst(data.info or "")
        elseif string.sub(param, 1, 1) == "!" then
            no_store = true
            param = string.sub(param, 2)
        elseif string.sub(param, 1, 1) == "#" then
            accel = false
            param = string.sub(param, 2)
        end
        
        local forms = data.forms
        
        if not forms then
            return "—"
        end
        
        local ret = {}
        
        for key, subform in ipairs(forms) do
            table.insert(ret, require("Module:links").full_link({lang = lang, term = subform, accel = accel and {form = param, lemma = data.lemma, no_store = no_store} or nil}))
        end
        
        return table.concat(ret, "<br/>")
    end
    
    local wikicode = {}
    
    -- Table header
    if data.has_poss or data.has_pred then
        table.insert(wikicode, mw.getCurrentFrame():expandTemplate{
            title = "inflection-box-top",
            args = {
                title = "{{{info}}}",
                flow = "vertical",
            }
        })
        table.insert(wikicode, mw.getCurrentFrame():expandTemplate{
            title = "inflection-table-top",
            args = {
                title = "-",
                palette = "red",
            }
        })
    else
        table.insert(wikicode, mw.getCurrentFrame():expandTemplate{
            title = "inflection-table-top",
            args = {
                title = "{{{info}}}",
                tall = "yes",
                palette = "red",
            }
        })
    end

    -- Main declension table
    local main_table = [=[
!
! singular
! plural
|-
! nominative
| {{{nom|s}}}
| {{{nom|p}}}
|-
! definite accusative
| {{{def|acc|s}}}
| {{{def|acc|p}}}
|-
! dative
| {{{dat|s}}}
| {{{dat|p}}}
|-
! locative
| {{{loc|s}}}
| {{{loc|p}}}
|-
! ablative
| {{{abl|s}}}
| {{{abl|p}}}
|-
! genitive
| {{{gen|s}}}
| {{{gen|p}}}]=]
    
    table.insert(wikicode, main_table)
    table.insert(wikicode, mw.getCurrentFrame():expandTemplate{ title = "inflection-table-bottom" })
    
    -- Possessive forms
    if data.has_poss then
        table.insert(wikicode, mw.getCurrentFrame():expandTemplate{
            title = "inflection-table-top",
            args = {
                title = "Possessive forms",
                palette = "red",
                tall = "yes",
            }
        })
        
        -- Define cases and persons
        local cases = {
            {name = "nominative", code = ""},
            {name = "definite accusative", code = "def|acc"},
            {name = "dative", code = "dat"},
            {name = "locative", code = "loc"},
            {name = "ablative", code = "abl"},
            {name = "genitive", code = "gen"}
        }
        
        local persons = {
            {name = "1st singular", code = "1|s"},
            {name = "2nd singular", code = "2|s"},
            {name = "3rd singular", code = "3|s"},
            {name = "1st plural", code = "1|p"},
            {name = "2nd plural", code = "2|p"},
            {name = "3rd plural", code = "3|p"}
        }
        
        -- Generate possessive table
        for _, case in ipairs(cases) do
            local case_code = case.code ~= "" and "|" .. case.code or ""
            table.insert(wikicode, "! colspan=\"3\" class=\"outer\" | " .. case.name)
            table.insert(wikicode, "|-")
            table.insert(wikicode, "!\n! singular\n! plural")
            
            for _, person in ipairs(persons) do
                table.insert(wikicode, "|-")
                table.insert(wikicode, "! " .. person.name)
                table.insert(wikicode, "| {{{" .. person.code .. "|spos|poss" .. case_code .. "}}}")
                table.insert(wikicode, "| {{{" .. person.code .. "|mpos|poss" .. case_code .. "}}}")
            end
        end
        
        table.insert(wikicode, mw.getCurrentFrame():expandTemplate{ title = "inflection-table-bottom" })
    end
    
    -- Predicative forms
    if data.has_pred then
        table.insert(wikicode, mw.getCurrentFrame():expandTemplate{
            title = "inflection-table-top",
            args = {
                title = "Predicative forms",
                palette = "red",
                tall = "yes",
            }
        })
        
        table.insert(wikicode, "!\n! singular\n! plural")
        
        local persons = {
            {name = "1st singular", code = "1|s"},
            {name = "2nd singular", code = "2|s"},
            {name = "3rd singular", code = "3|s"},
            {name = "1st plural", code = "1|p"},
            {name = "2nd plural", code = "2|p"},
            {name = "3rd plural", code = "3|p"}
        }
        
        for _, person in ipairs(persons) do
            table.insert(wikicode, "|-")
            table.insert(wikicode, "! " .. person.name)
            table.insert(wikicode, "| {{{" .. person.code .. "|pred|of the|s}}}")
            table.insert(wikicode, "| {{{" .. person.code .. "|pred|of the|p}}}")
        end
        
        table.insert(wikicode, mw.getCurrentFrame():expandTemplate{ title = "inflection-table-bottom" })
    end
    
    -- Table footer
    if data.has_poss or data.has_pred then
        table.insert(wikicode, '\n')
        table.insert(wikicode, mw.getCurrentFrame():expandTemplate{ title = "inflection-box-bottom" })
    end
    
    return mw.ustring.gsub(table.concat(wikicode), "{{{(?+)}}}", repl) .. require("Module:utilities").format_categories(data.categories, lang)
end

return export