Module:pl-common
Jump to navigation
Jump to search
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local u = mw.ustring.char
local rsplit = mw.text.split
local rfind = mw.ustring.find
local rmatch = mw.ustring.match
local rsubn = mw.ustring.gsub
local ulen = mw.ustring.len
local uupper = mw.ustring.upper
-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
local retval = rsubn(term, foo, bar)
return retval
end
-- version of rsubn() that returns a 2nd argument boolean indicating whether
-- a substitution was made.
local function rsubb(term, foo, bar)
local retval, nsubs = rsubn(term, foo, bar)
return retval, nsubs > 0
end
local function make_try(word)
return function(from, to)
local subbed
word, subbed = rsubb(word, "^(.*)" .. from .. "$", "%1" .. to)
if subbed then
return word
end
return nil
end
end
function export.soften_adj_masc_pers_pl(word)
local try = make_try(word)
return
try("chy", "si") or
try("hy", "si") or
try("sły", "śli") or
try("([crs])zły", "%2zli") or
try("zły", "źli") or
try("łły", "lli") or
try("ły", "li") or
try("ry", "rzy") or
try("sny", "śni") or
try("([crs])zny", "%2zni") or
try("zny", "źni") or
try("ny", "ni") or
try("sty", "ści") or
try("ty", "ci") or
try("([crs])zdy", "%2zdzi") or
try("zdy", "ździ") or
try("dy", "dzi") or
try("szy", "si") or
try("([bfmpvw])y", "%2i") or
try("ki", "cy") or
try("gi", "dzy") or
word
end
return export