Ignore first/last name errors with non-human authors
This commit is contained in:
parent
3ed3baa833
commit
d2e75d6e21
1 changed files with 22 additions and 8 deletions
|
|
@ -129,6 +129,7 @@ local function makelink(v, out, maxpos, wdl, namestyle)
|
||||||
if v.mainsnak.snaktype == "value" then
|
if v.mainsnak.snaktype == "value" then
|
||||||
if v.mainsnak.datatype == "wikibase-item" then
|
if v.mainsnak.datatype == "wikibase-item" then
|
||||||
local qnumber = v.mainsnak.datavalue.value.id
|
local qnumber = v.mainsnak.datavalue.value.id
|
||||||
|
local human_instance = false
|
||||||
local sitelink = mw.wikibase.getSitelink(qnumber)
|
local sitelink = mw.wikibase.getSitelink(qnumber)
|
||||||
if qnumber == "Q2818964" then sitelink = nil end -- suppress link to "Various authors"
|
if qnumber == "Q2818964" then sitelink = nil end -- suppress link to "Various authors"
|
||||||
|
|
||||||
|
|
@ -172,7 +173,18 @@ local function makelink(v, out, maxpos, wdl, namestyle)
|
||||||
if item_lookup and position <= max_authors_displayed then
|
if item_lookup and position <= max_authors_displayed then
|
||||||
last_name = last_name or getValue({"P734", qid=qnumber, maxvals=1, ps=2})
|
last_name = last_name or getValue({"P734", qid=qnumber, maxvals=1, ps=2})
|
||||||
first_names = first_names or getValue({"P735", qid=qnumber, maxvals=0, ps=2})
|
first_names = first_names or getValue({"P735", qid=qnumber, maxvals=0, ps=2})
|
||||||
|
|
||||||
|
-- check if P31 "instance of" Q5 "human"
|
||||||
|
local instance_of = mw.wikibase.getBestStatements(qnumber, 'P31')
|
||||||
|
if instance_of and instance_of[1] then
|
||||||
|
for k, vi in pairs(instance_of) do
|
||||||
|
if vi.mainsnak.snaktype == "value" and vi.mainsnak.datatype == "wikibase-item" and vi.mainsnak.datavalue.value.id == 'Q5' then
|
||||||
|
human_instance = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if first_names then
|
if first_names then
|
||||||
first_names = getStyledNames(first_names, namestyle)
|
first_names = getStyledNames(first_names, namestyle)
|
||||||
end
|
end
|
||||||
|
|
@ -192,6 +204,7 @@ local function makelink(v, out, maxpos, wdl, namestyle)
|
||||||
first = first_names or nil,
|
first = first_names or nil,
|
||||||
link = sitelink or nil,
|
link = sitelink or nil,
|
||||||
qid = qnumber,
|
qid = qnumber,
|
||||||
|
human = human_instance,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
elseif v.mainsnak.datatype == "string" then
|
elseif v.mainsnak.datatype == "string" then
|
||||||
|
|
@ -342,6 +355,7 @@ local function get_name_list (nl_type, args, qid, wdl)
|
||||||
label = label:gsub(''', '\''); -- prevent cs1|2 multiple names categorization; replace html entity with the actual character
|
label = label:gsub(''', '\''); -- prevent cs1|2 multiple names categorization; replace html entity with the actual character
|
||||||
names[i].label = label
|
names[i].label = label
|
||||||
names[i].qid = out[k].qid or nil
|
names[i].qid = out[k].qid or nil
|
||||||
|
names[i].human = out[k].human or nil
|
||||||
mw.log(i .. " " .. k .. " " .. label)
|
mw.log(i .. " " .. k .. " " .. label)
|
||||||
if args[nl_type .. i] then -- name gets overwritten
|
if args[nl_type .. i] then -- name gets overwritten
|
||||||
-- pull corresponding -link only if overwritten name is same as WD name
|
-- pull corresponding -link only if overwritten name is same as WD name
|
||||||
|
|
@ -835,10 +849,10 @@ local function _cite_q (citeq_args)
|
||||||
local missing_names = {}
|
local missing_names = {}
|
||||||
for i, author in pairs(names.authors or {}) do
|
for i, author in pairs(names.authors or {}) do
|
||||||
-- mw.logObject(author)
|
-- mw.logObject(author)
|
||||||
if not author.last and i <= (tonumber (citeq_args['display-authors']) or tonumber (author_count)) then
|
if not author.last and i <= (tonumber(citeq_args['display-authors']) or author_count) then
|
||||||
if author.qid then
|
if author.qid then
|
||||||
-- ignore anonymous
|
-- ignore anonymous or non-humans
|
||||||
if author.qid ~= 'Q4233718' then
|
if author.human then
|
||||||
table.insert(missing_names, author.label .. " <span title='edit author in Wikidata'>[[File:Edit icon on Wikisite.svg|14px|alt=|link=[[:d:" .. author.qid .. "]] ]]</span>")
|
table.insert(missing_names, author.label .. " <span title='edit author in Wikidata'>[[File:Edit icon on Wikisite.svg|14px|alt=|link=[[:d:" .. author.qid .. "]] ]]</span>")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
@ -847,10 +861,10 @@ local function _cite_q (citeq_args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i, editor in pairs(names.editors or {}) do
|
for i, editor in pairs(names.editors or {}) do
|
||||||
if not editor.last and i <= (tonumber (citeq_args['display-editors']) or tonumber (editor_count)) then
|
if not editor.last and i <= (tonumber(citeq_args['display-editors']) or editor_count) then
|
||||||
if editor.qid then
|
if editor.qid then
|
||||||
-- ignore anonymous
|
-- ignore anonymous or non-humans
|
||||||
if editor.qid ~= 'Q4233718' then
|
if editor.human then
|
||||||
table.insert(missing_names, editor.label .. " <span title='edit editor in Wikidata'>[[File:Edit icon on Wikisite.svg|14px|alt=|link=[[:d:" .. editor.qid .. "]] ]]</span>")
|
table.insert(missing_names, editor.label .. " <span title='edit editor in Wikidata'>[[File:Edit icon on Wikisite.svg|14px|alt=|link=[[:d:" .. editor.qid .. "]] ]]</span>")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
@ -861,8 +875,8 @@ local function _cite_q (citeq_args)
|
||||||
for i, translator in pairs(names.translators or {}) do
|
for i, translator in pairs(names.translators or {}) do
|
||||||
if not translator.last then
|
if not translator.last then
|
||||||
if translator.qid then
|
if translator.qid then
|
||||||
-- ignore anonymous
|
-- ignore anonymous or non-humans
|
||||||
if translator.qid ~= 'Q4233718' then
|
if translator.human then
|
||||||
table.insert(missing_names, translator.label .. " <span title='edit translator in Wikidata'>[[File:Edit icon on Wikisite.svg|14px|alt=|link=[[:d:" .. translator.qid .. "]] ]]</span>")
|
table.insert(missing_names, translator.label .. " <span title='edit translator in Wikidata'>[[File:Edit icon on Wikisite.svg|14px|alt=|link=[[:d:" .. translator.qid .. "]] ]]</span>")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue