Module:ZZProbe: Difference between revisions
From Bodhicitta
(probe) |
(probe) |
||
| (One intermediate revision by the same user not shown) | |||
| 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 q = mw.smw.ask{ | local out = {} | ||
for _, lim in ipairs({ 50, 200, 500, 1000, 5000 }) do | |||
local q = mw.smw.ask{ | |||
'[[' .. SSC_PREFIX .. ']][[SegmentFormat::Quote]]', | |||
'?QuoteSource#-=V', | |||
'?SegmentOrder#=O', | |||
limit = lim | |||
} | |||
local got, names = 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; names[s] = true end | |||
end | |||
end | end | ||
local d = 0 | |||
for _ in pairs(names) do d = d + 1 end | |||
table.insert(out, 'lim' .. lim .. ': rows=' .. (q and #q or 0) .. ' vals=' .. got .. ' distinct=' .. d) | |||
end | end | ||
return table.concat(out, ' | ') | |||
end | end | ||
return p | return p | ||
Latest 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 = {}
for _, lim in ipairs({ 50, 200, 500, 1000, 5000 }) do
local q = mw.smw.ask{
'[[' .. SSC_PREFIX .. ']][[SegmentFormat::Quote]]',
'?QuoteSource#-=V',
'?SegmentOrder#=O',
limit = lim
}
local got, names = 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; names[s] = true end
end
end
local d = 0
for _ in pairs(names) do d = d + 1 end
table.insert(out, 'lim' .. lim .. ': rows=' .. (q and #q or 0) .. ' vals=' .. got .. ' distinct=' .. d)
end
return table.concat(out, ' | ')
end
return p