יחידה:WikidataCrossValidation: הבדלים בין גרסאות בדף

מאין תקציר עריכה
מ 23 גרסאות של הדף wikipedia:he:יחידה:WikidataCrossValidation יובאו
 
(10 גרסאות ביניים של 3 משתמשים אינן מוצגות)
שורה 31: שורה 31:
return CrossValidate.CrossValidateResult.INVALID_WIKITEXT
return CrossValidate.CrossValidateResult.INVALID_WIKITEXT
end
end
end
-- temporary fix for option param of (e.g P1/P2)
if string.find(propertyName, '/') then
return CrossValidate.CrossValidateResult.INVALID_WIKITEXT
end
end
     local propertyVals = mw.wikibase.getBestStatements(entityId, propertyName)
     local propertyVals = mw.wikibase.getBestStatements(entityId, propertyName)
שורה 54: שורה 58:
    if propValue['type'] == 'wikibase-entityid' then
    if propValue['type'] == 'wikibase-entityid' then
    local localLabel, langLabel = mw.wikibase.getLabelWithLang( "Q" .. propValue.value['numeric-id'] )
    local localLabel, langLabel = mw.wikibase.getLabelWithLang( "Q" .. propValue.value['numeric-id'] )
    local isLocalLabel = langLabel=='he'
    local isLocalLabel = langLabel=='he'
    if not isLocalLabel then
    if not isLocalLabel then
שורה 91: שורה 95:
     end
     end
    elseif propValue['type'] == 'quantity' then
    elseif propValue['type'] == 'quantity' then
    local noramlizeUnit =  mw.ustring.gsub(wikitext, '(.+) מטרים', '%1 מטר')
    local noramlizeUnit = mw.ustring.gsub(wikitext, '[%[%]]', '')
    noramlizeUnit =  mw.ustring.gsub(noramlizeUnit, '(.+) מטרים', '%1 מטר')
    noramlizeUnit =  mw.ustring.gsub(noramlizeUnit, '(.+) ק"ג$', '%1 קילוגרם')
    if noramlizeUnit == formattedValue then
    if noramlizeUnit == formattedValue then
    return CrossValidate.CrossValidateResult.COMPATIBLE
    return CrossValidate.CrossValidateResult.COMPATIBLE
    end
    end
 
if mw.ustring.match(noramlizeUnit, '^[%d.,]+ מטר$') then
local ConvertModule = require('Module:Convert')
    local success, wikidataMeter = pcall(ConvertModule.convert, mw.getCurrentFrame():newChild{ args = {
['input'] = propertyName,
[2] = 'מטר',
['disp'] = 'out',
['qid'] = entityId,
['abbr']='off'
} }:newChild{})
if success then
wikidataMeter =  mw.ustring.gsub(wikidataMeter, '(.+) מטרים', '%1 מטר')
if wikidataMeter==noramlizeUnit then
return CrossValidate.CrossValidateResult.COMPATIBLE
end
end
    end
    return CrossValidate.CrossValidateResult.INVALID_WIKITEXT -- TODO: parse quantity and units
    return CrossValidate.CrossValidateResult.INVALID_WIKITEXT -- TODO: parse quantity and units
    elseif propValue['type'] == 'time' then
    elseif propValue['type'] == 'time' then
שורה 121: שורה 142:
return CrossValidate.CrossValidateResult.COMPATIBLE
return CrossValidate.CrossValidateResult.COMPATIBLE
end
function CrossValidate.templateCrossVal(frame)
local Arguments = require( "Module:Arguments" )
local args = Arguments.getArgs(frame, { ['trim'] = true, ['removeBlanks'] = true })
local wikitext = args[1]
local propertyName = args[2]
local res = CrossValidate.crossValidate(wikitext, propertyName)
if res then
return CrossValidate.maintainceCategory(res, propertyName)
end
end
end


return CrossValidate
return CrossValidate