MCPcopy Create free account
hub / github.com/davisking/dlib / read_enwiki

Function read_enwiki

examples/slm_advanced_train_ex.cpp:515–529  ·  view source on GitHub ↗

Function to read the "enwiki" file (entire or portion)

Source from the content-addressed store, hash-verified

513
514// Function to read the "enwiki" file (entire or portion)
515std::string read_enwiki(const std::string& filepath, size_t max_bytes = 0) {
516 std::ifstream file(filepath, std::ios::binary);
517 if (!file) {
518 throw std::runtime_error("Cannot open enwiki file: " + filepath);
519 }
520 size_t file_size = get_file_size(filepath);
521
522 // If max_bytes is specified and valid, limit the reading
523 size_t bytes_to_read = (max_bytes > 0 && max_bytes < file_size) ? max_bytes : file_size;
524
525 std::string content(bytes_to_read, ' ');
526 file.read(&content[0], bytes_to_read);
527
528 return content;
529}
530
531// Function to verify byte-for-byte matching with detailed error reporting
532bool verify_match(const std::string& original, const std::string& generated) {

Callers 1

mainFunction · 0.85

Calls 2

get_file_sizeFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected