Module:R:Bailly

Hello, you have come here looking for the meaning of the word Module:R:Bailly. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:R:Bailly, but we will also tell you about its etymology, its characteristics and you will know how to say Module:R:Bailly in singular and plural. Everything you need to know about the word Module:R:Bailly you have here. The definition of the word Module:R:Bailly will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:R:Bailly, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module serves {{R:Bailly}}.


local export = {}

local grc_accent_module = "Module:grc-accent"
local languages_module = "Module:languages"
local load_module = "Module:load"
local string_compare_module = "Module:string/compare"
local string_utilities_module = "Module:string utilities"

local require = require
local type = type

local function load_data(...)
	load_data = require(load_module).load_data
	return load_data(...)
end

local function string_compare(...)
	string_compare =  require(string_compare_module)
	return string_compare(...)
end

local function strip_accent(...)
	strip_accent = require(grc_accent_module).strip_accent
	return strip_accent(...)
end

local function ulower(...)
	ulower = require(string_utilities_module).lower
	return ulower(...)
end

local lang
local function get_lang(...)
	lang, get_lang = require(languages_module).getByCode("grc"), nil
	return lang
end

function export.create(frame)
	local args = require("Module:parameters").process(frame:getParent().args, {
		 = true,
		 = {alias_of = 1},
	})

	local logos = args or load_data("Module:headword/data").pagename
	if (lang or get_lang()):findBestScript(logos):getCode() ~= "Polyt" then
		return ""
	end
	
	local headwords = load_data("Module:R:Bailly/data")
	local x = strip_accent(logos)
	local x_sortkey = lang:makeSortKey(x)
	local is_lower = x == ulower(x)
	local l, h = 1, headwords.n
	while l < h do
		local m = (l + h) / 2
		m = m + m % 1
		local hw, dir, init_m = headwords, 1, m
		-- If the table has false (i.e. a page which no entries begin on), find
		-- one that does.
		while not hw do
			m = m + dir
			hw = headwords
			if hw == nil then
				m, dir = init_m, -dir
			end
		end
		-- If there's a direct match, use it.
		if x == hw then
			l = m
			break
		-- If it's a table, and there's an exact match, return page. This is
		-- used to specify the start page for multipage entries, as most aren't
		-- the first entry on the page they begin.
		elseif type(hw) == "table" then
			local hw_page = hw
			hw = hw
			if x == hw then
				l = hw_page
				break
			end
		end
		-- If `x` is lower, the upper bound is the previous page; if higher, the
		-- lower bound is this page.
		local hw_sortkey = lang:makeSortKey(hw)
		if (
			x_sortkey == hw_sortkey and is_lower and hw ~= ulower(hw) or
			string_compare(x_sortkey, hw_sortkey)
		) then
			h = m - 1
			-- If the previous page has no headword, iterate backwards until one
			-- is found.
			while headwords == false do
				h = h - 1
			end
		else
			l = m
		end
	end
	
	if headwords ~= x then
		while headwords == false do
			l = l + 1
		end
	end
	local page = l == 1 and "" or ("page/n%d/"):format(l - 1)
	return (' in '):format(
		page, logos
	)
end

return export