შინაარსზე გადასვლა

მოდული:რუსული არსებითი სახელი

გვერდიდან ვიქსიკონი

შეგიძლიათ შექმნათ დოკუმენტაცია ამ მოდულისათვის: მოდული:რუსული არსებითი სახელი/ინფო

local p = {}

-- გამოაქვს რუსული არსებითი სახელის ნაბრუნები ფორმა, რომელსაც ზუსტად შეესაბამება მითითებული გრამატიკული კატეგორიები.
local function rusnoun( lexeme, item_id, item_id2 )
	for i, form in pairs( lexeme:getForms() ) do
		local grammaticalFeatures = form:getGrammaticalFeatures()
		if #grammaticalFeatures == 2 and (grammaticalFeatures[1] == item_id and grammaticalFeatures[2] == item_id2 or grammaticalFeatures[2] == item_id and grammaticalFeatures[1] == item_id2) then
			return form
		end
	end
	return nil
end

-- Return the representation of the form in the given language code,
-- or the first representation otherwise.
local function representationInLanguage( form, language_code )
	local representation, language = form:getRepresentation( language_code )
	if representation then
		return { representation, language }
	else
		return form:getRepresentations()[1]
	end
end

local function termSpan( term )
	local text = term[1]
	local lang = term[2]
	local dir = mw.language.new( lang ):getDir()
	local span = mw.html.create( 'span' )
	span:attr( 'lang', lang ) -- TODO T310581
		:attr( 'dir', dir )
		:wikitext( text )
	return tostring( span )
end

local function getnoun( lexeme_id, item_id, item_id2 )
	local lexeme = mw.wikibase.getEntity( lexeme_id, item_id, item_id2 )
	local form = rusnoun( lexeme, item_id, item_id2 )
	if form == nil then
		return "×"
	end
	local representation = representationInLanguage( form, 'ru' )
	return termSpan( representation )
end

-- ნაბრუნები ფორმები
  -- მხოლობითი
function p.nomsin( frame ) -- სახელობითი
	return getnoun( frame.args[1], 'Q131105', 'Q110786' )
end

function p.gensin( frame ) -- ნათესაობითი
	return getnoun( frame.args[1], 'Q146233', 'Q110786' )
end

function p.datsin( frame ) -- მიცემითი
	return getnoun( frame.args[1], 'Q145599', 'Q110786' )
end

function p.accsin( frame ) -- ბრალდებითი
	return getnoun( frame.args[1], 'Q146078', 'Q110786' )
end

function p.instsin( frame ) -- მოქმედებითი
	return getnoun( frame.args[1], 'Q192997', 'Q110786' )
end

function p.prepsin( frame ) -- წინდებულიანი
	return getnoun( frame.args[1], 'Q2114906', 'Q110786' )
end

  -- მრავლობითი რიცხვი
function p.nomplur( frame ) -- სახელობითი
	return getnoun( frame.args[1], 'Q131105', 'Q146786' )
end

function p.genplur( frame ) -- ნათესაობითი
	return getnoun( frame.args[1], 'Q146233', 'Q146786' )
end

function p.datplur( frame ) -- მიცემითი
	return getnoun( frame.args[1], 'Q145599', 'Q146786' )
end

function p.accplur( frame ) -- ბრალდებითი
	return getnoun( frame.args[1], 'Q146078', 'Q146786' )
end

function p.instplur( frame ) -- მოქმედებითი
	return getnoun( frame.args[1], 'Q192997', 'Q146786' )
end

function p.prepplur( frame ) -- წინდებულიანი
	return getnoun( frame.args[1], 'Q2114906', 'Q146786' )
end

return p