Uwaga
Serwis Wedariusz jest portalem tematycznym prowadzonym przez Grupę Wedamedia. Aby zostać wedapedystą, czyli Użytkownikiem z prawem do tworzenia i edycji artykułów, wystarczy zarejestrować się na witrynie poprzez złożenie wniosku o utworzenie konta, co można zrobić tutaj. Liczymy na Waszą pomoc oraz wsparcie merytoryczne przy rozwoju także naszych innych serwisów tematycznych.

Moduł:odmiana-rzeczownik-polski-błędy

Z Wedariusz, słownik
Przejdź do nawigacji Przejdź do wyszukiwania

Moduł obsługiwany przez szablon {{odmiana-rzeczownik-polski}}. Zobacz też: Moduł:odmiana.


local Declension = require 'Module:odmiana' .Declension

Declension.separators = { ', ', ' lub ', ' albo ', ' i ' }

local p = {
	
main = function ( frame )
	local title = mw.title.getCurrentTitle()
	
	if
		not title:inNamespace( 0 ) or
		( string.find( title.text, ' ' ) ) or
		( string.find( title.text, '-' ) ) or
		( string.sub( title.text, -1) == '.')
	then
		return ''
	end
	
	local decl = Declension:new( frame:getParent().args, 'nieodm', {
		[ 'Mianownik lp' ]   = 'M_lp',  [ 'Mianownik lm' ]   = 'M_lm',
		[ 'Dopełniacz lp' ]  = 'D_lp',  [ 'Dopełniacz lm' ]  = 'D_lm',
		[ 'Celownik lp' ]    = 'C_lp',  [ 'Celownik lm' ]    = 'C_lm',
		[ 'Biernik lp' ]     = 'B_lp',  [ 'Biernik lm' ]     = 'B_lm',
		[ 'Narzędnik lp' ]   = 'N_lp',  [ 'Narzędnik lm' ]   = 'N_lm',
		[ 'Miejscownik lp' ] = 'Ms_lp', [ 'Miejscownik lm' ] = 'Ms_lm',
		[ 'Wołacz lp' ]      = 'W_lp',  [ 'Wołacz lm' ]      = 'W_lm'
	}, function ( data )
		return {
			exists_M_lp = data.M_lp and true or false,
			exists_M_lm = data.M_lm and true or false,
			empty       = not (
				data.M_lp or data.D_lp or data.C_lp or data.B_lp or
				data.N_lp or data.Ms_lp or data.W_lp or
				data.M_lm or data.D_lm or data.C_lm or data.B_lm or
				data.N_lm or data.Ms_lm or data.W_lm
			)
		}
	end)
	
	if decl.empty then
		return ''
	end
	
	local pagename = title.text
	local output = {}
	local category = 'Kategoria:Prawdopodobny błąd w polskiej odmianie'
	local myUString = mw.ustring
	local isCollNumeral = decl:endsWith( 'M_lm', 'oro' )
	
	-- 1: Mianownik liczby pojedynczej jest inny niż tytuł strony
	if
		decl.exists_M_lp and
		not decl:equals( 'M_lp', pagename )
	then
		output[ #output + 1 ] = '[[' .. category .. '|1]]'
	end
		
	-- 2: Nieprawidłowa końcówka biernika liczby pojedynczej
	if decl.exists_M_lp and not (
		decl:equals( 'B_lp', pagename ) or
		decl:endsWith( 'B_lp', 'a', 'ę', 'ą', 'ego' ) or
		decl:endsWith( 'M_lp', 'y' )
	) then
		output[ #output + 1 ] = '[[' .. category .. '|2]]'
	end
	
	-- 3: Liczba pojedyncza istnieje, jednak jedna z form liczby pojedynczej jest niewypełniona
	if
		decl.exists_M_lp and
		decl:missingForm( 'D_lp', 'C_lp', 'B_lp', 'N_lp', 'Ms_lp', 'W_lp' )
	then
		output[ #output + 1 ] = '[[' .. category .. '|3]]'
	end
		
	-- 4: Brak liczby pojedynczej, a mianownik liczby mnogiej nie zgadza się z tytułem strony
	-- 5: Nie podano mianownika liczby pojedynczej ani mnogiej
	if not decl.exists_M_lp then
		if not decl.exists_M_lm then
			output[ #output + 1 ] = '[[' .. category .. '|5]]'
		elseif not decl:equals( 'M_lm', pagename ) then
			output[ #output + 1 ] = '[[' .. category .. '|4]]'
		end
	end
		
	-- 6: Liczba mnoga istnieje, jednak jedna z form liczby mnogiej jest niewypełniona
	if
		decl.exists_M_lm and
		decl:missingForm( 'D_lm', 'C_lm', 'B_lm', 'N_lm', 'Ms_lm', 'W_lm' )
	then
		output[ #output + 1 ] = '[[' .. category .. '|6]]'
	end
	
	-- 7: Celownik liczby mnogiej nie kończy się na "om", "im", "ym"
	if
		decl.exists_M_lm and
		not isCollNumeral and
		not decl:endsWith( 'C_lm', 'om', 'im', 'ym' )
	then
		output[ #output + 1 ] = '[[' .. category .. '|7]]'
	end
		
	-- 8: Narzędnik liczby mnogiej nie kończy się na "ami", "imi", "ymi"
	if
		decl.exists_M_lm and
		not isCollNumeral and
		not decl:endsWith( 'N_lm', 'ami', 'imi', 'ymi' )
	then
		output[ #output + 1 ] = '[[' .. category .. '|8]]'
	end
	
	-- 9: Miejscownik liczby mnogiej nie kończy się na "ach", "ich", "ych"
	if
		decl.exists_M_lm and
		not isCollNumeral and
		not decl:endsWith( 'Ms_lm', 'ach', 'ich', 'ych' )
	then
		output[ #output + 1 ] = '[[' .. category .. '|9]]'
	end
		
	-- A: Wołacz liczby mnogiej jest inny niż mianownik liczby mnogiej
	if
		decl.exists_M_lm and
		not decl:equals( 'M_lm', 'W_lm' )
	then
		output[ #output + 1 ] = '[[' .. category .. '|A]]'
	end
	
	-- B: Biernik liczby mnogiej nie jest równy ani mianownikowi, ani dopełniaczowi liczby mnogiej
	if
		decl.exists_M_lm and
		not decl:equals( 'B_lm', 'M_lm' ) and
		not decl:equals( 'B_lm', 'D_lm' )
	then
		output[ #output + 1 ] = '[[' .. category .. '|B]]'
	end
		
	-- I: Biernik liczby pojedynczej kończy się na "iię"
	if
		decl.exists_M_lp and
		not isCollNumeral and
		decl:endsWith( 'B_lp', 'iię' )
	then
		output[ #output + 1 ] = '[[' .. category .. '|I]]'
	end
		
	-- K: Narzędnik liczby pojedynczej kończy się na "kem"
	if
		decl.exists_M_lp and
		not isCollNumeral and
		decl:endsWith( 'N_lp', 'kem' )
	then
		output[ #output + 1 ] = '[[' .. category .. '|K]]'
	end
		
	-- P: Nie wszystkie formy zaczynają się na tę samą literę
	local letter = myUString.sub( pagename, 1, 1 )
	
	if ( decl.exists_M_lp and not (
		decl:startsWith( 'M_lp', letter ) and
		decl:startsWith( 'D_lp', letter ) and
		decl:startsWith( 'C_lp', letter ) and
		decl:startsWith( 'B_lp', letter ) and
		decl:startsWith( 'N_lp', letter ) and
		decl:startsWith( 'Ms_lp', letter ) and
		decl:startsWith( 'W_lp', letter )
	) ) or ( decl.exists_M_lm and not (
		decl:startsWith( 'M_lm', letter ) and
		decl:startsWith( 'D_lm', letter ) and
		decl:startsWith( 'C_lm', letter ) and
		decl:startsWith( 'B_lm', letter ) and
		decl:startsWith( 'N_lm', letter ) and
		decl:startsWith( 'Ms_lm', letter ) and
		decl:startsWith( 'W_lm', letter )
	) ) then
		output[ #output + 1 ] = '[[' .. category .. '|P]]'
	end
	
	return table.concat( output )
end}

return p