وحدة:Past Simple
المظهر
local p = {}
-- A table of common irregular verbs and their past simple forms
local irregularVerbs = {
["be"] = "was",
["become"] = "became",
["begin"] = "began",
["break"] = "broke",
["bring"] = "brought",
["build"] = "built",
["buy"] = "bought",
["catch"] = "caught",
["choose"] = "chose",
["come"] = "came",
["do"] = "did",
["drink"] = "drank",
["eat"] = "ate",
["fall"] = "fell",
["feel"] = "felt",
["find"] = "found",
["fly"] = "flew",
["forget"] = "forgot",
["get"] = "got",
["give"] = "gave",
["go"] = "went",
["have"] = "had",
["know"] = "knew",
["leave"] = "left",
["make"] = "made",
["meet"] = "met",
["put"] = "put",
["read"] = "read", -- Note: past form is pronounced as 'red'
["ride"] = "rode",
["ring"] = "rang",
["run"] = "ran",
["say"] = "said",
["see"] = "saw",
["sell"] = "sold",
["send"] = "sent",
["sing"] = "sang",
["sit"] = "sat",
["speak"] = "spoke",
["spend"] = "spent",
["take"] = "took",
["teach"] = "taught",
["tell"] = "told",
["think"] = "thought",
["understand"] = "understood",
["win"] = "won",
["write"] = "wrote"
}
-- Function to check if a string contains only English letters and optional spaces or apostrophes
local function isEnglishText(text)
return text:match("^[A-Za-z '%-]+$") ~= nil
end
-- Function to get the past simple form of a verb
function p.main(frame)
-- Get the verb from the arguments or use the page name
local verb = frame.args[1] or frame:getTitle():getText()
-- Check if the verb is valid English text
if not isEnglishText(verb) then
return "<span style='color:red; font-weight:bold;'>خطأ: يجب أن يكون الإدخال نصًا باللغة الإنجليزية فقط.</span>"
end
-- Check for irregular verbs
if irregularVerbs[verb] then
return irregularVerbs[verb]
end
-- Handle regular verbs (adding -ed)
if verb:sub(-1) == "e" then
return verb .. "d"
elseif verb:sub(-1) == "y" and not (verb:sub(-2, -2):match("[aeiou]")) then
return verb:sub(1, -2) .. "ied"
else
return verb .. "ed"
end
end
return p