| 22 | }; |
| 23 | |
| 24 | class DocumentProcessor { |
| 25 | public: |
| 26 | explicit DocumentProcessor(const ProcessorConfig& config = {}); |
| 27 | ~DocumentProcessor(); |
| 28 | |
| 29 | // Process a single PDF → chunks |
| 30 | std::vector<DocumentChunk> process_pdf(const std::string& pdf_path); |
| 31 | |
| 32 | // Process a single .docx → chunks |
| 33 | std::vector<DocumentChunk> process_docx(const std::string& docx_path); |
| 34 | |
| 35 | // Process a single file (auto-detects type by extension) |
| 36 | std::vector<DocumentChunk> process_file(const std::string& file_path); |
| 37 | |
| 38 | // Process all supported files in a directory (recursive) |
| 39 | std::vector<DocumentChunk> process_directory(const std::string& dir_path); |
| 40 | |
| 41 | // Process a path that could be a file or directory |
| 42 | std::vector<DocumentChunk> process_path(const std::string& path); |
| 43 | |
| 44 | // Process raw text (for non-PDF sources) |
| 45 | std::vector<DocumentChunk> process_text( |
| 46 | const std::string& text, const std::string& source_name); |
| 47 | |
| 48 | private: |
| 49 | ProcessorConfig config_; |
| 50 | |
| 51 | // Extract text from PDF using poppler (pdftotext) |
| 52 | std::string extract_pdf_text(const std::string& path); |
| 53 | |
| 54 | // Extract text from .docx (Office Open XML) by unzipping word/document.xml |
| 55 | std::string extract_docx_text(const std::string& path); |
| 56 | |
| 57 | // Semantic chunking: split on paragraph/section boundaries |
| 58 | std::vector<DocumentChunk> semantic_chunk( |
| 59 | const std::string& text, const std::string& source); |
| 60 | |
| 61 | // Detect section boundaries |
| 62 | bool is_section_boundary(const std::string& line) const; |
| 63 | |
| 64 | // Rough token count estimation (~4 chars per token) |
| 65 | int estimate_tokens(const std::string& text) const; |
| 66 | }; |
| 67 | |
| 68 | } // namespace rastack |
nothing calls this directly
no outgoing calls
no test coverage detected