Module:ZZProbe: Difference between revisions
From Bodhicitta
(probe) |
(probe) |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local SSC_PREFIX = '~Translation Memory:016-Tsadra-SSC-Root/*' | local SSC_PREFIX = '~Translation Memory:016-Tsadra-SSC-Root/*' | ||
function p.main() | function p.main() | ||
local | local out = {} | ||
' | local variants = { | ||
'?QuoteSource# | { label = 'plain', po = '?QuoteSource=V' }, | ||
'? | { label = 'hash', po = '?QuoteSource#=V' }, | ||
{ label = 'hashmin',po = '?QuoteSource#-=V' }, | |||
} | } | ||
for _, v in ipairs(variants) do | |||
local q = mw.smw.ask{ | |||
for _, | '[[' .. SSC_PREFIX .. ']][[SegmentFormat::Quote]]', | ||
local | v.po, | ||
'?SegmentOrder#=O', | |||
for _, | limit = 60 | ||
} | |||
local got = 0 | |||
if q then | |||
for _, row in ipairs(q) do | |||
local s = row.V | |||
if type(s) == 'table' then s = s[1] end | |||
if type(s) == 'table' then s = s.fulltext end | |||
if type(s) == 'string' and s ~= '' then got = got + 1 end | |||
end | |||
end | end | ||
table.insert(out, v.label .. '=' .. got .. '/' .. (q and #q or 0)) | |||
end | end | ||
return table.concat(out, ' ') | |||
end | end | ||
return p | return p | ||
Revision as of 14:27, 21 September 2026
Documentation for this module may be created at Module:ZZProbe/doc
local p = {}
local SSC_PREFIX = '~Translation Memory:016-Tsadra-SSC-Root/*'
function p.main()
local out = {}
local variants = {
{ label = 'plain', po = '?QuoteSource=V' },
{ label = 'hash', po = '?QuoteSource#=V' },
{ label = 'hashmin',po = '?QuoteSource#-=V' },
}
for _, v in ipairs(variants) do
local q = mw.smw.ask{
'[[' .. SSC_PREFIX .. ']][[SegmentFormat::Quote]]',
v.po,
'?SegmentOrder#=O',
limit = 60
}
local got = 0
if q then
for _, row in ipairs(q) do
local s = row.V
if type(s) == 'table' then s = s[1] end
if type(s) == 'table' then s = s.fulltext end
if type(s) == 'string' and s ~= '' then got = got + 1 end
end
end
table.insert(out, v.label .. '=' .. got .. '/' .. (q and #q or 0))
end
return table.concat(out, ' ')
end
return p