Module:ZZProbe: Difference between revisions

From Bodhicitta
(probe)
(probe)
 
Line 3: Line 3:
function p.main()
function p.main()
local out = {}
local out = {}
local variants = {
for _, lim in ipairs({ 50, 200, 500, 1000, 5000 }) do
{ 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{
local q = mw.smw.ask{
'[[' .. SSC_PREFIX .. ']][[SegmentFormat::Quote]]',
'[[' .. SSC_PREFIX .. ']][[SegmentFormat::Quote]]',
v.po,
'?QuoteSource#-=V',
'?SegmentOrder#=O',
'?SegmentOrder#=O',
limit = 60
limit = lim
}
}
local got = 0
local got, names = 0, {}
if q then
if q then
for _, row in ipairs(q) do
for _, row in ipairs(q) do
Line 21: Line 16:
if type(s) == 'table' then s = s[1] end
if type(s) == 'table' then s = s[1] end
if type(s) == 'table' then s = s.fulltext end
if type(s) == 'table' then s = s.fulltext end
if type(s) == 'string' and s ~= '' then got = got + 1 end
if type(s) == 'string' and s ~= '' then got = got + 1; names[s] = true end
end
end
end
end
table.insert(out, v.label .. '=' .. got .. '/' .. (q and #q or 0))
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, ' ')
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