Module:User:Oyunqi/Turlenme

ئورنى Wiktionary

Documentation for this module may be created at Module:User:Oyunqi/Turlenme/doc

b = require('Module:bases')
qoshumche = mw.loadData('Module:User:Oyunqi/Turlenme/qoshumche')

local p = {}

function chiqirish( tab, _aldi, _birlik, _kopluk, _arqa, _yq)
    local result = ''
    if #tab> 0 then 
        result = result .. '#: ' .. _aldi
        if #tab >1 then result = result .. _kopluk else result = result .. _birlik end
        result = result ..  _arqa ..  table.concat(tab, " + ") 
        result = result .. "\n"
        if _yq ==1 then result = result  .. "<br/>" end
    end
    return result
end

local function build_tree(_xarakteri , _turkumi)
	local tree = {}
    for key, value in pairs(qoshumche) do 
       if _xarakteri == "all" or _turkumi == "all" then
            tree[key] = value.nami
      else
           if value.turkumi[_turkumi] and value.xarakteri[_xarakteri] then
                   tree[key] = value.nami
          end
--[[
           for a,b in pairs(value.turkumi) do

                 if value.turkumi[b] == _turkumi then
                        for c,d in pairs (value. xarakteri) do
                              if value.xarakteri[d] == _xarakteri then
                                       tree[key] = value.nami
                              end
                        end
                end
           end
]]--
      end
    end

	return tree
end

function p.turlenme(frame, _xarakteri, _turkumi)
    local tree ={}
    if _turkumi == nil or _xarakteri == nil then 
           tree = build_tree("all","all")
           _turkumi = "سۆزلەر"
    else
           tree = build_tree(_xarakteri, _turkumi)
           
    end
    local aldi = {}
    local arqa = {}
    local soz = {}
    local result = ''
    for key, value in ipairs(frame:getParent().args) do
        --result = result .. key .. '=' .. value .. '<br/>'
        if mw.ustring.sub(value, -1, -1) == "-"  then --aldi qoshumche
              if not tree[value] then 
                      table.insert(aldi,"[[" .. value .. "]]" )
                      result = result .. b.fait_categorie_contenu('Wiktionary: ھازىرچە ئامباردا يوق سۆز ' .. _xarakteri.. ' قوشۇمچىلار ' .. '')  --.. value 
              else
                      table.insert(aldi,"[[" .. value .. "]] ( " .. tree[value] .. " ) " )
                       result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى ' .. tree[value] .. ' قوشۇمچىسى بىلەن تۈرلەنگەن ' .. _turkumi)
                       result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى ' .. value .. ' قوشۇمچىسى بىلەن تۈرلەنگەن ' .. _turkumi)
              end
       elseif mw.ustring.sub(value, 1, 1) == "-"  then 
              if not tree[value] then 
                      table.insert(arqa,"[[" .. value .. "]]" )
                      result = result .. b.fait_categorie_contenu('Wiktionary: ھازىرچە ئامباردا يوق سۆز ' .. _xarakteri .. ' قوشۇمچىلار ' ..  '')  --value ..
              else
                      table.insert(arqa,"[[" .. value .. "]] ( " .. tree[value] .. " ) " )
                       result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى ' .. tree[value] .. ' قوشۇمچىسى بىلەن تۈرلەنگەن ' .. _turkumi)
                       result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى ' .. value .. ' قوشۇمچىسى بىلەن تۈرلەنگەن ' .. _turkumi)
              end
        else 
              table.insert(soz,"[[" .. value .. "]] ( " .. _turkumi .. " )")
              result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى تۈپ ' .. _turkumi .. ': ' .. value .. ' ')
        end
    end
    result = result .. "بۇ بىر تۈرلەنگەن " .. _turkumi .. " بولۇپ تەركىپلىرى تۆۋەندىكىچە: <br/></br/>"
    result = result .. chiqirish( aldi, "سۆز ئالدى ", "قوشۇمچە" , "قوشۇمچىلار", ": ", 1)
    result = result .. chiqirish( soz, "تۈپ ", "سۆز" , "سۆزلەر", ": ", 1)
    result = result .. chiqirish( arqa, "سۆز ئارقا ", "قوشۇمچە" , "قوشۇمچىلار", ": ", 0)
    result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى تۈرلەنگەن ' .. _turkumi)

    return result
