Module:th-anagram

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

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local links = require("Module:links")

local lang = require("Module:languages").getByCode("th")
local script = require("Module:scripts").getByCode("Thai")
local PAGENAME = mw.title.getCurrentTitle().text

local function contains(table, val)

	for i = 1, #table do
		if table == val then 
			return true
		end
	end

	return false

end

local function get_alphagram(word)

	word = mw.ustring.upper(word) -- it may apply
	word = mw.ustring.gsub(word, "", "")

	local charTbl = mw.text.split(word, "")
	table.sort(charTbl)
	return table.concat(charTbl, "")

end

function export.show(frame)

	local args = frame:getParent().args
	local head = ((frame.args == "" or frame.args == nil) and PAGENAME or frame.args)
	local alphagram = get_alphagram(head)

	local output = {}
	local list = require("Module:th-anagram/processed data")

	if list then
		for _, term in ipairs(list) do
			if term ~= head then
				table.insert(output, links.full_link({lang = lang, term = term, sc = script}))
			end
		end
	end

	return "<ul><li>" .. table.concat(output, ", ") .. "</li></ul>"

end

return export