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
Loading...
Searching...
No Matches
local_ai_find.cpp

This example demonstrates how to find a specific sentence in a document using a built-in local AI model.

#include "docwire.h"
#include <filesystem>
#include <iostream>
#include <sstream>
int main(int argc, char* argv[])
{
using namespace docwire;
std::stringstream out_stream;
try
{
std::filesystem::path("data_processing_definition.doc") | content_type::detector{} | office_formats_parser{} | plain_text_exporter() | ai::local::task("Find sentence about \"data conversion\" in the following text:\n\n") | out_stream;
ensure(out_stream.str()).is_one_of({
"Data processing refers to the activities performed on raw data to convert it into meaningful information.",
"Data processing is the activities performed on raw data to convert it into meaningful information."
});
}
catch (const std::exception& e)
{
std::cerr << errors::diagnostic_message(e) << std::endl;
return 1;
}
return 0;
}
Content type detection chain element.
A utility for creating expressive, exception-throwing assertions in a fluent style.
Definition ensure.h:56
void is_one_of(std::initializer_list< T > expected_values) const
Checks if the held value is present in a given set of values. Throws if it is not.
Definition ensure.h:167
A composite parser handling various office document formats.
Exports data to plain text format.
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