DocWire DocToText - Powered by Silvercoders 5.0.5
A multifaceted, data extraction software development toolkit that converts all sorts of files to plain text and html. Written in C++, this data extraction tool has a parser able to convert PST & OST files along with a brand new API for better file processing. To enhance its utility, DocToText, as a data extraction tool, can be integrated with other data mining and data analytics applications. It comes equipped with a high grade, scriptable and trainable OCR that has LSTM neural networks based character recognition. This document parser is able to extract metadata along with annotations and supports a list of formats that include: DOC, XLS, XLSB, PPT, RTF, ODF (ODT, ODS, ODP), OOXML (DOCX, XLSX, PPTX), iWork (PAGES, NUMBERS, KEYNOTE), ODFXML (FODP, FODS, FODT), PDF, EML, HTML, Outlook (PST, OST), Image (JPG, JPEG, JFIF, BMP, PNM, PNG, TIFF, WEBP) and DICOM (DCM)
example_5.cpp
1
2#include <algorithm>
3#include <iostream>
4#include <memory>
5
6#include "parser.h"
7#include "parser_builder.h"
8#include "plain_text_writer.h"
9
13int main(int argc, char* argv[])
14{
15 doctotext::ParserManager parser_manager; // Create parser manager (load parsers)
16 std::string path = argv[1];
17 auto parser_builder = parser_manager.findParserByExtension(path); // get the parser builder by extension
18 auto plain_text_writer = std::make_shared<doctotext::PlainTextWriter>(); // create a plain text writer
19 plain_text_writer->write_header(std::cout); // write the header to the output stream
20 if (parser_builder) // if parser builder exists
21 {
22 (*parser_builder)->build(path) // build the parser
23 ->addOnNewNodeCallback([&plain_text_writer](doctotext::Info &info) // add a callback function
24 {
25 plain_text_writer->write_to(info,
26 std::cout); // write the node to the output stream
27 })
28 .parse(); // start the parsing process
29 }
30 plain_text_writer->write_footer(std::cout); // write the footer to the output stream
31 return 0;
32}
33
Parser manager class. Loads all available parsers and provides access to them.
std::optional< ParserBuilder * > findParserByExtension(const std::string &file_name) const
Returns parser builder for given extension type or nullopt if no parser is found.