Module:Sandbox/AbstractWikipedia/Functions/fr
Appearance
From Meta, a Wikimedia project coordination wiki
Module documentation
[create]
You might want to create a documentation page for this Scribunto module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Please add categories to the /doc subpage. Subpages of this module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Please add categories to the /doc subpage. Subpages of this module.
localp={} localf=require("Module:Sandbox/AbstractWikipedia/Functions") locall=require("Module:Sandbox/AbstractWikipedia/Lexemes") localwd=require("Module:Sandbox/AbstractWikipedia/Wikidata") -- The following is a list of English-specific functions implementations for -- the template language -- Ideally, this should be replaced by fetching a lexeme from Wikidata. functionp.SimpleNoun(base_form,plural_form) localresult=l.newLexeme(base_form,"noun") result.addForm(base_form,{number="singular"}) plural_form=plural_formorbase_form.."s" result.addForm(plural_form,{number="plural"}) returnresult end localmonth_name={"janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"} functionp.Date(date) localresult='' ifdate.dayandtonumber(date.day)>0then result=result..date.day..' ' end ifdate.monthandtonumber(date.month)>0andtonumber(date.month)<=12then result=result..month_name[tonumber(date.month)]..' ' end ifdate.yearandtonumber(date.year)~=0then result=result..date.year end returnl.newLexeme(result,"noun") end -- Generates a pronoun lexeme; currently only third person. -- If a q_id is given, the generated pronoun will correspond to that item, -- otherwise a gender-variable pronoun ("he/she") is provided. functionp.Pronoun(q_id) ifq_idthen localgender=wd.getHumanGender(q_id) locallexeme ifgender=="feminine"then lexeme=f.Lexeme("L484")-- elle (she) elseifgender=="masculine"then lexeme=f.Lexeme("L485")-- il (he) elseifgender=="other"then lexeme=f.Lexeme("L485")-- il (he) -- lexeme = f.Lexeme("L371") -- iel? (they) else lexeme=f.Lexeme("L507")-- ce/ça (it) ? end if(wd.isDead(q_id))then -- We add a past tense feature for lexeme of dead people, as they are -- normally spoken about in the past tense. This can exposed to the -- verb by using the "tsubj relation". lexeme.addFeature("nominal_tense","past") end lexeme.log() returnlexeme else returnf.GenderedLexeme("L485","L484")-- il / elle (he / she) end end localordinals={"premier","deuxième","troisième"}-- FIXME: "premier" is masculine; the feminine is "première" -- Generates a lexeme corresponding to an ordinal number functionp.Ordinal(number) number=tonumber(number)-- allow string input as well -- For small ordinals return spelledout form ifnumber>0andnumber<=#ordinalsthen returnl.newLexeme(ordinals[number],"adjective") end -- Otherwise construct ordinal using number + ordinal suffix localsuffix='e' ifmath.abs(number)==1then suffix='er'--FIXME: replace by "re" is feminine" end returnl.newLexeme(tostring(number)..suffix,"adjective") end returnp