মডিউল:বাংলা আভিধানিক উপাত্ত
অবয়ব
এই মডিউলটি বর্তমানে পরীক্ষামূলক পর্যায়ে রয়েছে।
ব্যবহার
[সম্পাদনা]{{#invoke:বাংলা আভিধানিক উপাত্ত|all| লেক্সিম নং }}
উদা:
{{#invoke:বাংলা আভিধানিক উপাত্ত|all|L301993}}
এই মডিউলের একটি সরাসরি ব্যবহার দেখতে, হৃদয় পাতাটি দেখুন।
local p = {}
local converter = require('মডিউল:ConvertDigit')
-- Return the first form of the lexeme which has exactly the given grammatical feature.
local function formWithSingleGrammaticalFeature( lexeme, item_id )
for i, form in pairs( lexeme:getForms() ) do
local grammaticalFeatures = form:getGrammaticalFeatures()
if #grammaticalFeatures == 1 and grammaticalFeatures[1] == item_id then
return form
end
end
return nil
end
-- Return the representation of the form in the given language code,
-- or the first representation otherwise.
local function representationInLanguage( form, language_code )
for i, representation in pairs( form:getRepresentations() ) do
if representation[2] == language_code then
return representation
end
end
return form:getRepresentations()[1]
end
local function termSpan( term )
local text = term[1]
local lang = term[2]
local dir = mw.language.new( lang ):getDir()
local span = mw.html.create( 'span' )
span:attr( 'lang', lang )
:attr( 'dir', dir )
:wikitext( text )
return tostring( span )
end
function singularPlural( lexeme_id, item_id )
local lexeme = mw.wikibase.getEntity( lexeme_id )
local form = formWithSingleGrammaticalFeature( lexeme, item_id )
if form == nil then
return "''no such form''"
end
local representation = representationInLanguage( form, 'en' )
return termSpan( representation )
end
function getLemmata( current_lexeme )
lemma_string = ''
for i, rep in pairs(current_lexeme:getLemmas()) do
lemma_string = lemma_string .. termSpan(rep)
end
return lemma_string
end
function getExamples( current_lexeme, sense_id )
examples = mw.html.create('dl')
for i, stmt in pairs(current_lexeme:getAllStatements('P5831')) do -- ব্যবহারের উদাহরণ
if stmt.qualifiers['P6072'][1].datavalue.value.id == sense_id then -- subject sense
example_text = stmt.mainsnak.datavalue.value.text
example_lang = stmt.mainsnak.datavalue.value.language
example_form = mw.wikibase.getEntity(stmt.qualifiers['P5830'][1].datavalue.value.id) -- subject form
example_form_str = example_form:getRepresentation('bn')
example_text = mw.ustring.gsub(example_text, example_form_str, "'''" .. example_form_str .. "'''")
example_str = termSpan({example_text, example_lang})
example_from_id = stmt.references[1].snaks['P248'][1].datavalue.value.id -- এই উৎসে বিবৃত
example_from_text = mw.wikibase.getLabelByLang( example_from_id, 'bn' )
example_from_author = mw.wikibase.getEntity(example_from_id):getBestStatements('P50')[1].mainsnak.datavalue.value.id -- লেখক
example_from_author_text = mw.wikibase.getLabelByLang( example_from_author, 'bn' )
example_from_author_link = mw.wikibase.getSitelink( example_from_author, 'bnwikisource' )
example_from_publishedin_out = ''
if #mw.wikibase.getEntity(example_from_id):getBestStatements('P1433') ~= 0 then
example_from_publishedin = mw.wikibase.getEntity(example_from_id):getBestStatements('P1433')[1].mainsnak.datavalue.value.id -- এতে প্রকাশিত
example_from_publishedin_text = mw.wikibase.getLabelByLang( example_from_publishedin, 'bn' )
example_from_publishedin_link = mw.wikibase.getSitelink( example_from_publishedin, 'bnwikisource' )
example_from_publishedin_out = " ([[:s:" .. example_from_publishedin_link .. '|' .. example_from_publishedin_text .. ']] নামক রচনায় প্রকাশিত)'
end
example_from_link = mw.wikibase.getSitelink( example_from_id, 'bnwikisource' )
if stmt.references[1].snaks['P7421'] ~= nil then
example_from_lines = stmt.references[1].snaks['P7421'][1].datavalue.value -- পংক্তি(গুলো)
example_from_lines = converter._main(example_from_lines) .. " নং পংক্তি"
elseif stmt.references[1].snaks['P958'] ~= nil then
example_from_lines = stmt.references[1].snaks['P958'][1].datavalue.value -- অনুচ্ছেদ, চরণ, বা অধ্যায়
example_from_lines = '"' .. example_from_lines .. '" নামক অনুচ্ছেদ'
elseif stmt.references[1].snaks['P792'] ~= nil then
example_from_lines = stmt.references[1].snaks['P792'][1].datavalue.value -- পরিচ্ছেদ
example_from_lines = converter._main(example_from_lines) .. " নং পরিচ্ছেদ"
elseif stmt.references[1].snaks['P304'] ~= nil then
example_from_lines = stmt.references[1].snaks['P304'][1].datavalue.value -- পাতা
example_from_lines = converter._main(example_from_lines) .. " নং পাতায়"
end
inside_text = "—[[:s:" .. example_from_author_link .. '|' .. example_from_author_text .. "]]"
inside_text = inside_text .. ', [[File:Wikisource-logo.svg|16px|link=s:]] [[:s:' .. example_from_link .. '|' .. example_from_text .. ']]'
inside_text = inside_text .. example_from_publishedin_out
inside_text = inside_text .. ", " .. example_from_lines
examples:tag('dd'):wikitext("''" .. example_str .. "''"):done():tag('dd'):css('text-indent', '2em'):wikitext(inside_text)
end
end
return tostring(examples)
end
function getCategory ( current_lexeme )
cat_id = current_lexeme:getLexicalCategory()
cat_text = mw.wikibase.getLabelByLang( cat_id, 'bn' )
if cat_id == 'Q1084' then -- বিশেষ্য
cat_text = cat_text .. '[[বিষয়শ্রেণী:বাংলা বিশেষ্য]]'
elseif cat_id == 'Q34698' then -- বিশেষণ
cat_text = cat_text .. '[[বিষয়শ্রেণী:বাংলা বিশেষণ]]'
elseif cat_id == 'Q24905' then -- ক্রিয়াপদ
cat_text = cat_text .. '[[বিষয়শ্রেণী:বাংলা ক্রিয়া]]'
end
return cat_text
end
function getMeanings ( current_lexeme )
meanings = mw.html.create( 'ol' )
for i, sense in pairs(current_lexeme:getSenses()) do
gloss_text = ''
glosses = sense:getGlosses()
for j, gloss in pairs(glosses) do
if gloss[2] == 'bn' then
gloss_text = gloss[1]
end
end
examples = getExamples ( current_lexeme, sense:getId() )
meanings:tag('li'):wikitext(gloss_text):wikitext(examples)
end
return meanings
end
local item_mappings = {
["Q1350145"] = "vn_nom",
["Q21714344_Q3910936"] = "pres_simp_1",
["Q3910936_Q56650487"] = "pres_simp_2s",
["Q3910936_Q56650485"] = "pres_simp_2t",
["Q3910936_Q51929074"] = "pres_simp_3",
["Q3910936_Q56650512"] = "pres_simp_hon",
["Q21714344_Q7240943_Q75242466"] = "pres_prog_1_chalit",
["Q20613396_Q21714344_Q7240943"] = "pres_prog_1_sadhu",
["Q56650487_Q7240943_Q75242466"] = "pres_prog_2s_chalit",
["Q20613396_Q56650487_Q7240943"] = "pres_prog_2s_sadhu",
["Q56650485_Q7240943_Q75242466"] = "pres_prog_2t_chalit",
["Q20613396_Q56650485_Q7240943"] = "pres_prog_2t_sadhu",
["Q51929074_Q7240943_Q75242466"] = "pres_prog_3_chalit",
["Q20613396_Q51929074_Q7240943"] = "pres_prog_3_sadhu",
["Q56650512_Q7240943_Q75242466"] = "pres_prog_hon_chalit",
["Q20613396_Q56650512_Q7240943"] = "pres_prog_hon_sadhu",
["Q1240211_Q21714344_Q75242466"] = "pres_perf_1_chalit",
["Q1240211_Q20613396_Q21714344"] = "pres_perf_1_sadhu",
["Q1240211_Q56650487_Q75242466"] = "pres_perf_2s_chalit",
["Q1240211_Q20613396_Q56650487"] = "pres_perf_2s_sadhu",
["Q1240211_Q56650485_Q75242466"] = "pres_perf_2t_chalit",
["Q1240211_Q20613396_Q56650485"] = "pres_perf_2t_sadhu",
["Q1240211_Q51929074_Q75242466"] = "pres_perf_3_chalit",
["Q1240211_Q20613396_Q51929074"] = "pres_perf_3_sadhu",
["Q1240211_Q56650512_Q75242466"] = "pres_perf_hon_chalit",
["Q1240211_Q20613396_Q56650512"] = "pres_perf_hon_sadhu",
["Q52434162_Q56650487"] = "pres_imp_2s",
["Q52434162_Q56650485"] = "pres_imp_2t",
["Q51929074_Q52434162_Q75242466"] = "pres_imp_3_chalit",
["Q20613396_Q51929074_Q52434162"] = "pres_imp_3_sadhu",
["Q52434162_Q56650512_Q75242466"] = "pres_imp_hon_chalit",
["Q20613396_Q52434162_Q56650512"] = "pres_imp_hon_sadhu",
["Q1392475_Q21714344_Q75242466"] = "past_simp_1_chalit",
["Q1392475_Q20613396_Q21714344"] = "past_simp_1_sadhu",
["Q1392475_Q56650487_Q75242466"] = "past_simp_2s_chalit",
["Q1392475_Q20613396_Q56650487"] = "past_simp_2s_sadhu",
["Q1392475_Q56650485_Q75242466"] = "past_simp_2t_chalit",
["Q1392475_Q20613396_Q56650485"] = "past_simp_2t_sadhu",
["Q1392475_Q51929074_Q75242466"] = "past_simp_3_chalit",
["Q1392475_Q20613396_Q51929074"] = "past_simp_3_sadhu",
["Q1392475_Q56650512_Q75242466"] = "past_simp_hon_chalit",
["Q1392475_Q20613396_Q56650512"] = "past_simp_hon_sadhu",
["Q21714344_Q56650537_Q75242466"] = "past_prog_1_chalit",
["Q20613396_Q21714344_Q56650537"] = "past_prog_1_sadhu",
["Q56650487_Q56650537_Q75242466"] = "past_prog_2s_chalit",
["Q20613396_Q56650487_Q56650537"] = "past_prog_2s_sadhu",
["Q56650485_Q56650537_Q75242466"] = "past_prog_2t_chalit",
["Q20613396_Q56650485_Q56650537"] = "past_prog_2t_sadhu",
["Q51929074_Q56650537_Q75242466"] = "past_prog_3_chalit",
["Q20613396_Q51929074_Q56650537"] = "past_prog_3_sadhu",
["Q56650512_Q56650537_Q75242466"] = "past_prog_hon_chalit",
["Q20613396_Q56650512_Q56650537"] = "past_prog_hon_sadhu",
["Q21714344_Q623742_Q75242466"] = "past_perf_1_chalit",
["Q20613396_Q21714344_Q623742"] = "past_perf_1_sadhu",
["Q56650487_Q623742_Q75242466"] = "past_perf_2s_chalit",
["Q20613396_Q56650487_Q623742"] = "past_perf_2s_sadhu",
["Q56650485_Q623742_Q75242466"] = "past_perf_2t_chalit",
["Q20613396_Q56650485_Q623742"] = "past_perf_2t_sadhu",
["Q51929074_Q623742_Q75242466"] = "past_perf_3_chalit",
["Q20613396_Q51929074_Q623742"] = "past_perf_3_sadhu",
["Q56650512_Q623742_Q75242466"] = "past_perf_hon_chalit",
["Q20613396_Q56650512_Q623742"] = "past_perf_hon_sadhu",
["Q21714344_Q75242466_Q75243920"] = "hab_1_chalit",
["Q20613396_Q21714344_Q75243920"] = "hab_1_sadhu",
["Q56650487_Q75242466_Q75243920"] = "hab_2s_chalit",
["Q20613396_Q56650487_Q75243920"] = "hab_2s_sadhu",
["Q56650485_Q75242466_Q75243920"] = "hab_2t_chalit",
["Q20613396_Q56650485_Q75243920"] = "hab_2t_sadhu",
["Q51929074_Q75242466_Q75243920"] = "hab_3_chalit",
["Q20613396_Q51929074_Q75243920"] = "hab_3_sadhu",
["Q56650512_Q75242466_Q75243920"] = "hab_hon_chalit",
["Q20613396_Q56650512_Q75243920"] = "hab_hon_sadhu",
["Q21714344_Q75242466_Q96323395"] = "fut_simp_1_chalit",
["Q20613396_Q21714344_Q96323395"] = "fut_simp_1_sadhu",
["Q56650487_Q75242466_Q96323395"] = "fut_simp_2s_chalit",
["Q20613396_Q56650487_Q96323395"] = "fut_simp_2s_sadhu",
["Q56650485_Q75242466_Q96323395"] = "fut_simp_2t_chalit",
["Q20613396_Q56650485_Q96323395"] = "fut_simp_2t_sadhu",
["Q51929074_Q75242466_Q96323395"] = "fut_simp_3_chalit",
["Q20613396_Q51929074_Q96323395"] = "fut_simp_3_sadhu",
["Q56650512_Q75242466_Q96323395"] = "fut_simp_hon_chalit",
["Q20613396_Q56650512_Q96323395"] = "fut_simp_hon_sadhu",
["Q56650487_Q75242466_Q75244800"] = "fut_imp_2s_chalit",
["Q20613396_Q56650487_Q75244800"] = "fut_imp_2s_sadhu",
["Q56650485_Q75242466_Q75244800"] = "fut_imp_2t_chalit",
["Q20613396_Q56650485_Q75244800"] = "fut_imp_2t_sadhu",
["Q51929074_Q75242466_Q75244800"] = "fut_imp_3_chalit",
["Q20613396_Q51929074_Q75244800"] = "fut_imp_3_sadhu",
["Q56650512_Q75242466_Q75244800"] = "fut_imp_hon_chalit",
["Q20613396_Q56650512_Q75244800"] = "fut_imp_hon_sadhu",
["Q1050494_Q1423674_Q75242466"] = "prog_chalit",
["Q1050494_Q1423674_Q20613396"] = "prog_sadhu",
["Q1050494_Q1424306_Q75242466"] = "perf_chalit",
["Q1050494_Q1424306_Q20613396"] = "perf_sadhu",
["Q1050494_Q625581_Q75242466"] = "cond_chalit",
["Q1050494_Q20613396_Q625581"] = "cond_sadhu",
["Q1350145_Q146233_Q75242466"] = "vn_gen_chalit",
["Q1350145_Q146233_Q20613396"] = "vn_gen_sadhu"
}
function conj_table_arguments ( current_lexeme )
local forms = {}
for i, form in pairs(current_lexeme:getForms()) do
local reps = form:getRepresentations()
local feats = form:getGrammaticalFeatures()
table.sort(form:getGrammaticalFeatures())
local feats_cat = table.concat(feats,'_')
local table_arg = item_mappings[feats_cat]
if forms[table_arg] ~= nil then
forms[table_arg] = forms[table_arg] .. '/' .. reps[1][1]
else
forms[table_arg] = reps[1][1]
end
end
return forms
end
function getConjTable ( frame , current_lexeme )
return frame:expandTemplate{
title= 'bn-ধাতুরূপ/ছক',
args = conj_table_arguments ( current_lexeme )
}
end
item_mappings_decl = {
["Q131105"] = 'nom',
["Q146233"] = 'gen',
["Q146078"] = 'acc',
["Q202142"] = 'loc',
["Q145599"] = 'dat'
}
function decl_table_arguments ( current_lexeme )
local forms = {}
for i, form in pairs(current_lexeme:getForms()) do
local reps = form:getRepresentations()
local feats = form:getGrammaticalFeatures()[1]
local table_arg = item_mappings_decl[feats]
if forms[table_arg] ~= nil then
forms[table_arg] = forms[table_arg] .. '/' .. reps[1][1]
else
forms[table_arg] = reps[1][1]
end
end
return forms
end
function getDeclTable ( frame , current_lexeme )
return frame:expandTemplate{
title= 'bn-শব্দরূপ/ছক',
args = decl_table_arguments ( current_lexeme )
}
end
function p.all( frame )
lexeme_id = frame.args[1]
current_lexeme = mw.wikibase.getEntity(lexeme_id)
cat_text = '===' .. getCategory ( current_lexeme ) .. '==='
lemmata = getLemmata ( current_lexeme )
meanings = getMeanings ( current_lexeme )
cat_id = current_lexeme:getLexicalCategory()
if cat_id == 'Q24905' then
conjTable = getConjTable ( frame, current_lexeme )
elseif cat_id == 'Q1084' then
conjTable = getDeclTable ( frame, current_lexeme )
else
conjTable = ''
end
return cat_text .. '\n\n' .. tostring(meanings) .. '\n\n' .. conjTable
end
return p