Bu Lua modülü, şu şablonların çıktısını vermektedir:
local export = {}
local pos_functions = {}
local rfind = mw.ustring.find
local rmatch = mw.ustring.match
local rsubn = mw.ustring.gsub
local rsplit = mw.text.split
local lang = require("Modül:diller").getirKodaGore("fr")
local suffix_categories = {
= true,
= true,
= true,
= true,
= true,
}
-- 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
local function track(page)
--require("Modül:debug").track("fr-headword/" .. page)
return true
end
-- mw.title.new() returns nil if there are weird chars in
-- the pagename.
local function exists(pagename)
local title = mw.title.new(pagename)
return title and title.exists
end
local function add_suffix(list, suffix)
local newlist = {}
for _, item in ipairs(list) do
local form
if suffix == "s" then
if rfind(item, "$") then
form = item
elseif rfind(item, "al$") then
form = rsub(item, "al$", "aux")
else
form = item .. suffix
end
elseif suffix == "e" then
if rfind(item, "e$") then
form = item
elseif rfind(item, "en$") then
form = item .. "ne"
elseif rfind(item, "er$") then
form = rsub(item, "er$", "ère")
elseif rfind(item, "el$") then
form = item .. "le"
elseif rfind(item, "et$") then
form = item .. "te"
elseif rfind(item, "on$") then
form = item .. "ne"
elseif rfind(item, "ieur$") then
form = item .. "e"
elseif rfind(item, "teur$") then
form = rsub(item, "teur$", "trice")
elseif rfind(item, "eu$") then
form = rsub(item, "eu$", "euse")
elseif rfind(item, "if$") then
form = rsub(item, "if$", "ive")
elseif rfind(item, "c$") then
form = rsub(item, "c$", "que")
else
form = item .. suffix
end
else
form = item .. suffix
end
table.insert(newlist, form)
end
return newlist
end
local no_split_words = {
= true,
= true,
= true,
}
-- Auto-add links to a "space word" (after splitting on spaces). We split off
-- final punctuation, and then split on hyphens if split_dash is given, and
-- also split on apostrophes, including the apostrophe in the link to its left
-- (so we auto-split "l'eau" as "]]).
local function add_space_word_links(space_word, split_dash)
local space_word_no_punct, punct = rmatch(space_word, "^(.*)()$")
space_word_no_punct = space_word_no_punct or space_word
punct = punct or ""
local words
-- don't split prefixes and suffixes
if not split_dash or rfind(space_word_no_punct, "^%-") or rfind(space_word_no_punct, "%-$") then
words = {space_word_no_punct}
else
words = rsplit(space_word_no_punct, "%-")
end
local linked_words = {}
for _, word in ipairs(words) do
if not no_split_words and rfind(word, "'") then
word = rsub(word, "(+')", "]")
word = rsub(word, "%](]*)$", "]]")
else
word = "]"
end
table.insert(linked_words, word)
end
return table.concat(linked_words, "-") .. punct
end
-- Auto-add links to a lemma. We split on spaces, and also on hyphens
-- if split_dash is given or the word has no spaces. In addition, we split
-- on apostrophes, including the apostrophe in the link to its left
-- (so we auto-split "de l'eau" as "] ]]"). We don't always
-- split on hyphens because of cases like "boire du petit-lait" where
-- "petit-lait" should be linked as a whole, but provide the option to do it
-- for cases like "croyez-le ou non". If there's no space, however, then
-- it makes sense to split on hyphens by default (e.g. for "avant-avant-hier").
-- Cases where only some of the hyphens should be split can always be handled
-- by explicitly specifying the head (e.g. "Nord-Pas-de-Calais").
local function add_lemma_links(lemma, split_dash)
if not rfind(lemma, " ") then
split_dash = true
end
local words = rsplit(lemma, " ")
local linked_words = {}
for _, word in ipairs(words) do
table.insert(linked_words, add_space_word_links(word, split_dash))
end
local retval = table.concat(linked_words, " ")
-- If we ended up with a single link consisting of the entire lemma,
-- remove the link.
local unlinked_retval = rmatch(retval, "^%]*)%]%]$")
return unlinked_retval or retval
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local PAGENAME = mw.title.getCurrentTitle().text
local poscat = frame.args or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local params = {
= {},
= {list = true},
= {type = "boolean"},
= {type = "boolean"},
}
if rfind(PAGENAME, " ") then
track("space")
end
if pos_functions then
for key, val in pairs(pos_functions.params) do
params = val
end
end
local parargs = frame:getParent().args
local args = require("Modül:parameters").process(parargs, params)
local heads = args
if pos_functions and pos_functions.param1_is_head and args then
-- FIXME! REMOVE ME! Hack to correspond to previous template code in {{fr-adv}}.
if args == "-" then
track("arg1dash")
else
table.insert(heads, 1, args)
end
end
local auto_linked_head = add_lemma_links(PAGENAME, args)
if #heads == 0 then
heads = {auto_linked_head}
else
for _, head in ipairs(heads) do
if head == auto_linked_head then
track("redundant-head")
end
end
end
local veri = {dil = lang, soz_kategorisi = poscat, kategoriler = {}, baslar = {head}, cinsiyetler = {}, cekimler = {}}
if args then
veri.soz_kategorisi = "suffixes"
if suffix_categories then
local singular_poscat = poscat:gsub("s$", "")
table.insert(veri.kategoriler, lang:getirAsilAd() .. " " .. singular_poscat .. "-forming suffixes")
else
error("No category exists for suffixes forming " .. poscat .. ".")
end
end
if pos_functions then
pos_functions.func(args, veri)
end
return require("Modül:başlık başı").tam_baslikbasi(veri)
end
local allowed_genders = {
= true,
= true,
= true,
= true,
= true,
= true,
= true,
= true,
= true,
= true,
= true,
= true,
}
local function get_noun_pos(is_proper)
return {
params = {
= {},
= {list = true},
= {list = true},
= {list = true},
= {list = true},
= {list = true},
},
func = function(args, veri)
local PAGENAME = mw.title.getCurrentTitle().text
local function default_plural()
if rfind(PAGENAME, 'x$') then
track("default-x")
end
if rfind(PAGENAME, 'z$') then
track("default-z")
end
if rfind(PAGENAME, '$') then
return PAGENAME
elseif rfind(PAGENAME, 'u$') then
return "x"
elseif rfind(PAGENAME, 'al$') then
return mw.ustring.sub(PAGENAME, 1, -3) .. 'aux'
else
return "s"
end
end
-- Gather genders
local function insert_gender(g)
if g == "ed" or g == "mf" then
table.insert(veri.cinsiyetler, "e")
table.insert(veri.cinsiyetler, "d")
else
table.insert(veri.cinsiyetler, g)
end
end
insert_gender(args)
for _, g in ipairs(args.c) do
insert_gender(g)
end
-- Gather all the plural parameters from the numbered parameters.
local plurals = args
plurals.etiket = "çoğulu"
plurals.accel = {form = "ç"}
plurals.request = true
-- Gather all the feminine parameters
local feminines = args
feminines.etiket = "dişili"
-- Gather all the masculine parameters
local masculines = args
masculines.etiket = "erili"
-- Add categories for genders
if #veri.cinsiyetler == 0 then
table.insert(veri.cinsiyetler, "?")
end
local mode = nil
for _, g in ipairs(veri.cinsiyetler) do
if g == "m-p" or g == "f-p" or g == "e-ç" or g == "d-ç" then
mode = "ç"
end
if g == "?" and (is_proper or mw.title.getCurrentTitle().nsText == "Şablon") then
-- allow unknown gender in template example and proper nouns,
-- since there are currently so many proper nouns with
-- unspecified gender
elseif g and g ~= "" and not allowed_genders then
error("Unrecognized French gender: " .. g)
end
if g == "m" or g == "m-p" or g == "m-s"
or g == "e" or g == "e-ç" or g == "e-t" then
table.insert(veri.kategoriler, "Fransızca eril adlar")
elseif g == "f" or g == "f-p" or g == "f-s"
or g == "d" or g == "d-ç" or g == "d-t" then
table.insert(veri.kategoriler, "Fransızca dişil adlar")
end
end
-- Decide how to show the plurals
mode = mode or plurals
-- Plural is not attested
if mode == "!" then
table.insert(veri.cekimler, {etiket = "çoğulu onaylanmamış"})
table.insert(veri.kategoriler, "Fransızca nouns with unattested plurals")
-- Plural-only noun, doesn't have a plural
elseif mode == "ç" then
table.insert(veri.cekimler, {etiket = "topluluk adı"})
table.insert(veri.kategoriler, "Fransızca topluluk adları")
else
-- Plural is unknown
if mode == "?" then
table.remove(plurals, 1) -- Remove the mode parameter
-- Uncountable noun; may occasionally have a plural
elseif mode == "-" then
table.remove(plurals, 1) -- Remove the mode parameter
table.insert(veri.kategoriler, "Fransızca sayılamayan adlar")
-- If plural forms were given explicitly, then show "usually"
if #plurals > 0 then
track("count-uncount")
table.insert(veri.cekimler, {etiket = "usually ]"})
table.insert(veri.kategoriler, "Fransızca sayılabilen adlar")
else
table.insert(veri.cekimler, {etiket = "]"})
end
-- Mixed countable/uncountable noun, always has a plural
elseif mode == "~" then
table.remove(plurals, 1) -- Remove the mode parameter
table.insert(veri.cekimler, {etiket = "] ve ]"})
table.insert(veri.kategoriler, "Fransızca sayılamayan adlar")
table.insert(veri.kategoriler, "Fransızca sayılabilen adlar")
-- If no plural was given, add a default one now
if #plurals == 0 then
table.insert(plurals, default_plural())
end
-- Default proper noun; uncountable unless plural(s) specified
elseif is_proper then
if #plurals > 0 then
table.insert(veri.kategoriler, "Fransızca sayılabilen adlar")
else
table.insert(veri.kategoriler, "Fransızca sayılamayan adlar")
end
-- The default, always has a plural
else
table.insert(veri.kategoriler, "Fransızca sayılabilen adlar")
-- If no plural was given, add a default one now
if #plurals == 0 then
table.insert(plurals, default_plural())
end
end
-- Process the plural forms
for i, pl in ipairs(plurals) do
if pl == "*" then
pl = PAGENAME
elseif pl == "s" then
pl = PAGENAME .. "s"
elseif pl == "x" then
pl = PAGENAME .. "x"
end
if not exists(pl) then
table.insert(veri.kategoriler, "Fransızca kırmızı bağlantılı çoğulu olan adlar")
end
plurals = pl
end
-- Add the plural forms; do this in some cases even if no plurals
-- specified so we get a "please provide plural" message.
if mode ~= "-" and (not is_proper or mode) or #plurals > 0 then
table.insert(veri.cekimler, plurals)
end
end
-- Add the feminine forms
if #feminines > 0 then
table.insert(veri.cekimler, feminines)
for _, f in ipairs(feminines) do
if not exists(f) then
table.insert(veri.kategoriler, "Fransızca kırmızı bağlantılı çekimi olan adlar")
end
end
end
-- Add the masculine forms
if #masculines > 0 then
table.insert(veri.cekimler, masculines)
for _, m in ipairs(masculines) do
if not exists(m) then
table.insert(veri.kategoriler, "Fransızca kırmızı bağlantılı çekimi olan adlar")
end
end
end
-- Handle diminutives
if #args.dim > 0 then
local dims_infl = mw.clone(args.dim)
dims_infl.etiket = "diminutive"
dims_infl.accel = {form = "diminutive"}
table.insert(veri.cekimler, dims_infl)
end
end
}
end
pos_functions = get_noun_pos(false)
pos_functions = get_noun_pos(true)
pos_functions = {
params = {
= {list = true},
= {alias_of = "g"},
= {list = true},
= {list = true},
= {list = true, allow_holes = true},
= {list = true},
= {list = true, allow_holes = true},
= {list = true},
= {list = true, allow_holes = true},
= {list = true},
= {list = true, allow_holes = true},
= {list = true},
= {list = true, allow_holes = true},
},
func = function(args, veri)
local PAGENAME = mw.title.getCurrentTitle().text
-- Gather genders
local function insert_gender(g)
if g == "mf" or g == "ed" then
table.insert(veri.cinsiyetler, "e")
table.insert(veri.cinsiyetler, "d")
else
table.insert(veri.cinsiyetler, g)
end
end
for _, g in ipairs(args.c) do
insert_gender(g)
end
local function process_inflection(etiket, infls, quals)
infls.etiket = etiket
for i, infl in ipairs(infls) do
if quals then
infls = {term = infl, qualifiers = {quals}}
end
end
end
-- Gather all inflections.
process_inflection("erili", args, args)
process_inflection("dişili", args, args)
process_inflection("eril çoğulu", args, args)
process_inflection("dişil çoğulu", args, args)
process_inflection("çoğulu", args, args)
-- Add categories for genders
if #veri.cinsiyetler == 0 then
table.insert(veri.cinsiyetler, "?")
end
-- Validate/canonicalize genders
for i, g in ipairs(veri.cinsiyetler) do
if g == "?" and mw.title.getCurrentTitle().nsText == "Şablon" then
-- allow unknown gender in template example
elseif g == "?" then
-- FIXME, remove this branch once we've added the required genders
track("missing-pron-gender")
elseif g and g ~= "" and not allowed_genders then
error("Tanınmayan Fransızca cinsiyeti: " .. g)
end
end
-- Add the inflections
if #args > 0 then
table.insert(veri.cekimler, args)
end
if #args > 0 then
table.insert(veri.cekimler, args)
end
if #args > 0 then
table.insert(veri.cekimler, args)
end
if #args > 0 then
table.insert(veri.cekimler, args)
end
if #args > 0 then
table.insert(veri.cekimler, args)
end
end
}
local function get_misc_pos()
return {
param1_is_head = true,
params = {
= {},
},
func = function(args, veri)
end
}
end
pos_functions = get_misc_pos()
pos_functions = get_misc_pos()
pos_functions = get_misc_pos()
pos_functions = get_misc_pos()
pos_functions = get_misc_pos()
pos_functions = get_misc_pos()
pos_functions = get_misc_pos()
pos_functions = get_misc_pos()
pos_functions = get_misc_pos()
pos_functions = get_misc_pos()
pos_functions = {
params = {
= {},
= {},
= {},
= {},
= {list = true},
= {list = true},
= {list = true},
= {list = true},
= {list = true},
= {list = true},
= {list = true},
},
func = function(args, veri)
local PAGENAME = mw.title.getCurrentTitle().text
if args.tekc == "p" or args.tekc == "m-p" or args.tekc == "f-p"
or args.tekc == "ç" or args.tekc == "e-ç" or args.tekc == "d-ç" then
table.insert(veri.kategoriler, "Fransızca topluluk adları")
end
if args.tekc == "s" or args.tekc == "m-s" or args.tekc == "f-s"
or args.tekc == "t" or args.tekc == "e-t" or args.tekc == "d-t" then
table.insert(veri.kategoriler, "Fransızca singularia tantum")
end
if args.tekc then
table.insert(veri.kategoriler, "Fransızca defective adjectives")
end
if args.tekc == "p" or args.tekc == "ç" then
table.insert(veri.cekimler, {etiket = "sadece çoğulu"})
if args ~= "mf" or args ~= "ed" then
-- Handle feminine plurals
if #args > 0 then
local fplurals_infl = mw.clone(args)
fplurals_infl.etiket = "feminine plural"
fplurals_infl.accel = {form = "d|ç"}
table.insert(veri.cekimler, fplurals_infl)
end
end
elseif args.tekc == "s" or args.tekc == "t" then
table.insert(veri.cekimler, {etiket = "sadece tekili"})
if not ((args == "mf" or args == "ed") or #args.d == 0 and rfind(PAGENAME, "e$")) then
-- Handle feminines
local feminines = #args.d > 0 and args.d or add_suffix(#args.current > 0 and args.current or {PAGENAME}, "e")
local feminines_infl = mw.clone(feminines)
feminines_infl.etiket = "dişil tekili"
feminines_infl.accel = {form = "d|t"}
table.insert(veri.cekimler, feminines_infl)
end
elseif args.tekc == "m" or args.tekc == "e" then
table.insert(veri.cinsiyetler, "m")
table.insert(veri.cekimler, {etiket = "sadece erili"})
-- Handle masculine plurals
local mplurals = #args > 0 and args or add_suffix(#args.current > 0 and args.current or {PAGENAME}, "s")
local mplurals_infl = mw.clone(mplurals)
mplurals_infl.etiket = "eril çoğulu"
mplurals_infl.accel = {form = "e|ç"}
table.insert(veri.cekimler, mplurals_infl)
elseif args.tekc == "f" or args.tekc == "d" then
table.insert(veri.cinsiyetler, "d")
table.insert(veri.cekimler, {etiket = "sadece dişili"})
-- Handle feminine plurals
local fplurals = #args > 0 and args or add_suffix(#args.current > 0 and args.current or {PAGENAME}, "s")
local fplurals_infl = mw.clone(fplurals)
fplurals_infl.etiket = "dişil çoğulu"
fplurals_infl.accel = {form = "d|ç"}
table.insert(veri.cekimler, fplurals_infl)
elseif args.tekc then
table.insert(veri.cinsiyetler, args.tekc)
table.insert(veri.cekimler, {etiket = "defective"})
else
-- Gather genders
local gender = args
-- Default to mf if base form ends in -e and no feminine,
-- feminine plural or gender specified
if not gender and #args.d == 0 and #args == 0 and rfind(PAGENAME, "e$") then
gender = "ed"
end
if #args.current > 0 then
track("adj-current")
end
if args.inv then
table.insert(veri.cekimler, {etiket = "invariable"})
end
-- Handle plurals of mf adjectives
local plurals = #args > 0 and args or {PAGENAME .. "s"}
if not args.inv and (gender == "mf" or gender == "ed") then
local plurals_infl = mw.clone(plurals)
plurals_infl.etiket = "çoğulu"
plurals_infl.accel = {form = "ç"}
table.insert(veri.cekimler, plurals_infl)
end
if not args.inv and gender ~= "ed" and gender ~= "mf" then
-- Handle case of special masculine singular before vowel
if args.e2 then
local masc_before_vowel = {args.e2}
masc_before_vowel.etiket = "sesliden önce eril tekili"
masc_before_vowel.accel = {form = "e|t"}
table.insert(veri.cekimler, masc_before_vowel)
end
-- Handle feminines
local feminines = #args.d > 0 and args.d or add_suffix(#args.current > 0 and args.current or {PAGENAME}, "e")
local feminines_infl = mw.clone(feminines)
feminines_infl.etiket = "dişil tekili"
feminines_infl.accel = {form = "d|t"}
table.insert(veri.cekimler, feminines_infl)
-- Handle masculine plurals
local mplurals = #args > 0 and args or add_suffix(#args.current > 0 and args.current or {PAGENAME}, "s")
local mplurals_infl = mw.clone(mplurals)
mplurals_infl.etiket = "eril çoğulu"
mplurals_infl.accel = {form = "e|ç"}
table.insert(veri.cekimler, mplurals_infl)
-- Handle feminine plurals
local fplurals = #args > 0 and args or add_suffix(feminines, "s")
local fplurals_infl = mw.clone(fplurals)
fplurals_infl.etiket = "dişil çoğulu"
fplurals_infl.accel = {form = "d|ç"}
table.insert(veri.cekimler, fplurals_infl)
end
end
-- Handle comparatives
if #args.comp > 0 then
local comps_infl = mw.clone(args.comp)
comps_infl.etiket = "comparative"
comps_infl.accel = {form = "comparative"}
table.insert(veri.cekimler, comps_infl)
end
-- Handle superlatives
if #args.sup > 0 then
local sups_infl = mw.clone(args.sup)
sups_infl.etiket = "superlative"
sups_infl.accel = {form = "superlative"}
table.insert(veri.cekimler, sups_infl)
end
-- Check existence
for key, val in pairs(veri.cekimler) do
for i, form in ipairs(val) do
if not exists(form) then
table.insert(veri.kategoriler, "Fransızca kırmızı bağlantılı çekimi olan ön adlar")
return
end
end
end
end
}
pos_functions = {
param1_is_head = true,
params = {
= {},
= {list = true},
},
func = function(args, veri)
local PAGENAME = mw.title.getCurrentTitle().text
for _, ty in ipairs(args.type) do
local category, etiket
if ty == "auxiliary" then
category = "auxiliary verbs"
elseif ty == "defective" then
category = "defective verbs"
etiket = "]"
elseif ty == "impersonal" then
category = "impersonal verbs"
etiket = "]"
elseif ty == "modal" then
category = "modal verbs"
elseif ty == "reflexive" then
category = "reflexive verbs"
elseif ty == "transitive" then
etiket = "]"
elseif ty == "intransitive" then
etiket = "]"
elseif ty == "ambitransitive" or ty == "ambi" then
etiket = "] and ]"
end
if category then
table.insert(veri.kategoriler, "Fransızca " .. category)
end
if etiket then
table.insert(veri.cekimler, {etiket = etiket})
end
end
end
}
return export
-- For Vim, so we get 4-space tabs
-- vim: set ts=4 sw=4 noet: