| 72 | } |
| 73 | |
| 74 | nlohmann::json create_config(std::filesystem::path ifile, |
| 75 | std::filesystem::path ofile, |
| 76 | std::optional<std::vector<int>> pages=std::nullopt, |
| 77 | std::filesystem::path pdf_resource_dir="../docling_parse/pdf_resources/") |
| 78 | { |
| 79 | nlohmann::json config = nlohmann::json::object({}); |
| 80 | |
| 81 | auto data = nlohmann::json::object({}); |
| 82 | data["pdf-resource-directory"] = pdf_resource_dir; |
| 83 | |
| 84 | auto tasks = nlohmann::json::array({}); |
| 85 | { |
| 86 | auto task = nlohmann::json::object({}); |
| 87 | task["filename"] = ifile; |
| 88 | |
| 89 | if(ofile.string()!="") |
| 90 | { |
| 91 | task["output"] = ofile; |
| 92 | } |
| 93 | |
| 94 | if(pages.has_value()) |
| 95 | { |
| 96 | task["page-numbers"] = *pages; |
| 97 | } |
| 98 | |
| 99 | tasks.push_back(task); |
| 100 | } |
| 101 | |
| 102 | config["data"] = data; |
| 103 | config["files"] = tasks; |
| 104 | |
| 105 | return config; |
| 106 | } |
| 107 | |
| 108 | int main(int argc, char* argv[]) { |
| 109 | int orig_argc = argc; |