Module:Process ask query results 2
Documentation for this module may be created at Module:Process ask query results 2/doc
local p = {}
-- this code was developed in plainlist_processing_1_b.lua
function p.processData(frame)
local page_names_query_arg = frame.args["page_names_query"]
local full_query_arg = frame.args["full_query"]
local property_names_arg = frame.args["property_names_list"]
require("Module:String to array")
local page_names_array = string_to_array(page_names_query_arg, "#")
local property_names_array = string_to_array(property_names_arg, ",")
local source_page_positions = {}
-- build a table of the form {index: {page name, start pos, end pos}, ...} where "start pos" and "end pos" are the positions in the
-- in the full query response string of the starting and ending characters of the page name
local i = 1
local j = 1
while i <= #full_query_arg do
ch1, ch2 = string.find(full_query_arg, "__source_page_", i)
if ch1 ~= nil then
source_page_positions[j] = {ch1, ch2}
j = j + 1
i = ch2 + 1
else
i = #full_query_arg + 1
end
end
-- print it out so that I check whether it was done correctly
local output_string_1 = "<ul>"
for i, v in ipairs(source_page_positions) do
output_string_1 = output_string_1 .. "<li>" .. i .. ": {" .. v[1] .. ", " .. v[2] .. "}" .. "</li>"
end
output_string_1 = output_string_1 .. "</ul>"
return "<ul><li>" .. type(page_names_array) .. "</li><li>" .. type(property_names_array) .. "</li><li>" .. property_names_arg .. "</li></ul>" .. output_string_1
end
return p