Módulo:BibRules: mudanças entre as edições

Conteúdo deletado Conteúdo adicionado
Sem resumo de edição
Sem resumo de edição
 
(58 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1:
local p = {}
 
function p.BibRulesRules(frame)
-- Define o alvo das regras
local target = frame:getParent().args[1] or frame.args[1]
if target == ''"" or target == nil then
target = mw.uri.decode(frame:callParserFunction('"#urlget'", '"fullpagename'"))
end
if target == ''"" or target == nil then
target = mw.title.getCurrentTitle().prefixedText
end
-- Semantic Scribunto foi carregado?
if not mw.smw then
return '"mw.smw module not found'"
end
-- Define variáveis básicas
local test, info, queryResult, a, b
local infos = {}
-- Funções básicas
local function ucfirst(str)
return (str:gsub('"^%l'", string.upper))
end
-- Somente realizerealiza as análises dese existir o campo 245
local f245 =
if frame:expandTemplate {title = 'Exist', args = {'245', target}} ~= '' then
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "245", "0", "0", fullpagename = target } }) or
""
if f245 ~= "" then
-- Categorias
local categories =
frame:callParserFunction {
name = "#ask:[[" .. target .. "]]",
args = {
"?Category",
format = "plainlist",
link = "none",
headers = "hide",
mainlabel = "-",
outro = "",
sep = "",
valuesep = "",
propsep = "",
prefix = "none"
}
} or ""
-- Record status
local recordStatus =
test = frame:expandTemplate {title = 'Field data string', args = {'000', '5', '1', property = 'Leader', fullpagename = target}} or false
frame:expandTemplate {
if test == 'n' then
title = "Field data string",
a = 'Segundo o Líder, este é um registro <b>novo</b> (não um alterado ou revisado, expandido, excluído, etc.)'
args = { "000", "5", "1", property = "Leader", fullpagename = target }
info = string.format( '* %s.' , a )
} or false
if recordStatus == "n" then
a = "Segundo o Líder, este é um registro <b>novo</b> (não um alterado ou revisado, expandido, excluído, etc.)"
info = string.format("* %s.", a)
table.insert(infos, info)
elseif testrecordStatus == '"c'" then
a = '"Segundo o Líder, este é um registro <b>alterado ou revisado</b> (não um novo, expandido, excluído, etc.)'"
info = string.format( '"* %s.'", a )
table.insert(infos, info)
elseif testrecordStatus == '"a'" or testrecordStatus == '"d'" or testrecordStatus == '"p'" then
a = '"Segundo o Líder, este é um registro <b>expandido</b> ou <b>excluído</b> (não novo)'"
info = string.format( '"* %s.'", a )
table.insert(infos, info)
end
-- Type of record
local typeOfRecord =
test = frame:expandTemplate {title = 'Field data string', args = {'000', '6', '1', property = 'Leader', fullpagename = target}} or false
frame:expandTemplate {
if test == 'a' then
title = "Field data string",
a = 'Segundo o Líder, este registro descreve um <b>material textual</b>'
args = { "000", "6", "1", property = "Leader", fullpagename = target }
info = string.format( '* %s.', a )
} or false
if typeOfRecord == "a" then
a = "Segundo o Líder, este registro descreve um <b>material textual</b>"
info = string.format("* %s.", a)
table.insert(infos, info)
end
-- Bibliographic level
local bibliographicLevel =
test = frame:expandTemplate {title = 'Field data string', args = {'000', '7', '1', property = 'Leader', fullpagename = target}} or false
frame:expandTemplate {
if test == 'm' then
title = "Field data string",
a = 'Segundo o Líder, este registro descreve um <b>item monográfico</b> (não parte de um item, não um item seriado, não uma coleção, etc.)'
args = { "000", "7", "1", property = "Leader", fullpagename = target }
info = string.format( '* %s.', a )
} or false
if bibliographicLevel == "m" then
a =
"Segundo o Líder, este registro descreve um <b>item monográfico</b> (não parte de um item, não um item seriado, não uma coleção, etc.)"
info = string.format("* %s.", a)
table.insert(infos, info)
end
-- Encoding level
local encodingLevel =
test = frame:expandTemplate {title = 'Field data string', args = {'000', '17', '1', property = 'Leader', fullpagename = target}} or false
frame:expandTemplate {
if test == '1' then
title = "Field data string",
a = 'Segundo o Líder, este registro tem um nível <b>completo</b> de catalogação (mas o material não foi examinado)'
args = { "000", "17", "1", property = "Leader", fullpagename = target }
info = string.format( '* %s.', a )
} or false
if encodingLevel == "1" then
a =
"Segundo o Líder, este registro tem um nível <b>completo</b> de catalogação (mas o material não foi examinado)"
info = string.format("* %s.", a)
table.insert(infos, info)
elseif testencodingLevel == '"#'" then
a =
a = 'Segundo o Líder, este registro tem um nível <b>completo</b> de catalogação (a descrição foi realizada com o material em mãos)'
"Segundo o Líder, este registro tem um nível <b>completo</b> de catalogação (a descrição foi realizada com o material em mãos)"
info = string.format( '* %s.', a )
info = string.format("* %s.", a)
table.insert(infos, info)
end
-- Descriptive cataloging form
local descriptiveCatalogingForm =
test = frame:expandTemplate {title = 'Field data string', args = {'000', '18', '1', property = 'Leader', fullpagename = target}} or false
frame:expandTemplate {
if test == 'a' then
title = "Field data string",
a = 'Segundo o Líder, este registro possui uma catalogação <b>compatível com as regras do AACR 2</b>'
args = { "000", "18", "1", property = "Leader", fullpagename = target }
info = string.format( '* %s.', a )
} or false
if descriptiveCatalogingForm == "a" then
a = "Segundo o Líder, este registro possui uma catalogação <b>compatível com as regras do AACR 2</b>"
info = string.format("* %s.", a)
table.insert(infos, info)
else
a = '"Segundo o Líder, este registro possui uma catalogação <b>não compatível com as regras da ISBD</b>'"
info = string.format( '"* %s.'", a )
table.insert(infos, info)
end
-- Explica a sintaxe '(Biblioteca)NúmeroDeControle'
local f001 =
local f001 = frame:expandTemplate {title = 'Field data string', args = {'001', '0', '', property = 'Control field data', fullpagename = target}}
local f003 = frame:expandTemplate {
title = '"Field data string'",
args = {'003' "001", '"0'", ''"", property = '"Control field data'", fullpagename = target }
} or }""
local f003 =
a = 'Internamente, este registro é identificado pelo código'
frame:expandTemplate {
b = 'para sistemas externos, o código é'
title = "Field data string",
info = string.format( '* %s "%s"; %s "(%s)%s".', a, f001, b, f003, f001 )
args = { "003", "0", "", property = "Control field data", fullpagename = target }
} or ""
a = "Internamente, este registro é identificado pelo código"
b = "para sistemas externos, o código é"
info = string.format('* %s "%s"; %s "(%s)%s".', a, f001, b, f003, f001)
table.insert(infos, info)
-- Campo 005
local creationDate =
queryResult = mw.smw.ask('[[' .. target .. ']]|?Creation date#-F[l, d \\d\\e F \\d\\e Y]|headers=hide|mainlabel=-')
mw.smw.ask("[[" .. target .. "]]|?Creation date#-F[l, d \\d\\e F \\d\\e Y]|headers=hide|mainlabel=-") or ""
local creationDate = ''
if type(queryResultcreationDate) == '"table'" then
for _, row in pairs(queryResultcreationDate) do
for _, data in pairs(row) do
creationDate = data
Linha 94 ⟶ 142:
end
end
queryResultlocal modificationDate =
mw.smw.ask('"[['" .. target .. '"]]|?Modification date#-F[l, d \\d\\e F \\d\\e Y]|headers=hide|mainlabel=-'") or ""
localif type(modificationDate) == "table" ''then
for _, row in pairs(modificationDate) do
if type(queryResult) == 'table' then
for _, row in pairs(queryResult) do
for _, data in pairs(row) do
modificationDate = data
Linha 104 ⟶ 151:
end
end
a = '"O registro foi criado em:'"
b = '"Sua última transação foi em:'"
info = string.format( '"* %s %s. %s %s.'", a, creationDate, b, modificationDate )
table.insert(infos, info)
-- Campo 008
local invalidCode = '<strong class="error">código inválido para o local de publicação</strong>'
local pubPlace_tblpubPlaceTbl = {
['"acb'"] = '"Acre'",
['"alb'"] = '"Alagoas'",
['"amb'"] = '"Amazonas'",
['"apb'"] = '"Amapá'",
['"bab'"] = '"Bahia'",
['"ceb'"] = '"Ceará'",
['"dfb'"] = '"Distrito Federal'",
['"esb'"] = '"Espírito Santo'",
['"gob'"] = '"Goiás'",
['"mab'"] = '"Maranhão'",
['"mgb'"] = '"Minas Gerais'",
['"msb'"] = '"Mato Grosso do Sul'",
['"mtb'"] = '"Mato Grosso'",
['"pab'"] = '"Pará'",
['"pbb'"] = '"Paraíba'",
['"peb'"] = '"Pernambuco'",
['"pib'"] = '"Piauí'",
['"prb'"] = '"Paraná'",
['"rjb'"] = '"Rio de Janeiro'",
['"rnb'"] = '"Rio Grande do Norte'",
['"rob'"] = '"Rondônia'",
['"rrb'"] = '"Roraima'",
['"rsb'"] = '"Rio Grande do Sul'",
['"scb'"] = '"Santa Catarina'",
['"seb'"] = '"Sergipe'",
['"spb'"] = '"São Paulo'",
['"tob'"] = '"Tocantins'",
['"bl '"] = '"Brasil'",
['"xxu'"] = '"Estados Unidos'",
['"flu'"] = '"Flórida, EUA'",
['"nyu'"] = '"Nova York, EUA'",
['"po '"] = '"Portugal'",
['"xxk'"] = '"Reino Unido'",
['"fr '"] = '"França'",
['"sp '"] = '"Espanha'",
['"gw '"] = '"Alemanha'",
['"xx '"] = '<strong class="error">não foi identificado um local de publicação no campo 008.</strong>',
['"vp '"] = '"há vários locais de publicação'",
['"esp'"] = invalidCode,
['"eua'"] = invalidCode,
['"fra'"] = invalidCode,
["pt "] = invalidCode,
['   '] = '<strong class="error">é necessário informar um código de local de publicação, campo 008.</strong>'
["   "] = '<strong class="error">é necessário informar um código de local de publicação, campo 008.</strong>'
}
local f008pubPlace =
frame:expandTemplate {
title = '"Field data string'",
args = {' "008'", '"15'", '"3'", property = '"Control field data'", fullpagename = target } or ""
}
if string.match(f008pubPlace, '"^[A-Z]'") then
a = '"O uso de maiúsculas não é permitido no campo 008, local de publicação'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
elseif pubPlace_tblpubPlaceTbl[f008pubPlace] then
a = '"O item possui a seguinte origem:'"
info = string.format( '"* %s %s'.", a, tostring( pubPlace_tblpubPlaceTbl[f008pubPlace] ) )
table.insert(infos, info)
else
a = '"O item possui a seguinte origem:'"
info = string.format( '"* %s %s'.", a, f008pubPlace )
table.insert(infos, info)
end
invalidCode = '<strong class="error">código inválido para o idioma (campo 008 ou subcampo $h do campo 041).</strong>'
local lang_tbllangTbl = {
['"por'"] = '"português'",
['"eng'"] = '"inglês'",
['"spa'"] = '"espanhol'",
['"ger'"] = '"alemão'",
['"fre'"] = '"francês'",
['"ita'"] = '"italiano'",
['"chi'"] = '"chinês'",
['"esp'"] = invalidCode,
['"ing'"] = invalidCode,
['"fra'"] = invalidCode,
['"pt'"] = invalidCode,
['"en'"] = invalidCode,
['"es'"] = invalidCode,
['"   '"] = '<strong class="error">é necessário informar um código de idioma no campo 008.</strong>'
}
local f008lang =
frame:expandTemplate {
title = '"Field data string'",
args = {' "008'", '"35'", '"3'", property = '"Control field data'", fullpagename = target }
} or ""
if string.match(f008lang, '"^[A-Z]'") then
a = '"O uso de maiúsculas não é permitido no campo 008, idioma'"
info = string.format( '* <strong class="error">%s.</strong>', a )
elseif lang_tbllangTbl[f008lang] then
a = '"Majoritariamente, o item se expressa no seguinte idioma:'"
info = string.format( '"* %s %s'", a, tostring( lang_tbllangTbl[f008lang] ) )
else
a = '"Majoritariamente, o item se expressa no seguinte idioma:'"
info = string.format( '"* %s %s'", a, f008lang )
end
-- Se existe o campo 041, mostra '(traduzido do... )' na mesma linha do idioma presente no 008
local f041 =
local f041existance = frame:expandTemplate {title = 'Exist', args = {'041', target}} or ''
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "041", "0", "0", fullpagename = target } }) or
if f041existance ~= '' then
""
test = mw.text.trim ( frame:expandTemplate {title = 'Field data string', args = {'041', '0', '1', fullpagename = target}} )
if testf041 =~= '1'"" then
if f041:sub(1, 1) == "1" then
local f041h = frame:expandTemplate {title = 'Select', args = {'041', 'h', target}}
local f041h = frame:expandTemplate { title = "Select", args = { "041", "h", target } } or ""
f041h = lang_tbl[f041h] or f041h
infof041h = string.format(langTbl[f041h] '%s (traduzido do %s)', info,or f041h )
info = string.format("%s (traduzido do %s).", info, f041h)
end
end
table.insert(infos, info)
-- Testa se existe(m) ISBN(s) inválido(s)
local f020 =
test = frame:expandTemplate {title = 'Exist', args = {'020', target}} or false
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "020", "0", "0", fullpagename = target } }) or
if test ~= '' then
""
test = frame:expandTemplate {title = 'Print ISBN'} or false
if f020 if string.match(test,~= "error") then
local printedIsbn = frame:expandTemplate { title = "Print ISBN" } or ""
a = 'ISBN inválido, por favor, reveja os números informados'
info =if string.formatmatch(printedIsbn, '* <strong class="error">%s.</strong>',) a )then
a = "ISBN inválido, por favor, reveja os números informados"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se existe(m) hifen(s) ou x minúsculo no ISBN
queryResultlocal f020 = mw.smw.ask('"[['" .. target .. '"#020]]|?Field data#|headers=hide|mainlabel=-'") or ""
localif type(f020) == "table" ''then
for _, row in pairs(f020) do
if type(queryResult) == 'table' then
for _, row in pairs(queryResult) do
for _, data in pairs(row) do
f020if = mw.text.trim(table.concattype(data)) == "table" then
f020 = mw.text.trim(table.concat(data))
else
f020 = mw.text.trim(data)
end
end
end
end
if string.match(f020, '"-'") then
a = 'O ISBN não pode conter hifens. Apenas números e "X" maiúsculo'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
elseif string.match(f020, '"x'") then
a = 'O ISBN não pode conter um x minúsculo. Apenas números e "X" maiúsculo'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
elseif string.match(f020, "%(") then
a =
'O campo de ISBN só pode conter números e "X" maiúsculo. Use o subcampo $q para outros dados (sem parênteses)'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se há indicadores no campo 020
if string.f020:sub(f020, 1, 1) ~= '"#'" then
a = '"O primeiro indicador do campo 020 foi preenchido, porém, ele não deve ser preenchido'"
info = string.format( '* <strong class="error">.</strong>', a )
table.insert(infos, info)
end
if string.f020:sub(f020, 2, 2) ~= '"#'" then
a = '"O segundo indicador do campo 020 foi preenchido, porém, ele não deve ser preenchido'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
end
-- Testa o uso de maiúsculas no campo 041
if f041existancef041 ~= ''"" then
if f041:sub(1, 1) == "#" then
test = mw.text.trim ( frame:expandTemplate {title = 'Field data string', args = {'041', '0', '1', fullpagename = target}} )
a = "Talvez o primeiro indicador do campo 041 tenha sido esquecido"
if test == '#' then
info = string.format('* <strong class="error">%s.</strong>', a)
a = 'Talvez o primeiro indicador do campo 041 tenha sido esquecido'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
testlocal f041a = frame:expandTemplate { title = '"Select'", args = {' "041'", '"a'", target } } or false""
if string.match(testf041a, '"^[A-Z]'") then
a = '"O uso de maiúsculas não é permitido nos códigos de idioma (campo 041)'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
Linha 274 ⟶ 332:
-- queryResult = mw.smw.ask( '[[' .. target .. '#100||' .. target .. '#110||' .. target .. '#111||' .. target .. '#130]]' )
local accessPointPresence =
frame:callParserFunction {
name = '"#ask:[['" .. target .. '"#100||'" .. target .. '"#110||'" .. target .. '"#111||'" .. target .. '"#130]]'",
args = {' "?Field data'", format = '"count'", mainlabel = '"-'" }
} or 0
accessPointPresence = tonumber( accessPointPresence ) or 0
-- A seguir, testaTesta se há subcampo $b e se há espaço no subcampo $c do campo 090
local f090 =
test = frame:expandTemplate {title = 'Exist', args = {'090', target}} or false
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "090", "0", "0", fullpagename = target } }) or
if test ~= '' then
""
test = frame:expandTemplate {title = 'Select', args = {'090', 'b', target}} or false
if testf090 =~= ''"" then
if string.match(f090, ",") then
a = 'Está faltando o subcampo $b do campo 090 (notação de Cutter)'
a = "Normalmente não há vírgula no campo 090, reveja"
info = string.format( '* <strong class="error">%s.</strong>', a )
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
local f090b = frame:expandTemplate { title = "Select", args = { "090", "b", target } } or ""
-- A seguir, testa se não foi esquecida a letra do tíulo na notação de Cutter, caso haja um ponto de acesso 1XX
if accessPointPresencef090b >== 1 and string.match(test, '[0-9]$')"" then
a = 'Falta"Está afaltando letrao subcampo $b do títulocampo na090 (notação de Cutter')"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- Testa se não foi esquecida a letra do tíulo na notação de Cutter, caso haja um ponto de acesso 1XX
test = frame:expandTemplate {title = 'Select', args = {'090', 'c', target}} or false
if accessPointPresence >= 1 and string.match(testf090b, '%sed'"[0-9]$") then
a = "Falta a letra do título na notação de Cutter"
a = 'Nossa política de catalogação proíbe espaços na indicação de edição no número de chamada (090 $c)'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
local f090c = frame:expandTemplate { title = "Select", args = { "090", "c", target } } or ""
if string.match(f090c, "%sed") then
a = "Nossa política de catalogação proíbe espaços na indicação de edição no número de chamada (090 $c)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- A seguir, testaTesta (conta) se existe mais de um ponto de acesso principal
local f100existance = frame:expandTemplate { title = '"Exist'", args = {' "100'", target } } or ""
if accessPointPresence > 1 or f100existance == '"multiple'" then
a = '"Foi registrado <b>mais de um ponto de acesso principal</b>. Isso não é permitido'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
if f100existance ~= ''"" then
local f100 =
local f100 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'100', '0', '0', fullpagename = target}} or '' )
mw.text.trim(
info = 'O ponto de acesso principal foi dado a uma <b>pessoa</b>'
frame:expandTemplate { title = "Field data string", args = { "100", "0", "0", fullpagename = target } }
if f100:sub(1, 1) == '0' then
) or ""
a = 'e a entrada começa pelo seu <b>primeiro nome</b>'
info = string.format("O '*ponto %sde %s.',acesso info,principal foi dado a )uma <b>pessoa</b>"
if f100:sub(1, 1) == "0" then
a = 'e a entrada começa pelo seu <strong class="error">primeiro nome</strong>'
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f100:sub(1, 1) == '"1'" then
a = '"e a entrada começa pelo seu <b>sobrenome</b>'"
info = string.format( '"* %s %s.'", info, a )
table.insert(infos, info)
elseif f100:sub(1, 1) == '"3'" then
a = '"e a entrada começa pelo seu <b>nome de família</b>'"
info = string.format( '"* %s %s.'", info, a )
table.insert(infos, info)
elseif f100:sub(1, 1) == '"#'" then
a = '"o primeiro indicador não foi preenchido'"
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
else
a = "o primeiro indicador foi preenchido incorretamente"
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
elseif
f100:sub(1, 1) == '2' or f100:sub(1, 1) == '4' or f100:sub(1, 1) == '5' or f100:sub(1, 1) == '6' or
f100:sub(1, 1) == '7' or
f100:sub(1, 1) == '8' or
f100:sub(1, 1) == '9'
then
a = 'o primeiro indicador foi preenchido incorretamente'
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
end
if f100:sub(2, 2) ~= '"#'" then
a = '"O segundo indicador do campo 100 foi preenchido, porém, ele não deve ser preenchido'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- Testa se existe ', ' no subcampo $a (Nome, Sobrenome)
local f100a = frame:expandTemplate { title = '"Select'", args = {' "100'", '"a'", target } } or ""
if f100a ~= ''"" then
if not string.match(f100a, '".-,.'") then
a = '"Em pontos de acesso, o nome pessoal deve ser invertido (Nome, Sobrenome). Verifique o campo 100'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
if string.match(f100a, "[a-zÀ-ü],[A-ZÀ-ü]") then
a = "Falta espaço após a vírgula. Verifique o campo 100"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f100a, '[a-zÀ-ü],[A-ZÀ-ü]'"%d%d%d%d") then
a = 'Falta"No espaçocampo após100, ao vírgula.ano Verifiquedeve oser campoinformado 100'no subcampo $d"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
end
local f100q = frame:expandTemplate { title = '"Select'", args = {' "100'", '"q'", target } } or ""
if f100q ~= ''"" then
if not string.match(f100q, '"^%('") then
a = '"O subcampo $q do campo 100 necessita parênteses'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
end
local f100d = frame:expandTemplate { title = '"Select'", args = {' "100'", '"d'", target } } or ""
if f100d ~= ''"" then
if string.match(f100, '"%$d %d%d%d%d$'") then
a = '"O subcampo $d do campo 100 necessita hífen'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
end
end
-- A seguir, testaTesta se existe um ponto de acesso principal 110
local f110 =
local f110existance = frame:expandTemplate {title = 'Exist', args = {'110', target}}
mw.text.trim(
if f110existance ~= '' then
local f110 = mw.text.trim( frame:expandTemplate { title = '"Field data string'", args = {' "110'", '"0'", '"0'", fullpagename = target } } or '' )""
)
info = 'O ponto de acesso principal foi dado a uma <b>entidade coletiva</b>'
if f110:sub(1, 1) =~= '0'"" then
info = a"O =ponto 'ede aacesso entradaprincipal começafoi pordado a umuma <b>nomeentidade invertidocoletiva</b>'"
if f110:sub(1, 1) == "0" then
info = string.format( '* %s %s.', info, a )
a = "e a entrada começa por um <b>nome invertido</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f110:sub(1, 1) == '"1'" then
a = '"e a entrada começa por um <b>nome de jurisdição</b>'"
info = string.format( '"* %s %s.'", info, a )
table.insert(infos, info)
elseif f110:sub(1, 1) == '"2'" then
a = '"e a entrada começa por um <b>nome em ordem direta</b>'"
info = string.format( '"* %s %s.'", info, a )
table.insert(infos, info)
elseif f110:sub(1, 1) == '"#'" then
a = '"o primeiro indicador não foi preenchido'"
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
else
a = "o primeiro indicador foi preenchido incorretamente"
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
elseif
f110:sub(1, 1) == '3' or f110:sub(1, 1) == '4' or f110:sub(1, 1) == '5' or f110:sub(1, 1) == '6' or
f110:sub(1, 1) == '7' or
f110:sub(1, 1) == '8' or
f110:sub(1, 1) == '9'
then
a = 'o primeiro indicador foi preenchido incorretamente'
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
end
if f110:sub(2, 2) ~= '"#'" then
a = '"O segundo indicador do campo 110 foi preenchido, porém, ele não deve ser preenchido'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
end
-- A seguir, testaTesta se existe um ponto de acesso principal 111
local f111 =
local f111existance = frame:expandTemplate {title = 'Exist', args = {'111', target}}
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "111", "0", "0", fullpagename = target } }) or
if f111existance ~= '' then
""
local f111 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'111', '0', '0', fullpagename = target}} or '' )
if f111 ~= "" then
info = 'O ponto de acesso principal foi dado a um <b>evento</b>'
info = "O ponto de acesso principal foi dado a um <b>evento</b>"
if f111:sub(1, 1) == '0' then
if f111:sub(1, 1) == "0" then
a = 'e a entrada começa por um <b>nome invertido</b>'
infoa = string.format"e (a '*entrada %scomeça %s.'por ,um info, a<b>nome )invertido</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f111:sub(1, 1) == '"1'" then
a = '"e a entrada começa por um <b>nome de jurisdição</b>'"
info = string.format ( '"* %s %s.' ", info, a )
table.insert(infos, info)
elseif f111:sub(1, 1) == '"2'" then
a = '"e a entrada começa por um <b>nome em ordem direta</b>'"
info = string.format ( '"* %s %s.' ", info, a )
table.insert(infos, info)
elseif f111:sub(1, 1) == '"#'" then
a = '"o primeiro indicador não foi preenchido'"
info = string.format ( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
else
a = "o primeiro indicador foi preenchido incorretamente"
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
elseif
f111:sub(1, 1) == '3' or f111:sub(1, 1) == '4' or f111:sub(1, 1) == '5' or f111:sub(1, 1) == '6' or
f111:sub(1, 1) == '7' or
f111:sub(1, 1) == '8' or
f111:sub(1, 1) == '9'
then
a = 'o primeiro indicador foi preenchido incorretamente'
info = string.format ( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
end
if f111:sub(2, 2) ~= '"#'" then
a = '"O segundo indicador do campo 111 foi preenchido, porém, ele não deve ser preenchido'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
end
-- A seguir, testaTesta se existe um ponto de acesso principal 130
local f130 =
local f130existance = frame:expandTemplate {title = 'Exist', args = {'130', target}}
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "130", "0", "0", fullpagename = target } }) or
if f130existance ~= '' then
""
local f130 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'130', '0', '0', fullpagename = target}} or '' )
if f130 ~= "" then
info = 'O ponto de acesso principal foi dado a um <b>título uniforme</b>'
info = "O ponto de acesso principal foi dado a um <b>título uniforme</b>"
if f130:sub(1, 1) == '#' then
if f130:sub(1, 1) == "#" then
a = 'o primeiro indicador não foi preenchido'
a = "o primeiro indicador não foi preenchido"
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
else
local f130a = frame:expandTemplate { title = '"Select'", args = {' "130'", '"a'", target } } or ""
a = ucfirst( f130a:sub( tonumber(f130:sub(1, 1) ) or 0))
info = string.format( '* %s, ele será alfabetado como "<b>%s</b>".', info, a )
table.insert(infos, info)
end
if f130:sub(2, 2) ~= '"#'" then
a = '"O segundo indicador do campo 130 foi preenchido, porém, ele não deve ser preenchido'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
end
-- A seguir, testaTesta se existe um ponto de acesso principal. Se existir, testa se o primeiro indicador do campo 245 condiz com essa realidade
local f245ind1 = mw.text.trimf245:sub( frame:expandTemplate {title = 'Field data string'1, args = {'245', '0', '1', fullpagename = target}} ) or ''""
if accessPointPresence == 0 then
if f245ind1 == '"1'" then
a =
a = 'Não houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor "0"'
'Não houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor "0"'
info = string.format( '* <strong class="error">%s.</strong>', a )
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
else
if f245ind1 == '"0'" then
a =
a = 'Houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor "1"'
'Houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor "1"'
info = string.format( '* <strong class="error">%s.</strong>', a )
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- a seguir, testaTesta a relação entre a presença do campo 240 em relação a presença do campo 041 e a presença do subcampo $l
local f240 =
local f240existance = frame:expandTemplate {title = 'Exist', args = {'240', target}}
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "240", "0", "0", fullpagename = target } }) or
if f240existance ~= '' then
""
local f240 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'240', '0', '0', fullpagename = target}} )
if f041existancef240 =~= ''"" then
if f041 == "" then
a = 'Normalmente, quando há um campo 240, deve haver um campo 041'
a = "Normalmente, quando há um campo 240, deve haver um campo 041"
info = string.format( '* <strong class="error">%s.</strong>' , a )
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
local f240l = frame:expandTemplate { title = '"Select'", args = {' "240'", '"l'", target } } or ''""
if f240l ~= ''"" then
if string.match(f240l, '"^[a-zA-Z]{3}[a-zA-Z][a-zA-Z]$'") then
a = '"É necessário informar o idioma por extenso ($l do campo 240) antecedido por um ponto no subcampo $a'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
if not string.match(f240, '"%.%s?%$l'") then
a = '"O subcampo $l do campo 240 necessita ser antecedido por um ponto no subcampo anterior'"
info = string.format ( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
else
a = '"Normalmente, quando há um campo 240 $a, deve haver também um 240 $l. 240 $l não foi detectado'"
info = string.format ( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
if f240:sub(1, 1) == '"0'" then
a = '"O título uniforme não será exibido'"
info = string.format( '"* %s.'", a )
table.insert(infos, info)
elseif f240:sub(1, 1) == '"1'" then
a = '"O título uniforme será exibido'"
info = string.format( '"* %s.'", a )
table.insert(infos, info)
elseif f240:sub(1, 1) == '"#'" then
a = '"Está faltando o primeiro indicador do campo 240'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
else
a = '"O primeiro indicador do campo 240 foi preenchido incorretamente'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
if f240:sub(2, 2) == '"#'" then
a = '"Está faltando o segundo indicador do campo 240'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
else
local f240a =
local f240a = string.gsub( mw.text.trim ( frame:expandTemplate {title = 'Select', args = {'240', 'a', target}} ), '[/:=.]$', '' )
string.gsub(mw.text.trim(frame:expandTemplate { title = "Select", args = { "240", "a", target } }), "[/:=.]$",
a = 'O título uniforme será alfabetado como'
b = ucfirst( f240a:sub( f240:sub(2, 2 "") +or 1 ) )""
infoa = string.format("O '*título %suniforme "<b>%s</b>".',será a,alfabetado b )como"
b = ucfirst(f240a:sub(f240:sub(2, 2) + 1))
info = string.format('* %s "<b>%s</b>".', a, b)
table.insert(infos, info)
end
end
-- A seguir, informaInforma se o título receberá o ponto de acesso principal ou secundário
if f245ind1 == "0" then
local f245 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'245', '0', '0', fullpagename = target}} ) or ''
a = "O título recebeu o <b>ponto de acesso principal</b>"
if f245ind1 == '0' then
info = string.format("* %s.", a)
a = 'O título recebeu o <b>ponto de acesso principal</b>'
info = string.format( '* %s.', a )
table.insert(infos, info)
elseif f245ind1 == '"1'" then
a = '"O título recebeu um <b>ponto de acesso secundário</b>'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
elseif f245ind1 == '"#'" then
a = '"Está faltando o primeiro indicador do campo 245'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
else
a = '"O primeiro indicador do campo 245 foi preenchido incorretamente'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- A seguir, testaTesta se foi preenchido o segundo indicador do 245, se foi, mostra como será a alfabetação, removendo a pontuação final do subcampo $a ('/',':','='' ou '.')
local f245a = frame:expandTemplate { title = '"Select'", args = {' "245'", '"a'", target } } or ""
if f245:sub(2, 2) == '"#'" then
a = '"Está faltando o segundo indicador do campo 245'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
else
a = '"O título será alfabetado como'"
b = ucfirst( f245a:sub( f245:sub(2, 2) + 1 ) )
b = string.gsub( b, '"%s?[/:=.]$'", '' "")
info = string.format( '* %s "<b>%s</b>".', a, b )
table.insert(infos, info)
end
-- A seguir, testaTesta se existe espaço antes da pontuação "/", ":" e "=" no final do subcampo $a e $b
if string.match( f245a, '"[a-zA-Z][/:=]$' ") then
a = '"Inclua um espaço antes da pontuação (ao final do subcampo $a do campo 245')"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- A seguir, testaTesta se o subcampo $b começa com letras maiúsculas
local f245b = frame:expandTemplate { title = '"Select'", args = {' "245'", '"b'", target } } or ''""
if f245b ~= ''"" then
if string.match( f245b, '"[a-zA-Z][/:=]$' ") then
a = '"Inclua um espaço antes da pontuação (ao final do subcampo $b do campo 245'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
if string.match( f245b, '"^[A-Z]' ") then
a = '"Normalmente, o início de um subtítulo (245 $b) começa com letras minúsculas'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- Testa se existe mais de um subcampo $b no 245
if string.match( f245, '"%$b.*%$b' ") then
a = '"Há mais de um subcampo $b no campo 245. O subcampo $b não é repetível'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
end
-- A seguir, testaTesta se o subcampo $c está presente
local f245c = frame:expandTemplate { title = '"Select'", args = {' "245'", '"c'", target } } or ''""
if f245c ~= ''"" then
-- Testa se existe espaço antes do ponto e vírgula na indicação de responsabilidade, subcampo $c do 245
if string.match( f245c, '"[a-zA-Z.];' ") then
a = '"Inclua um espaço antes do ponto e vírgula (subcampo $c do campo 245)'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- Testa se existe "/" antes do subcampo $c do campo 245
if string.match( f245, '"[a-zA-Z]%s?%$c' ") then
a = 'É necessária a pontuação que precede a indicação de responsabilidade (" / ") no campo 245'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- Testa se há ": $c"
if string.match( f245, '":%s?%$c' ") then
a =
a = 'Ou o subtítulo foi colocado no subcampo $c, ou a pontuação que precede a indicação de responsabilidade (" / ") não foi informada corretamente (campo 245).'
'Ou o subtítulo foi colocado no subcampo $c, ou a pontuação que precede a indicação de responsabilidade (" / ") não foi informada corretamente (campo 245).'
info = string.format( '* <strong class="error">%s.</strong>', a )
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se o subcampo $c termina em "-"
if string.match( f245, '"%-$' ") then
a = '"Nunca inclua hifens de separação de áreas do AACR2 em registros MARC 21. Reveja a pontuação (campo 245)'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- Testa se existe mais de um subcampo $c no 245
if string.match( f245, '"%$c.*%$c' ") then
a = '"Há mais de um subcampo $c no campo 245. O subcampo $c não é repetível'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- Testa se existe mais de 3 vírgulas no campo 245 $c
if string.match( f245c, '("[A-Za-zÀ-ü ]*+,){3}'[A-Za-zÀ-ü ]+,[A-Za-zÀ-ü ]+,") then
a = 'Parece haver mais de 3 pessoas na indicação de responsabilidade (245 $c), use " ... [et al.]"'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- Testa se existe a sintaxe "*...[et. "
if string.match( f245c, '"[a-zA-ZÀ-ü]%.%.%.%[et.?%s' ") then
a = 'No campo 245, o espaçamento correto é " ... [et al.]"'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
else
a = '"Está faltando o subcampo $c do campo 245'"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- Testa se existe espaço antes de "ed." (subcampo $a do 250)
local f250 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "250", "0", "0", fullpagename = target } }) or
""
if f250 ~= "" then
local f250a = frame:expandTemplate { title = "Select", args = { "250", "a", target } } or ""
if string.match(f250a, "%d%.?ed%.") then
a = 'Inclua um espaço antes da indicação "ed." (subcampo $a do campo 250)'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f250a, "%-$") then
a = "Nunca inclua hifens de separação de áreas do AACR2 em registros MARC 21. Reveja a pontuação (campo 250)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- Testa se existe 260, se existir, verifica a pontuação final dos subcampos $a, $b e $c do campo 260
local f260 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "260", "0", "0", fullpagename = target } }) or
""
if f260 ~= "" then
local f260a = frame:expandTemplate { title = "Select", args = { "260", "a", target } } or ""
if f260a ~= "" then
if string.match(f260a, "[a-zA-ZÀ-ü%],]%s?$") then
a = 'Normalmente, o final do subcampo $a do campo 260 requer a seguinte pontuação " : "'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
else
if string.match(categories, "Livro") then
a = "Está faltando o subcampo $a do campo 260"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
if string.match(f260a, "[a-zA-ZÀ-ü%]]:") then
a =
'Normalmente, o final do subcampo $a do campo 260 requer a seguinte pontuação " : " (perceba o espaço antes da pontuação)'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
local f260b = frame:expandTemplate { title = "Select", args = { "260", "b", target } } or ""
if f260b ~= "" then
if string.match(f260b, "[a-zA-Z.]$") then
a =
'Normalmente, o final do subcampo $b do campo 260 requer uma das seguintes pontuações ", " ou " : ". Reveja a pontuação'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
else
if string.match(categories, "Livro") then
a = "Está faltando o subcampo $b do campo 260"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f260c = frame:expandTemplate { title = "Select", args = { "260", "c", target } } or ""
if f260c ~= "" then
-- Testa se o subcampo $c é precedido ou não por ","
if string.match(f260, "[a-zA-ZÀ-ü%]][;:]%s?%$c") then
a = "O ano de publicação deve sempre ser precedido de uma vírgula. Reveja a pontuação (campo 260)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f260c, "[a-zA-ZÀ-ü0-9%]]$") then
a = "Nossa política de catalogação define que o subcampo $c do campo 260 deve terminar com um ponto"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
else
a = "Está faltando o subcampo $c do campo 260"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- Testa se existe espaço entre o número e a indicaçação de extensão do texto
local f300 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "300", "0", "0", fullpagename = target } }) or
""
if f300 ~= "" then
local f300a = frame:expandTemplate { title = "Select", args = { "300", "a", target } } or ""
if f300a ~= "" then
if string.match(f300a, "%d[a-z]%.") then
a = 'Inclua um espaço entre o número e a indicação "p.", "f." ou "v." (subcampo $a do campo 300)'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se existe espaço entre "p." e ";"
if string.match(f300a, "%.[:;]") then
a = 'Inclua um espaço entre a indicação "p.", "f." ou "v." e a pontuação final (subcampo $a do campo 300)'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se existe "il." no subcampo $a (deve estar no subcampo $b)
if string.match(f300a, "il%.") then
a = 'Ilustrações e outros detalhes físicos devem ir no subcampo $b do campo 300, antecedidos de " : "'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f300b = frame:expandTemplate { title = "Select", args = { "300", "b", target } } or ""
if f300b ~= "" then
-- Testa se existe ".;" no subcampo $b do campo 300
if string.match(f300b, "%.;") then
a = "Inclua um espaço entre o ponto e o ponto e vírgula (campo 300, subcampo $b)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f300b, "il,") then
a = "Falta um ponto na abreviatura para ilustrações (il.)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f300b, "il%.?, col") then
a = "'Ilustrações coloridas' (il. color.) é uma expressão só, remova a vírgula"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se o subcampo $b contém "il. ; color" ou "il. ; p&b"
if string.match(f300b, "il%. ?; color") then
a = "'Ilustrações coloridas' (il. color.) é uma expressão só, remova o ponto e vírgula da expressão"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f300b, "il%. ?; p&b") then
a = "'Ilustrações pretas e brancas' (il. p&b) é uma expressão só, remova o ponto e vírgula da expressão"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se os itens do subcampo $b estão separados por ponto e vírgula
if string.match(f300b, "il%. ?; gráf") then
a = "No campo 300, $b, os itens devem ser separados por vírgulas (il., gráfs.)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se o subcampo $b termina em ":"
if not string.match(f300, ":%s%$b") then
a = 'A pontuação que precede o subcampo $b, no campo 300, deve ser sempre " : "'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f300c = frame:expandTemplate { title = "Select", args = { "300", "c", target } } or ""
if f300c ~= "" then
-- Testa se a sintaxe das dimensões está correta
if string.match(f300c, "%d[a-z]") then
a =
'Atenção, a sintaxe correta para a dimensão é: "NN cm" ou, menos frequentemente, "NN x NN cm" (subcampo $c do campo 300)'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
else
if string.match(categories, "Livro") then
a = "Está faltando o subcampo $c do campo 300"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- Testa se a pontuação antes da dimensão é ".", "," ou ":"
if string.match(f300, "[.,:]%s?%$c") then
a = 'A pontuação que precede a dimensão (300 $c) deve ser " ; "'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se o subcampo $c termina em "-"
if string.match(f300, "%-$") then
a = "Nunca inclua hifens de separação de áreas do AACR2 em registros MARC 21. Reveja a pontuação (campo 300)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f440 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "440", "0", "0", fullpagename = target } }) or
""
if f440 ~= "" then
a = "O campo 440 é obsoleto. Mova seu conteúdo para o campo 490"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se existem indicadores, parênteses no subcampo $a do campo 490 e se existe ";" antes da numeração da série
local f490 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "490", "0", "0", fullpagename = target } }) or
""
if f490 ~= "" then
if f490:sub(2, 2) ~= "#" then
a = "O segundo indicador do campo 490 foi preenchido, porém, ele não deve ser preenchido"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
local f490a = frame:expandTemplate { title = "Select", args = { "490", "a", target } } or ""
if f490a ~= "" then
if string.match(f490a, "^%(") then
a = "Segundo as orientações do MARC 21, não inclua os parênteses no campo 490 ou 830"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se o início da série/coleção começa com letra minúscula
if string.match(f490a, "^[a-zà-ÿ]") then
a = "Normalmente, o início de uma série/coleção (490 $a) começa com letra maiúscula"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se há espaço antes do ponto e vírgula da série
if string.match(f490a, "[a-zA-ZÀ-ü0-9];") then
a = 'O sinal de ponto e vírgula (";") deve ser sempre precedido por um espaço. Reveja a pontuação'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f490v = frame:expandTemplate { title = "Select", args = { "490", "v", target } } or ""
if f490v ~= "" then
if not string.match(f490, ";%s?%$v") then
a = "É necessária a pontuação que precede a numeração da série (490, $v)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- Testa a consistência entre o indicador do 490 e a presença do campo 830
local f830 =
mw.text.trim(
frame:expandTemplate { title = "Field data string", args = { "830", "0", "0", fullpagename = target } }
) or ""
if f490:sub(1, 1) == "#" then
a = "Está faltando o primeiro indicador do campo 490"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
elseif f490:sub(1, 1) == "1" then
if f830 == "" then
a =
"Foi especificado um ponto de acesso secundário para a série (490, primeiro indicador com valor 1), porém, um campo 830 não foi informado"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
elseif f490:sub(1, 1) == "0" then
if f830 ~= "" then
a =
"O primeiro indicador do campo 490 indica que não foi gerado um ponto de acesso para a série, porém, um campo 830 foi informado"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
else
a = "O primeiro indicador do campo 490 foi preenchido incorretamente"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- Testa se a nota 500 acaba com "."
local f500 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "500", "0", "0", fullpagename = target } }) or
""
if f500 ~= "" then
if string.match(f500, "[a-zA-ZÀ-ü0-9:;-]$") then
a = "Nossa política de catalogação define que as notas devem terminar com um ponto (500)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f500, "inclui") then
a = "Verifique o uso de maiúsculas no início de frase ('inclui')"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- Testa se a nota 504 acaba com "." e se existe uso de maiúsculas no meio da nota
local f504 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "504", "0", "0", fullpagename = target } }) or
""
if f504 ~= "" then
if string.match(f504, "[a-zA-ZÀ-ü0-9]$") then
a = "Nossa política de catalogação define que as notas devem terminar com um ponto (504)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se existe uso de maiúsculas no meio da nota 504
if string.match(f504:sub(6), ".*%s[A-Z]") then
a = "Verifique o uso de maiúsculas na nota do campo 504"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f504, "Inclui índice%.?$") then
a = "'Inclui índice', somente, deve estar no campo 500"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f600 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "600", "0", "0", fullpagename = target } }) or
""
-- Testa os indicadores dos campos 6XX
if f600 ~= "" then
if f600:sub(1, 1) == "#" then
a = "Está faltando o primeiro indicador do campo 600"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if f600:sub(2, 2) ~= "4" then
a = 'Nossa política de catalogação define que o segundo indicador do campo 600 deve ser sempre "4"'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se existe "," no subcampo $a (Nome, Sobrenome)
local f600a = frame:expandTemplate { title = "Select", args = { "600", "a", target } } or ""
if f600a ~= "" then
if not string.match(f600a, ".*,.") then
a = "Em pontos de acesso, o nome pessoal deve ser invertido (Nome, Sobrenome). Verifique o campo 600"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f600a, "[a-zÀ-ü],[A-ZÀ-ü]") then
a = "Falta espaço após a vírgula. Verifique o campo 600"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f600a, "%d%d%d%d") then
a = "No campo 600, o ano deve ser informado no subcampo $d"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f600q = frame:expandTemplate { title = "Select", args = { "600", "q", target } } or ""
if f600q ~= "" then
if not string.match(f600q, "^%(") then
a = "O subcampo $q do campo 600 necessita parênteses"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
end
local f610 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "610", "0", "0", fullpagename = target } }) or
""
if f610 ~= "" then
if f610:sub(1, 1) == "#" then
a = "Está faltando o primeiro indicador do campo 610"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if f610:sub(2, 2) ~= "4" then
a = 'Nossa política de catalogação define que o segundo indicador do campo 610 deve ser sempre "4"'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f611 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "611", "0", "0", fullpagename = target } }) or
""
if f611 ~= "" then
if f611:sub(1, 1) == "#" then
a = "Está faltando o primeiro indicador do campo 611"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if f611:sub(2, 2) ~= "4" then
a = 'Nossa política de catalogação define que o segundo indicador do campo 611 deve ser sempre "4"'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f630 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "630", "0", "0", fullpagename = target } }) or
""
if f630 ~= "" then
if f630:sub(1, 1) == "#" then
a = "Está faltando o primeiro indicador do campo 630"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if f630:sub(2, 2) ~= "4" then
a = 'Nossa política de catalogação define que o segundo indicador do campo 630 deve ser sempre "4"'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f650 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "650", "0", "0", fullpagename = target } }) or
""
if f650 ~= "" then
if f650:sub(1, 1) ~= "0" then
a = 'Nossa política de catalogação define que o primeiro indicador do campo 650 deve ser sempre "0"'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if f650:sub(2, 2) ~= "4" then
a = 'Nossa política de catalogação define que o segundo indicador do campo 650 deve ser sempre "4"'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se os assuntos começam com letra minúscula
if string.match(f650, "%$[axzy]%s[a-z]") then
a = "Os assuntos principais e suas subdivisões devem começar com letra maiúscula"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se um subcampo termina em "-"
if string.match(f650, "%-%s?%$") then
a = "Nunca inclua hifens entre termos de assuntos"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f651 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "651", "0", "0", fullpagename = target } }) or
""
if f651 ~= "" then
if f651:sub(1, 1) ~= "#" then
a = 'Nossa política de catalogação define que o primeiro indicador do campo 651 deve ser sempre "#"'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if f651:sub(2, 2) ~= "4" then
a = 'Nossa política de catalogação define que o segundo indicador do campo 651 deve ser sempre "4"'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- Testa os pontos de acesso secundários, tal como os principais
local f700 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "700", "0", "0", fullpagename = target } }) or
""
if f700 ~= "" then
info = "Um ponto de acesso secundário foi dado a uma <b>pessoa</b>"
if f700:sub(1, 1) == "0" then
a = 'e a entrada começa pelo seu <strong class="error">primeiro nome</strong>'
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f700:sub(1, 1) == "1" then
a = "e a entrada começa pelo seu <b>sobrenome</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f700:sub(1, 1) == "3" then
a = "e a entrada começa pelo seu <b>nome de família</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f700:sub(1, 1) == "#" then
a = "o primeiro indicador não foi preenchido"
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
else
a = "o primeiro indicador foi preenchido incorretamente"
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
end
if f700:sub(2, 2) ~= "#" then
a = "O segundo indicador do campo 700 foi preenchido, porém, ele não deve ser preenchido"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- Testa se existe mais de um subcampo $a no mesmo campo 700
local exist700 = frame:expandTemplate { title = "Exist", args = { "700", target } } or false
if exist700 == "yes" then
if string.match(f700, "%$a.*%$a.-$") then
a = "Há mais de um subcampo $a no campo 700. O subcampo $a não é repetível"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
-- testa se existe "," no subcampo $a (Nome, Sobrenome)
local f700a = frame:expandTemplate { title = "Select", args = { "700", "a", target } } or ""
if f700a ~= "" then
if not string.match(f700a, ".-,.") then
a = "Em pontos de acesso, o nome pessoal deve ser invertido (Nome, Sobrenome). Verifique o campo 700"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f700a, "[a-zÀ-ü],[A-ZÀ-ü]") then
a = "Falta espaço após a vírgula. Verifique o campo 700"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(f700a, "%d%d%d%d") then
a = "No campo 700, o ano deve ser informado no subcampo $d"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f700q = frame:expandTemplate { title = "Select", args = { "700", "q", target } } or ""
if f700q ~= "" then
if not string.match(f700q, "^%(") then
a = "O subcampo $q do campo 700 necessita parênteses"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f700e = frame:expandTemplate { title = "Select", args = { "700", "e", target } } or ""
if f700e ~= "" then
if string.match(f700, "[a-zA-ZÀ-ü0-9%]-]%s?%$e") then
a = "O subcampo $e do campo 700 deve ser precedido por uma vírgula"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
end
end
local f710 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "710", "0", "0", fullpagename = target } }) or
""
if f710 ~= "" then
info = "Um ponto de acesso secundário foi dado a uma <b>entidade coletiva</b>"
if f710:sub(1, 1) == "0" then
a = "e a entrada começa por um <b>nome invertido</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f710:sub(1, 1) == "1" then
a = "e a entrada começa por um <b>nome de jurisdição</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f710:sub(1, 1) == "2" then
a = "e a entrada começa por um <b>nome em ordem direta</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f710:sub(1, 1) == "#" then
a = "o primeiro indicador não foi preenchido"
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
else
a = "o primeiro indicador foi preenchido incorretamente"
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
end
if f710:sub(2, 2) ~= "#" then
a = "O segundo indicador do campo 710 foi preenchido, porém, ele não deve ser preenchido"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f711 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "711", "0", "0", fullpagename = target } }) or
""
if f711 ~= "" then
info = "Um ponto de acesso secundário foi dado a um <b>evento</b>"
if f711:sub(1, 1) == "0" then
a = "e a entrada começa por um <b>nome invertido</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f711:sub(1, 1) == "1" then
a = "e a entrada começa por um <b>nome de jurisdição</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f711:sub(1, 1) == "2" then
a = "e a entrada começa por um <b>nome em ordem direta</b>"
info = string.format("* %s %s.", info, a)
table.insert(infos, info)
elseif f711:sub(1, 1) == "#" then
a = "o primeiro indicador não foi preenchido"
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
else
a = "o primeiro indicador foi preenchido incorretamente"
info = string.format('* %s, porém, <strong class="error">%s.</strong>', info, a)
table.insert(infos, info)
end
if f711:sub(2, 2) ~= "#" then
a = "O segundo indicador do campo 711 foi preenchido, porém, ele não deve ser preenchido"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f740 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "740", "0", "0", fullpagename = target } }) or
""
if f740 ~= "" then
if f740:sub(1, 1) == "#" then
a = "O primeiro indicador do campo 740 precisa ser preenchido"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- Testa os indicadores do campo 830
local f830 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "830", "0", "0", fullpagename = target } }) or
""
if f830 ~= "" then
if f830:sub(1, 1) ~= "#" then
a = "O primeiro indicador do campo 830 foi preenchido, porém, ele não deve ser preenchido"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if f830:sub(2, 2) == "#" then
a = "O segundo indicador do campo 830 precisa ser preenchido"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
local f830v = frame:expandTemplate { title = "Select", args = { "830", "v", target } } or ""
if f830v ~= "" then
if not string.match(f830, ";%s?%$v") then
a = "É necessária a pontuação que precede a numeração da série (830, $v)"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
if f490 == "" then
a = "Foi informado um ponto de acesso secundário para a série (campo 830), porém, um campo 490 não foi detectado"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
local f856 =
mw.text.trim(frame:expandTemplate { title = "Field data string", args = { "856", "0", "0", fullpagename = target } }) or
""
if f856 ~= "" then
if f856:sub(1, 1) ~= "4" then
a = 'O primeiro indicador do campo 856 precisa ter o valor "4"'
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
local f856a = frame:expandTemplate { title = "Select", args = { "856", "a", target } } or ""
if f856a ~= "" then
a = "Normalmente, o subcampo utilizado no 856 é o $u, não o $a"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
end
-- Testa por inteiro o registro de modo a acusar: "," ou o "." precedido de espaço; designadores de subcampos errados
local isoRecord =
frame:callParserFunction {
name = "#ask:[[-Has subobject::" .. target .. "]][[Field data::+]]",
args = {
"?Field data",
format = "plainlist",
link = "none",
headers = "hide",
mainlabel = "-",
outro = "",
sep = "",
valuesep = "",
propsep = ""
}
} or ""
if string.match(isoRecord, "%s[.,][^.]") then
a = "Pontos finais ou vírgulas nunca devem ser precedidos por um espaço"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
if string.match(isoRecord, "%$[A-Z]") then
a = "Não são permitidos designadores de subcampos com letras maiúsculas"
info = string.format('* <strong class="error">%s.</strong>', a)
table.insert(infos, info)
end
 
 
 
end -- end if 245
 
return table.concat(infos, '\n')
return table.concat(infos, "\n")
end