end

-- ياسىغۇچى تۈرلىگۈچى
-- ئىسىم سۈپەت ...
-- ئىسىملار سۈپەتلەر ...
-- ياسالغان تۈرلەنگەن 
function p.tur_isim(frame)
    local result = ''
    result = p.mezmuni(frame, "تۈرلىگۈچى", "ئىسىم", "ئىسىملار", "تۈرلەنگەن")
    return result
end

-- ياسىغۇچى تۈرلىگۈچى
-- ئىسىم سۈپەت ...
-- ئىسىملار سۈپەتلەر ...
-- ياسالغان تۈرلەنگەن 
function p.yas_isim(frame)
    local result = ''
    result = p.mezmuni(frame, "ياسىغۇچى", "ئىسىم", "ئىسىملار", "ياسالغان")
    return result
end

function p.qoshumche(str)
    local result = ''
    if type(str) == "table" then str = str.args[1] end
    if str==nil or str==""  then
       str = mw.title.getCurrentTitle().text
    end

    if qoshumche[str] == nil then 
        result = "(ئامباردا ھازىرچە " .. str .. " قوشۇمچىسى يوق)"
    else
        qoshum = qoshumche[str]

        result = result .. "<ol>"
        for a, c in ipairs(qoshum.xarakteri) do
                result = result .. "<li>"
                result = result .. " سۆز " .. c .. " قوشۇمچە: "
				result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى سۆز ' .. c .. ' قوشۇمچىلار')
                if c == "تۈرلىگۈچى" then 
                    result = result .. qoshum.nami .. " قوشۇمچىسى"
				else
	                --result = result .. "<ul><li>"
					if qoshum.yas_nami then
                    	result = result .. qoshum.yas_nami .. " قوشۇمچە"
					else
                    	result = result .. qoshum.nami .. " قوشۇمچە"
					end
			        if qoshum.roli ~= nil then
		                result = result .. "<ul>"
            			for r1, r2 in ipairs(qoshum.roli) do
							result = result .. "<li>" .. r2 .. "</li>"
            			end
		                result = result .. "</ul>"
        			end
	                --result = result .. "</li></ol>"
                end
                result = result .. "</li>"
        end
        result = result .. "</ol>"
       

    end

    return result
end

function ambardimu(_str,_xarakteri,_turkumi)
    local qoshum = ''
    if qoshumche[_str] == nil then 
        --error("بۇنداق قوشۇمچە يوق")
        return false
    else
         qoshum = qoshumche[_str]
         local tapti = false
         for a, b in ipairs(qoshum.xarakteri) do
               if b == _xarakteri then tapti=true end
        end
         for a, b in ipairs(qoshum.turkumi) do
               if b == _turkumi then tapti=true end
        end
        return tapti
    end
end

function ambar_nami(_str, _xarakteri)
    if _xarakteri=="ياسىغۇچى" then 
        if qoshumche[_str].yas_nami then
             return qoshumche[_str].yas_nami
        else
             return qoshumche[_str].nami
       end
    else
        return qoshumche[_str].nami
    end
end

--بۇ فۇنكىسىيىنى ھازىرچە ئىشلەتمىدىم بەلكىم كېرەك بولۇپ قېلىشى مۇمكىن
function ambar_haliti(_str, _xarakteri)
    if _xarakteri=="ياسىغۇچى" then 
        return qoshumche[_str].yas_haliti
    else
        return qoshumche[_str].haliti
    end
end

-- ياسىغۇچى تۈرلىگۈچى
-- ئىسىم سۈپەت ...
-- ئىسىملار سۈپەتلەر ...
-- ياسالغان تۈرلەنگەن 
function p.mezmuni(frame, _xarakteri, _turkumi,_turkop,_xarak)
    local aldi = {}
    local arqa = {}
    local soz = {}
    local result = ''
    local si =0
    local ari = 0
    for key, value in ipairs(frame:getParent().args) do
        if mw.ustring.sub(value, -1, -1) == "-"  then --aldi qoshumche
              if not ambardimu(value, _xarakteri, _turkumi) then 
                      table.insert(aldi,"[[" .. value .. "]]" )
                      result = result .. b.fait_categorie_contenu('Wiktionary: قوشۇمچىسى تېخى ئامبارغا كىرمىگەن سۆزلەر' ..  '')
              else
                      table.insert(aldi,"[[" .. value .. "]] ( " .. ambar_nami(value, _xarakteri) .. " ) " )
                       result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى ' .. ambar_nami(value, _xarakteri) .. ' قوشۇمچىسى بىلەن ' .. _xarak .. ' ' .. _turkop)
              end
                       result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى ' .. value .. ' قوشۇمچىسى بىلەن ' .. _xarak .. ' ' .. _turkop)
       elseif mw.ustring.sub(value, 1, 1) == "-"  then 
              if not ambardimu(value, _xarakteri, _turkumi) then 
                      table.insert(arqa,"[[" .. value .. "]]" )
                      result = result .. b.fait_categorie_contenu('Wiktionary: قوشۇمچىسى تېخى ئامبارغا كىرمىگەن سۆزلەر' .. '')
              else
                      ari = ari +1
                      --if si>0 then return (qoshumche[value].haliti) end
                      if si>0 and si==ari and qoshumche[value].haliti then soz[#soz] = mw.ustring.gsub(soz[#soz], "( سۆز )", qoshumche[value].haliti) end
                      table.insert(arqa,"[[" .. value .. "]] ( " .. ambar_nami(value, _xarakteri) .. " ) " )
                       result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى ' .. ambar_nami(value, _xarakteri) .. ' قوشۇمچىسى بىلەن ' .. _xarak .. ' ' .. _turkop)
              end
                       result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى ' .. value .. ' قوشۇمچىسى بىلەن ' .. _xarak .. ' ' .. _turkop)
        else 
              si = si +1
              if _xarakteri == "تۈرلىگۈچى" then
                    table.insert(soz,"[[" .. value .. "]] ( " .. _turkumi .. " )")
              else
                   table.insert(soz,"[[" .. value .. "]] ( " .. 'سۆز' .. " )")
              end    
              -- result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى تۈپ ' .. 'سۆز' .. ': ' .. value .. 'نىڭ ھەر خىل شەكىللىرى')
        end
    end
--    result = result .. "</br/> بۇ بىر " .. _xarak .. " " .. _turkumi .. " بولۇپ تەركىپلىرى تۆۋەندىكىچە: <br/>"
--    result = result .. "« " .. soz .. " » دىگەن " .. _turkumi .. "نىڭ " .. _xarak .. " شەكلى" .. " .\n"
    result = result .. "بۇ بىر " .. _xarak .. " " .. _turkumi .. " .\n"

--    result = result .. chiqirish( aldi, "سۆز ئالدى ", "قوشۇمچە" , "قوشۇمچىلار", ": ", 1) 
    result = result .. chiqirish( aldi, "سۆز ئالدى ", "قوشۇمچە" , "قوشۇمچىلار", ": ", 0) 

--    result = result .. "  "
--    result = result .. chiqirish( soz, "تۈپ ", "سۆز" , "سۆزلەر", ": ", 1) 
    result = result .. chiqirish( soz, "تۈپ ", "سۆز" , "سۆزلەر", ": ", 0) 

--    result = result .. "  "
--    result = result .. chiqirish( arqa, "سۆز ئارقا ", "قوشۇمچە" , "قوشۇمچىلار", ": ", 1) 
    result = result .. chiqirish( arqa, "سۆز ئارقا ", "قوشۇمچە" , "قوشۇمچىلار", ": ", 0) 

--    result = result .. " لارنىڭ قوشۇلۇشىدىن " .. _xarak .. " " .. _turkumi .. "."
    result = result .. b.fait_categorie_contenu('ئۇيغۇر تىلىدىكى ' .. _xarak .. " " .. _turkop)

    return result

end

return p