Module:auto cat: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 33: Line 33:
-- given data
-- given data
local function to_pattern(pattern, categories)
local function to_pattern(pattern, categories)
     return {"^" .. capitalize(pattern) .. "$", categories}
     return {"^" .. pattern .. "$", categories}
end
end


Line 58: Line 58:
                    table.insert(p_out_cats, capitalize(replace(p_cat, {["%%l"] = l_data.name, ["%%u"] = l2_data.name, ["%%ps"] = pluralize(pos), ["%%p"] = pos})))
                    table.insert(p_out_cats, capitalize(replace(p_cat, {["%%l"] = l_data.name, ["%%u"] = l2_data.name, ["%%ps"] = pluralize(pos), ["%%p"] = pos})))
                    end
                    end
                    table.insert(out_patterns, to_pattern(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["%%u"] = sanitize(l2_data.name), ["%%ps"] = pluralize(pos), ["%%p"] = pos}), p_out_cats))
                    table.insert(out_patterns, to_pattern(capitalize(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["%%u"] = sanitize(l2_data.name), ["%%ps"] = pluralize(pos), ["%%p"] = pos}), p_out_cats)))
                end
                end
            end
            end
Line 66: Line 66:
            table.insert(p_out_cats, capitalize(replace(p_cat, {["%%l"] = l_data.name, ["%%ps"] = pluralize(pos), ["%%p"] = pos})))
            table.insert(p_out_cats, capitalize(replace(p_cat, {["%%l"] = l_data.name, ["%%ps"] = pluralize(pos), ["%%p"] = pos})))
            end
            end
            table.insert(out_patterns, to_pattern(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["%%ps"] = pluralize(pos), ["%%p"] = pos}), p_out_cats))
            table.insert(out_patterns, to_pattern(capitalize(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["%%ps"] = pluralize(pos), ["%%p"] = pos}), p_out_cats)))
        end
        end
     end
     end
Line 77: Line 77:
                    table.insert(p_out_cats, replace(p_cat, {["%%l"] = l_data.name, ["%%u"] = l2_data.name}))
                    table.insert(p_out_cats, replace(p_cat, {["%%l"] = l_data.name, ["%%u"] = l2_data.name}))
                    end
                    end
                    table.insert(out_patterns, to_pattern(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["%%u"] = sanitize(l2_data.name)}), p_out_cats))
                    table.insert(out_patterns, to_pattern(capitalize(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["%%u"] = sanitize(l2_data.name)}), p_out_cats)))
                end
                end
            end
            end
Line 85: Line 85:
            table.insert(p_out_cats, replace(p_cat, {["%%l"] = l_data.name}))
            table.insert(p_out_cats, replace(p_cat, {["%%l"] = l_data.name}))
            end
            end
            table.insert(out_patterns, to_pattern(replace(p_lua, {["%%l"] = sanitize(l_data.name)}), p_out_cats))
            table.insert(out_patterns, to_pattern(capitalize(replace(p_lua, {["%%l"] = sanitize(l_data.name)}), p_out_cats)))
        end
        end
         end
         end
Line 107: Line 107:
             table.insert(p_out_cats, capitalize(replace(p_cat, {["%%ps"] = pluralize(pos), ["%%p"] = pos})))
             table.insert(p_out_cats, capitalize(replace(p_cat, {["%%ps"] = pluralize(pos), ["%%p"] = pos})))
         end
         end
         table.insert(out_patterns, to_pattern(replace(p_lua, {["%%ps"] = pluralize(pos), ["%%p"] = pos}), p_out_cats))
         table.insert(out_patterns, to_pattern(capitalize(replace(p_lua, {["%%ps"] = pluralize(pos), ["%%p"] = pos}), p_out_cats)))
end
end
end
end