DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
local_ai_classify.cpp

This example shows how to classify a document into one of several categories using a built-in local AI model.

#include "docwire.h"
#include <sstream>
int main(int argc, char* argv[])
{
using namespace docwire;
std::stringstream out_stream;
try
{
std::filesystem::path("document_processing_market_trends.odt") | content_type::detector{} | office_formats_parser{} | plain_text_exporter() | local_ai::model_chain_element("Classify to one of the following categories and answer with exact category name: agreement, invoice, report, legal, user manual, other:\n\n") | out_stream;
ensure(out_stream.str()) == "report";
}
catch (const std::exception& e)
{
std::cerr << errors::diagnostic_message(e) << std::endl;
return 1;
}
return 0;
}
DOCWIRE_CORE_EXPORT std::string diagnostic_message(const std::exception &e)
Generates a diagnostic message for the given nested exceptions chain.
The main namespace for the DocWire SDK.
Definition: ai_elements.h:19
ensure(const T &, const docwire::source_location &) -> ensure< T >
Deduction guide for the ensure class template.