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[])
{
std::stringstream out_stream;
try
{
std::filesystem::path("data_processing_definition.doc") | content_type::detector{} | office_formats_parser{} | plain_text_exporter() | local_ai::model_chain_element("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)
{
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.
ensure(const T &, const docwire::source_location &) -> ensure< T >
Deduction guide for the ensure class template.