Module:pra-decl/noun
- The following documentation is located at Module:pra-decl/noun/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
Purpose
This module provides inflection tables for Prakrit for nouns, adjectives and potentially some pronouns. For pronouns, one currently uses the interface for nouns, while for adjectives one uses separate invocations for each gender. The script of the inflected forms is the one used for the stem.
Some functions are exported from this module to service the testing of noun inflection.
Normal Use
The normal way to use this module is to invoke a dialect-specific template. This invokes a dialect-specific exported function, which see for the interface. This invokes the internal function show
.
Dialect | Template | Function | Code | Data table |
---|---|---|---|---|
Ardhamagadhi | {{pra-ard-decl-noun}} |
pra_ard() |
pra-ard | Module:pra-decl/noun/pra-ard |
Maharashtri | {{pra-mah-decl-noun}} |
pra_mah() |
pra-mah | Module:pra-decl/noun/pra-mah |
Magadhi | {{pra-mag-decl-noun}} |
pra_mag() |
pra-mag | Module:pra-decl/noun/pra-mag |
Sauraseni | {{pra-sau-decl-noun}} |
pra_sau() |
pra-sau | Module:pra-decl/noun/pra-sau |
The Ardhamagadhi data table has not yet been written, and the Magadhi data table does not include the feminine declensions.
Data Modules
The data modules are for use on stems written in a slight customisation of IAST.
The data modules export a Lua table indexed by the final stem vowel and gender. The same value may be used for slightly different final vowels. These values are arrays for 16 different case/number combinations, and their values are an array of endings for that combination.
A stem and an ending are combined by the following rules, implemented in function joinSuffix
:
- For each '⌫' at the start of the ending, delete one character from the stem.
- Append the juncture marker 'Ⓙ' to the remains of the stem.
- Append the rest of the ending to the modified stem.
- Make adjustments at the junctures. For the initial use of the juncture marker, this consisted of adding diaereses when abutting vowels could be confused with diphthongs.
- Remove remaining juncture markers.
- Convert the result to the appropriate script.
Note that the tables follow the Hindu identification rules for the cases, which differ from the Pali rules. Thus, while in Pali the case forms used for the ablative plural and the dative are mostly the same as for the instrumental plural and dative, in Prakrit such forms are not categorised by their functions but are rather assigned to the instrumental plural or genitive according to their forms.
Other Exported Functions
The following Lua functions are also exported by this module:
select
joinSuffix
show
Function endings, stem = select(dialect, word, g, etc)
The primary purpose is to return the endings for the word and gender (g
, they are returned in return value endings
. The argument etc
is a table which contains the script object in field sc
and should contain arguments other than the word and its gender. The function may append other items and preprocessed data. This table should be passed to subsequent invocations of joinSuffix
.
The word word
is transliterated to the Roman script as function value stem
. Special treatment is applied if it contains a trailing combining diaeresis.
This function is also used by Module:pra-decl/noun/testcases.
Function joinSuffix(frame, stem, suffixes, etc)
This function returns the contents of a cell of the declension table. It returns the wikicode for a cell of the declension table, with the inflected forms in the appropriate script.
The argument frame
is a frame variable. Any frame variable will suffice. The argument stem
is the Roman script stem as returned by select()
. The argument suffixes
is an array of endings, also in the Roman script.
The argument etc
is a table of arguments affecting the combination of stem and suffixes. In particular, it shall contains the field sc
as the script object for the script the inflected forms are to be displayed in. This argument should normally be as modified by function select()
.
This function is also used by Module:pra-decl/noun/testcases.
Function show(frame, dialect)
This function coordinates the preparation of a table. It can only be called from Lua code. It should probably not be exported.
Exported variables
The variable orJoin
is the string used to join forms listed in a cell of the declension table. It should be treated as a constant.
The variable is also used by Module:pra-decl/noun/testcases.
local export = {}
local m_links = require("Module:links")
local m_str_utils = require("Module:string utilities")
local sub = m_str_utils.sub
local gsub = m_str_utils.gsub
local match = m_str_utils.match
local u = m_str_utils.char
local PAGENAME = mw.loadData("Module:headword/data").pagename
local lang = require("Module:languages").getByCode("pra")
local genders = {
["m"] = "masculine", ["f"] = "feminine", ["n"] = "neuter",
}
export.orjoiner = " <small style=\"color:888\">or</small> " -- Share for testing
local cases = {
"Nominative", "Accusative", "Instrumental", "Dative", "Ablative",
"Genitive", "Locative", "Vocative"
}
local diaeresis = {i = "ï", u = "ü"}
function ending(tr)
return sub(tr, -1, -1)
end
function export.joinSuffix(frame, stem, suffixes, etc)
local output = ""
local term
local function to_Brah(tr)
local is = require("Module:typing-aids").interpret_shortcuts
return is(tr, "pra")
end
local function to_Deva(tr)
local is = require("Module:typing-aids").interpret_shortcuts
return is(tr, "sa")
end
local function to_Knda(tr)
local is = require("Module:typing-aids").interpret_shortcuts
return is(tr, "pra-Knda")
end
local function asis(tr) return tr end
local sc = etc and etc.sc or error("Script not provided.")
local converter = etc and etc.converter
if not converter then
converters = {Brah = to_Brah, Deva = to_Deva, Knda = to_Knda}
converter = converters[sc:getCode()] or asis
if etc then etc.converter = converter end
end
for _,suffix in ipairs(suffixes) do
if match(suffix, "^⌫⌫") then --backspace
term = sub(stem, 1, -3) .. "Ⓙ" .. sub(suffix, 3, -1)
elseif match(suffix, "^⌫") then --backspace
term = sub(stem, 1, -2) .. "Ⓙ" .. sub(suffix, 2, -1)
else
term = stem .. "Ⓙ" .. suffix
end
-- May need a diaeresis at the join.
term = gsub(term, "aⒿⒿ?([iu])", function(x) return "a" .. diaeresis[x] end)
term = gsub(term, "Ⓙ", "")
if output ~= "" then
output = output .. export.orjoiner
end
output = output .. m_links.full_link({
lang = lang,
sc = sc,
term = converter(term)})
end
if output == "" then
output = "—"
end
return output
end
function export.select(dialect, word, g, etc)
-- This is a function rather than inline so as to facilitate testing.
-- sc is not yet used, but will be in later forms, and will be script object.
local dn = "Module:pra-decl/noun/" .. dialect
local data = mw.loadData(dn) or error("Could not load data module "..dn)
if not etc then error("Argument etc not provided.") end
if not etc.sc then
error("Argument etc lacks field sc")
-- else error("Argument etc provides script "..etc.sc:getCode())
end
toler_other = false
local word_tr = (lang:transliterate(word, etc.sc)) or toler_other and word
if not word_tr then
if etc.sc:getCode() == "None" then
error(word.." is not in a script registered for Prakrit.")
else
error("Unknown transliteration error for "..word)
end
end
-- Special handling for explicit combining diaeresis.
if sub(word_tr, -1, -1) == u(0x0308) then
stem = sub(word_tr, 1, -3) .. "Ⓙ" .. sub(word_tr, -2, -2)
else
stem = word_tr
end
local the_ending = ending(stem)
return data[the_ending] and data[the_ending][g], stem
end
function export.show(frame, dialect)
local args = frame:getParent().args
local g = args[1]
local word = args[2] or PAGENAME
if PAGENAME == "pra-mah-decl-noun" or PAGENAME == "pra-sau-decl-noun" or PAGENAME == "pra-ard-decl-noun" or PAGENAME == "pra-mag-decl-noun" then
g = "m"
word = "𑀧𑀼𑀢𑁆𑀢"
end
local sc = lang:findBestScript(word)
local etc = {sc = sc}
local m_lang = require("Module:languages").getByCode(dialect, true, "allow etym")
-- 4th argument is to be supplied when it comes to be used.
local selected_data, word_tr = export.select(dialect, word, g, etc)
local output = {nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}
local output_i = 0
local function insert(s)
output_i = output_i + 1
output[output_i] = s
end
insert([=[
{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="background:#FEFEFE; text-align:center; border: 1px solid #CCC;"
|- style="background: #d9ebff;"
! class="vsToggleElement" style="text-align: left;" colspan="3" |]=])
insert(sub(m_lang:getCanonicalName(), 1, -9))
insert [=[ declension of ]=]
insert(word)
insert(" (" .. genders[g] .. ")")
insert [=[
|- class="vsHide"
! style="background:#eff7ff" |
! style="background:#eff7ff" | singular
! style="background:#eff7ff" | plural
]=]
for i,v in ipairs(cases) do
insert("\n|- class=\"vsHide\"\n! style=\"background-color:#eff7ff;\" | ")
insert(v)
insert("\n| ")
insert(export.joinSuffix(frame, word_tr, selected_data[2 * i - 1], etc))
insert("\n| ")
insert(export.joinSuffix(frame, word_tr, selected_data[2 * i], etc))
end
insert "\n|}"
return table.concat(output)
end
function export.pra_mah(frame)
return export.show(frame, "pra-mah")
end
function export.pra_sau(frame)
return export.show(frame, "pra-sau")
end
function export.pra_ard(frame)
return export.show(frame, "pra-ard")
end
function export.pra_mag(frame)
return export.show(frame, "pra-mag")
end
return export