Module:ZZProbe

From Bodhicitta
Revision as of 14:27, 21 September 2026 by Jeremi (talk | contribs) (probe)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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