Module:ZZProbe

From Bodhicitta
Revision as of 14:27, 21 September 2026 by Jeremi (talk | contribs) (probe)

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