Seeking Advice: Ignoring Variations in Answers for Educational Game

local function normalizeAnswer(answer)
	return answer:gsub("[%p%c%s]", ""):lower()
end

local function isAnswerCorrect(playerAnswer, correctAnswer, questionType)
	if questionType == "typeAnswer" then
		-- Normalize answers
		local normalizedPlayerAnswer = normalizeAnswer(playerAnswer)
		local normalizedCorrectAnswer = normalizeAnswer(correctAnswer)

		return normalizedPlayerAnswer == normalizedCorrectAnswer
	elseif questionType == "multipleChoice" then
		return playerAnswer:lower() == correctAnswer:lower()
	end
	return false
end

The code provided focuses on filtering out specific words, punctuation marks, and white spaces during answer validation. For example, if the question asks ‘What makes Lua suitable for game development?’ and I respond with ‘Because of its efficiency, flexibility, and embeddability,’ the expected correct answer in the code is ‘Its efficiency, flexibility, and embeddability.’ However, variations involving extra words, altered words, and case sensitivity (uppercase or lowercase) are not currently managed.