| 43 | } |
| 44 | |
| 45 | std::string normalize_text_as_paragraph(const std::string & text) { |
| 46 | std::string normalized; |
| 47 | bool in_space = false; |
| 48 | for (unsigned char ch : text) { |
| 49 | if (std::isspace(ch)) { |
| 50 | in_space = !normalized.empty(); |
| 51 | continue; |
| 52 | } |
| 53 | if (in_space) { |
| 54 | normalized.push_back(' '); |
| 55 | in_space = false; |
| 56 | } |
| 57 | normalized.push_back(static_cast<char>(ch)); |
| 58 | } |
| 59 | return normalized; |
| 60 | } |
| 61 | |
| 62 | std::string read_plain_text_batch_file(const std::filesystem::path & path) { |
| 63 | return normalize_text_as_paragraph(read_text_file(path)); |
no test coverage detected