Module:Pt-conj/table

local exports = {}
local lang = require('Module:languages').getByCode('pt')

local function makeLink(term, face, allow_self_link)
    local m_links = require('Module:links')
    return m_links.full_link({term = term, lang = lang}, face, allow_self_link)
end

local function verbInformation(verb_data)
    local function verbDescription()
        local description = "This is "
        if verb_data.irregular then
            description = description .. "an irregular "
        else
            description = description .. "a regular "
        end
        if verb_data.abundant then description = description .. "abundant " end
        if verb_data.defective then description = description .. "defective " end
        return description .. "verb of the '''-" .. verb_data.suffix .. "''' group."
    end

    local function verbExamples()
        local examples = {}
        for i, verb in ipairs(verb_data.examples) do
            table.insert(examples,  makeLink(verb, 'term', true))
        end
        return table.concat(examples, ', ')
    end

    local module = string.sub(verb_data.suffix, #verb_data.suffix-1)
    local edit_link = "[".. tostring(mw.uri.fullUrl(
        "Module:pt-conj/data/-"..module, {action='edit'}))
            .." [edit]]"

    return "'''Notes''':<sup class='plainlinks'>" .. edit_link .. "</sup>\n"
            .. "* "  .. verbDescription() .. "\n"
            .. "* " .. table.concat(verb_data.comments, "\n* ") .. "\n"
            .. "* Verbs with this conjugation include: " .. verbExamples() .. "."
end

local function navHeadText(verb_data)
    return "&nbsp;&nbsp;Conjugation of the [[Appendix:" .. lang:getCanonicalName() .. " verbs|" ..
            lang:getCanonicalName() .. " ''-" ..
            verb_data.suffix .. "'' verb]] " ..
            "''" .. verb_data.forms.infn.impe .. "''"
end

-- main entry point for this module, renders table with all verb forms
function exports.create(verb_data)
    local has_short_pp = verb_data.forms.short_part_past and verb_data.forms.long_part_past
    local function lookup(s)
        local parts = mw.text.split(s, '%.')
        local f = verb_data.forms
        for i, k in ipairs(parts) do
            if f == nil then break end
            f = f[k]
        end
        return f
    end

    local function linkForm(form)
        return makeLink(form, nil, false)
    end

    local function verbForm(param)
        local stdform = lookup(param)
        local text = stdform and stdform ~= '' and linkForm(stdform) or '-'
        local altforms  = lookup(param .. '_alt')
        local defective = lookup(param .. '_defective')
        local obsolete  = lookup(param .. '_obsolete')
        if altforms then
            for _, form in ipairs(altforms) do
                text = text .. '<br/>' ..linkForm(form)
            end
        end
        if defective then
            text = text .. "<br/><small>'''Normally defective:'''</small><br/>''" .. linkForm(defective) .. "''"
        end
        if obsolete then
            text = text .. "<br/><small>'''Obsolete:'''</small><br/>''" .. linkForm(obsolete) .. "''"
        end
        return text
    end

    local function repl(param)
        if param == 'navhead' then
            return navHeadText(verb_data)
        elseif param == 'verbInformation' then
            return verbInformation(verb_data)
        elseif param then
            return verbForm(param)
        end
    end

    local function pastParticiple()
        if has_short_pp then
            return [=[
! style="border: 1px solid #999999; background:#ffc498" colspan="7" | ''Short past participle''<sup><small>[1]</small></sup>
|-
! style="border: 1px solid #999999; background:#dfa478" | Masculine
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{short_part_past.sing.m}}}
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{short_part_past.plur.m}}}
|-
! style="border: 1px solid #999999; background:#dfa478" | Feminine
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{short_part_past.sing.f}}}
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{short_part_past.plur.f}}}
|-
! style="border: 1px solid #999999; background:#ffc498" colspan="7" | ''Long past participle''<sup><small>[2]</small></sup>
|-
! style="border: 1px solid #999999; background:#dfa478" | Masculine
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{long_part_past.sing.m}}}
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{long_part_past.plur.m}}}
|-
! style="border: 1px solid #999999; background:#dfa478" | Feminine
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{long_part_past.sing.f}}}
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{long_part_past.plur.f}}}
]=]
        else
            return [=[
! style="border: 1px solid #999999; background:#ffc498" colspan="7" | ''Past participle''
|-
! style="border: 1px solid #999999; background:#dfa478" | Masculine
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{part_past.sing.m}}}
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{part_past.plur.m}}}
|-
! style="border: 1px solid #999999; background:#dfa478" | Feminine
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{part_past.sing.f}}}
| style="border: 1px solid #999999; vertical-align: top;" colspan="3" | {{{part_past.plur.f}}}
]=]
        end
    end

    local wikicode = [=[<div class="NavFrame" style="clear:both; white-space: nowrap">
<div class="NavHead">{{{navhead}}}</div>
<div class="NavContent" align="left">
{| class="inflection-table" style="background:#F6F6F6; text-align: left; border: 1px solid #999999;" cellpadding="3" cellspacing="0"
|-
| style="border: 1px solid #999999;" colspan="7" | {{{verbInformation}}}
|-
! style="border: 1px solid #999999; background:#B0B0B0" rowspan="2" |
! style="border: 1px solid #999999; background:#D0D0D0" colspan="3" | Singular
! style="border: 1px solid #999999; background:#D0D0D0" colspan="3" | Plural
|-
! style="border: 1px solid #999999; background:#D0D0D0; width:12.5%" | First-person<br>([[eu#Portuguese|eu]])
! style="border: 1px solid #999999; background:#D0D0D0; width:12.5%" | Second-person<br>([[tu#Portuguese|tu]])
! style="border: 1px solid #999999; background:#D0D0D0; width:12.5%" | Third-person<br>([[ele#Portuguese|ele]] / [[ela#Portuguese|ela]] / [[você#Portuguese|você]])
! style="border: 1px solid #999999; background:#D0D0D0; width:12.5%" | First-person<br>([[nós#Portuguese|nós]])
! style="border: 1px solid #999999; background:#D0D0D0; width:12.5%" | Second-person<br>([[vós#Portuguese|vós]])
! style="border: 1px solid #999999; background:#D0D0D0; width:12.5%" | Third-person<br>([[eles#Portuguese|eles]] / [[elas#Portuguese|elas]] / [[vocês#Portuguese|vocês]])
|-
! style="border: 1px solid #999999; background:#c498ff" colspan="7" | ''Infinitive''
|-
! style="border: 1px solid #999999; background:#a478df" | '''Impersonal'''
| style="border: 1px solid #999999; vertical-align: top;" colspan="6" | {{{infn.impe}}}
|-
! style="border: 1px solid #999999; background:#a478df" | '''Personal'''
| style="border: 1px solid #999999; vertical-align: top;" | {{{infn.pers.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{infn.pers.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{infn.pers.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{infn.pers.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{infn.pers.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{infn.pers.plur.3}}}
|-
! style="border: 1px solid #999999; background:#98ffc4" colspan="7" | ''Gerund''
|-
| style="border: 1px solid #999999; background:#78dfa4" |
| style="border: 1px solid #999999; vertical-align: top;" colspan="6" | {{{part_pres}}}
|-
]=] .. pastParticiple() .. [=[
|-
! style="border: 1px solid #999999; background:#d0dff4" colspan="7" | ''Indicative''
|-
! style="border: 1px solid #999999; background:#b0bfd4" | Present
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pres.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pres.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pres.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pres.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pres.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pres.plur.3}}}
|-
! style="border: 1px solid #999999; background:#b0bfd4" | Imperfect
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.impf.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.impf.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.impf.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.impf.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.impf.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.impf.plur.3}}}
|-
! style="border: 1px solid #999999; background:#b0bfd4" | Preterite
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pret.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pret.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pret.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pret.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pret.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.pret.plur.3}}}
|-
! style="border: 1px solid #999999; background:#b0bfd4" | Pluperfect
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.plpf.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.plpf.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.plpf.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.plpf.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.plpf.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.plpf.plur.3}}}
|-
! style="border: 1px solid #999999; background:#b0bfd4" | Future
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.futu.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.futu.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.futu.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.futu.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.futu.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.futu.plur.3}}}
|-
! style="border: 1px solid #999999; background:#ffffaa" colspan="7" | ''Conditional''
|-
! style="border: 1px solid #999999; background:#ddddaa" |
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.cond.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.cond.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.cond.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.cond.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.cond.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{indi.cond.plur.3}}}
|-
! style="border: 1px solid #999999; background:#d0f4d0" colspan="7" | ''Subjunctive''
|-
! style="border: 1px solid #999999; background:#b0d4b0" | Present
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.pres.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.pres.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.pres.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.pres.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.pres.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.pres.plur.3}}}
|-
! style="border: 1px solid #999999; background:#b0d4b0" | Imperfect
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.impf.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.impf.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.impf.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.impf.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.impf.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.impf.plur.3}}}
|-
! style="border: 1px solid #999999; background:#b0d4b0" | Future
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.futu.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.futu.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.futu.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.futu.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.futu.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{subj.futu.plur.3}}}
|-
! style="border: 1px solid #999999; background:#f4e4d0" colspan="7" | ''Imperative''
|-
! style="border: 1px solid #999999; background:#d4c4b0" | Affirmative
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.affr.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.affr.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.affr.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.affr.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.affr.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.affr.plur.3}}}
|-
! style="border: 1px solid #999999; background:#d4c4b0" | Negative ([[não#Portuguese|não]])
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.negt.sing.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.negt.sing.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.negt.sing.3}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.negt.plur.1}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.negt.plur.2}}}
| style="border: 1px solid #999999; vertical-align: top;" | {{{impe.negt.plur.3}}}
|}
]=] .. (has_short_pp and [=[
* <sup><small>[1]</small></sup> Used with auxiliary verbs [[ser#Portuguese|ser]] and [[estar#Portuguese|estar]];
* <sup><small>[2]</small></sup> Used with auxiliary verbs [[haver#Portuguese|haver]] and [[ter#Portuguese|ter]].
]=] or '') ..
            [=[
            </div>
            </div>]=]
    local replaced, _ = mw.ustring.gsub(wikicode, "{{{([a-zA-Z0-9._]+)}}}", repl)
    return replaced
end

return exports

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.