मॉड्यूल:R:CEDHL
दिखावट
"इस मॉड्यूल हेतु प्रलेख मॉड्यूल:R:CEDHL/doc पर बनाया जा सकता है"
p = {}
local list = require("Module:R:CEDHL/data")
function p.normalize(term)
local length = mw.ustring.len(term)
local i = 1
local normalized = ""
while i <= length do
local x = mw.ustring.codepoint(term, i)
if not (1425 <= x and x <= 1479) then
normalized = normalized .. mw.ustring.sub(term, i, i)
end
i = i + 1
end
return normalized:gsub("'", ""):gsub("׳", ""):gsub("◌", "")
end
function p.page_number(frame)
local value = p.normalize(frame.args[1])
local low = 1
local high = #list
local mid = 0
while high - low > 1 do
mid = math.floor((low+high)/2)
if list[mid] == value then return mid
elseif list[mid] < value then low = mid
elseif list[mid] > value then high = mid - 1
end
end
if list[high] <= value then return high
else return low
end
end
return p