exit when refreshing file list, better organization
This commit is contained in:
+18
-13
@@ -52,21 +52,10 @@ local generate_and_score = function(file_name, text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local export_ordered_list_of_prompts = function()
|
local export_ordered_list_of_prompts = function()
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
os.execute("mkdir -p PRIVATE_DATA/synopses")
|
|
||||||
|
|
||||||
if arg[1] == "refresh_file_list" then
|
|
||||||
print("Refresing file list...")
|
|
||||||
refresh_file_list()
|
|
||||||
end
|
|
||||||
|
|
||||||
if arg[1] == "export_ordered_list_of_prompts" then
|
|
||||||
local path = "PRIVATE_DATA/synopses"
|
local path = "PRIVATE_DATA/synopses"
|
||||||
local items = {}
|
local items = {}
|
||||||
local item_order = {}
|
local item_order = {}
|
||||||
|
|
||||||
utility.list(path, function(path_name)
|
utility.list(path, function(path_name)
|
||||||
local full_path = path .. utility.path_separator .. path_name
|
local full_path = path .. utility.path_separator .. path_name
|
||||||
if path_name:find("%.json") then
|
if path_name:find("%.json") then
|
||||||
@@ -78,7 +67,9 @@ if arg[1] == "export_ordered_list_of_prompts" then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
table.sort(item_order, function(A,B) return A.mean_score > B.mean_score end)
|
table.sort(item_order, function(A,B) return A.mean_score > B.mean_score end)
|
||||||
|
|
||||||
local output = {
|
local output = {
|
||||||
"---",
|
"---",
|
||||||
"title: Ordered Synopses (" .. #item_order .. " items)",
|
"title: Ordered Synopses (" .. #item_order .. " items)",
|
||||||
@@ -87,25 +78,39 @@ if arg[1] == "export_ordered_list_of_prompts" then
|
|||||||
"---",
|
"---",
|
||||||
"",
|
"",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v in pairs(item_order) do
|
for _, v in pairs(item_order) do
|
||||||
local item = items[v.path_name]
|
local item = items[v.path_name]
|
||||||
local text = item.synopsis
|
local text = item.synopsis
|
||||||
local tab = text:split("\n")
|
local tab = text:split("\n")
|
||||||
|
|
||||||
for index, line in ipairs(tab) do
|
for index, line in ipairs(tab) do
|
||||||
if line:sub(1, 1) == "#" then
|
if line:sub(1, 1) == "#" then
|
||||||
tab[index] = "#" .. tab[index]
|
tab[index] = "#" .. tab[index]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
output[#output + 1] = "# " .. v.path_name .. " (" .. v.total_score .. ")\n\n" .. table.concat(tab, "\n") .. "\n"
|
output[#output + 1] = "# " .. v.path_name .. " (" .. v.total_score .. ")\n\n" .. table.concat(tab, "\n") .. "\n"
|
||||||
output[#output + 1] = "## Scoring\n\n```json\n" .. json.encode(item.scoring, { indent = true, }) .. "\n```\n"
|
output[#output + 1] = "## Scoring\n\n```json\n" .. json.encode(item.scoring, { indent = true, }) .. "\n```\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
utility.write_file("PRIVATE_DATA/Ordered Synopses.md", table.concat(output, "\n"))
|
utility.write_file("PRIVATE_DATA/Ordered Synopses.md", table.concat(output, "\n"))
|
||||||
os.execute("pandoc \"PRIVATE_DATA/Ordered Synopses.md\" -o \"PRIVATE_DATA/Ordered Synopses.epub\"")
|
os.execute("pandoc \"PRIVATE_DATA/Ordered Synopses.md\" -o \"PRIVATE_DATA/Ordered Synopses.epub\"")
|
||||||
os.exit(0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
os.execute("mkdir -p PRIVATE_DATA/synopses")
|
||||||
|
|
||||||
|
if arg[1] == "refresh_file_list" then
|
||||||
|
print("Refresing file list...")
|
||||||
|
refresh_file_list()
|
||||||
|
os.exit(0)
|
||||||
|
elseif arg[1] == "export_ordered_list_of_prompts" then
|
||||||
|
export_ordered_list_of_prompts()
|
||||||
|
os.exit(0)
|
||||||
|
end
|
||||||
|
|
||||||
print(#files .. " files to select from.")
|
print(#files .. " files to select from.")
|
||||||
if #files == 0 then
|
if #files == 0 then
|
||||||
print("Run \"./synopsis_generator.lua refresh_file_list\" first.")
|
print("Run \"./synopsis_generator.lua refresh_file_list\" first.")
|
||||||
|
|||||||
Reference in New Issue
Block a user