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_6.cpp

[example_cpp]

[example_cpp]

#include <algorithm>
#include <iostream>
#include <memory>
#include "parser.h"
#include "parser_builder.h"
#include "plain_text_writer.h"
int main(int argc, char* argv[])
{
auto parser_manager = std::make_shared<doctotext::ParserManager>(); // Create parser manager (load parsers)
std::string path = argv[1];
auto parser_builder = parser_manager->findParserByExtension(path); // get the parser builder by extension
doctotext::PlainTextWriter plain_text_writer; // create a plain text writer
plain_text_writer.write_header(std::cout); // write the header to the output stream
if (parser_builder) // if parser builder exists
{
(*parser_builder)->withParserManager(parser_manager) // set the parser manager
.build(path) // build the parser
->addOnNewNodeCallback([](doctotext::Info &info) // add a callback function to filter by subject text
{
if (info.tag_name ==
doctotext::StandardTag::TAG_MAIL) // if current node is mail
{
auto subject = info.getAttributeValue<std::string>(
"subject"); // get the subject attribute
if (subject) // if subject attribute exists
{
if (subject->find("Hello") != std::string::npos) // if subject contains "Hello"
{
info.skip = true; // skip the current node
}
}
}
})
.addOnNewNodeCallback([&plain_text_writer](
doctotext::Info &info) // add callback function to write the parsed text to the output stream
{
plain_text_writer.write_to(info, std::cout); // write the node to the output stream
})
.parse(); // start the parsing process
}
plain_text_writer.write_footer(std::cout); // write the footer to the output stream
return 0;
}
void write_footer(std::ostream &stream) const override
Write footer for plain text format.
void write_to(const doctotext::Info &info, std::ostream &stream) const override
Converts text from callback to plain text format.
static const std::string TAG_MAIL
Tag for mail. Attributes: "subject": std::string, "date": uint (unix timestamp).
Definition: parser.h:82
std::string tag_name
tag name
Definition: parser.h:100