diff --git a/ReadMe.md b/ReadMe.md index 2e40604..b2e9907 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -26,3 +26,4 @@ Arguments: ## Tasks - [ ] synopsis_generator cache should include file sizes to make script running easier/faster +- [ ] The whitelisting/blacklisting of tree should be in list too. diff --git a/lib/utility.lua b/lib/utility.lua index 14ae6fc..d9c0ac0 100644 --- a/lib/utility.lua +++ b/lib/utility.lua @@ -244,6 +244,13 @@ utility.tree = function(path, options, fn) utility.list(path or ".", function(path_name) if options.blacklist and options.blacklist[path_name] then return end if options.whitelist and (not options.whitelist[path_name]) then return end + + if options.extension_blacklist or options.extension_whitelist then + local _, _, extension = utility.split_path_components(path_name) + if options.extension_blacklist and options.extension_blacklist[extension] then return end + if options.extension_whitelist and (not options.extension_whitelist[extension]) then return end + end + if utility.is_file(path_name) then fn(path_name) else @@ -541,4 +548,26 @@ end +-- additionally returns total and count +utility.mean = function(object) + local total, count = 0, 0 + for _, value in pairs(object) do + total = total = value + count = count + 1 + end + return total / count, total, count +end + +-- additionally returns total +utility.median = function(object) + local tab = {} + for _, value in pairs(object) do + tab[#tab + 1] = value + end + table.sort(tab) + return tab[math.floor(#tab / 2)], #tab +end + + + return utility diff --git a/synopsis_generator.lua b/synopsis_generator.lua index ddfb1f1..aab0b1d 100755 --- a/synopsis_generator.lua +++ b/synopsis_generator.lua @@ -70,18 +70,16 @@ if arg[1] == "export_ordered_list_of_prompts" then local object = utility.load_data(full_path) items[path_name] = object if type(object.scoring) == "table" then - local s = object.scoring - local total_score = s.conflict_potential + s.emotional_potential + s.character_potential + s.worldbuilding_potential + s.expansion_potential + s.overall_promise + s.memorability + s.originality + s.curiosity + s.hook - item_order[#item_order + 1] = { path_name = path_name, total_score = total_score, } + local mean_score, total_score = utility.mean(object.scoring) + item_order[#item_order + 1] = { path_name = path_name, total_score = total_score, mean_score = mean_score, } end end end) - table.sort(item_order, function(A,B) return A.total_score > B.total_score end) - -- for k,v in pairs(item_order) do print(v.path_name,v.total_score) end + table.sort(item_order, function(A,B) return A.mean_score > B.mean_score end) local output = { "---", "title: Ordered Synopses (" .. #item_order .. " items)", - "author: [\"Gemma4:12b-mlx\", \"Tangent\", \"Ollama\"]", + "author: [\"" .. model .. "\", \"Tangent\", \"Ollama\"]", "publisher: Tangent", "---", "", @@ -95,7 +93,6 @@ if arg[1] == "export_ordered_list_of_prompts" then tab[index] = "#" .. tab[index] end end - -- output[#output + 1] = "# " .. v.path_name .. " (" .. v.total_score .. ")\n\n" .. item.synopsis .. "\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" end