Module:sandbox/Morse

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


local export = {}

local sc = require("Module:scripts").getByCode("Morse")

local charList = {
	 = ".-",
	 = "-...",
	 = "-.-.",
	 = "-..",
	 = ".",
	 = "..-.",
	 = "--.",
	 = "....",
	 = "..",
	 = ".---",
	 = "-.-",
	 = ".-..",
	 = "--",
	 = "-.",
	 = "---",
	 = ".--.",
	 = "--.-",
	 = ".-.",
	 = "...",
	 = "-",
	 = "..-",
	 = "...-",
	 = ".--",
	 = "-..-",
	 = "-.--",
	 = "--..",
}

local headwordMap = {
	 = "]",
	 = "]",
	 = "]",
}

local inlineMap = {
	 = "]",
	 = "]",
	 = "]",
}

function export.convertToMorse(text)
	local result = mw.ustring.gsub(text, ".", charList)

	return result
end

function export.textToHeadword(text)
	return mw.ustring.gsub(text, "", headwordMap)
end

function export.textToInline(text)
	return mw.ustring.gsub(text, "", inlineMap)
end

function export.link(frame)
	local text = frame:getParent().args
	local textUpper = mw.ustring.upper(text)
	local morseValues = export.convertToMorse(textUpper)
	local morseFinal = export.textToInline(morseValues)

	local result = morseFinal
	return result
end

local types = {
	 = "letters",
	 = "numbers",
	 = "punctuation marks",
	 = "symbols",
	 = "interjections",
}

function export.headword(frame)

	local m_head = require("Module:headword")

	local type = frame.args ~= "" and frame.args
	local head = frame:getParent().args
	if not head or head == "" then
		head = mw.title.getCurrentTitle().subpageText
	end
	local langCode = frame.args or "mul"
	local lang = require("Module:languages").getByCode(langCode)

	local display = '<span style="display:inline-block;vertical-align:middle">' .. export.textToHeadword(head) .. '</span>'
	
	local data = {lang = lang, sc = sc, categories = {}, sort_key = head, heads = {display}, translits = {"-"}}
	
	if types then
		data.pos_category = types
	end

	return m_head.full_headword(data)

end

return export