CPP API class rl3::BaseEngine

From RL3 Wiki
Jump to: navigation, search


Class member functions

is_debug_mode

bool is_debug_mode();

Check if debug mode is enabled.

Returns: true if a debug mode is enabled, false otherwise

set_debug_mode

void set_debug_mode(bool mode);

Enable or disable debug mode.

mode: true to enable debug mode, false to disable debug mode
Returns: nothing

is_update_mode

bool is_update_mode();

Check if update mode is enabled.

Returns: true if an update mode is enabled, false otherwise

set_update_mode

void set_update_mode(bool mode);

Enable or disable update mode.

mode: true to enable update mode, false to disable update mode
Returns: nothing

load

void load(const std::string& file_path, bool silent = true);

Load a compiled engine model from file.

file_path: path to model file
silent: true (default) to suppress system messages, false otherwise
Returns: nothing

create_sharedtext functions

std::shared_ptr<rl3::SharedText> create_sharedtext(const UnicodeString& text);

Create a SharedText structure (used with multiple facts found in different parts of one text instance).
The text parameter is a unicode string.

text: a reference to the text to be used as shared
Returns: a shared pointer to a new SharedText object
std::shared_ptr<rl3::SharedText> create_sharedtext(const std::string& text);

Create a SharedText structure (used with multiple facts found in different parts of one text instance).
The text parameter is a UTF-8 string.

text: a reference to the text to be used as shared
Returns: a shared pointer to a new SharedText object
std::shared_ptr<rl3::SharedText> create_sharedtext(const char* text);

Create a SharedText structure (used with multiple facts found in different parts of one text instance).
The text parameter is a character pointer.

text: a pointer to the first character in the text to be used as shared
Returns: a shared pointer to a new SharedText object

create_fact functions

std::shared_ptr<rl3::Fact> create_fact(const UnicodeString& label, const UnicodeString& value, double weight = 1.0);

Create a new simple fact (i.e. a fact not linked to a SharedText instance).
The label and value parameters are unicode strings.

label: a reference to the name (label) of a fact
value: a reference to the fact value
weight: fact weight
Returns: a shared pointer to a new Fact object
std::shared_ptr<rl3::Fact> create_fact(const std::string& label, const std::string& value, double weight = 1.0);

Create a new simple fact (i.e. a fact not linked to a SharedText instance).
The label and value parameters are UTF-8 strings.

label: a reference to the name (label) of a fact
value: a reference to the fact value
weight: fact weight
Returns: a shared pointer to a new Fact object
std::shared_ptr<rl3::Fact> create_fact(const char* label, const char* value, double weight = 1.0);

Create a new simple fact (i.e. a fact not linked to a SharedText instance).
The label and value parameters are character pointers.

label: a pointer to the first character in the name (label) of a fact
value: a pointer to the first character in the fact value
weight: fact weight
Returns: a shared pointer to a new Fact object
std::shared_ptr<rl3::Fact> create_fact(const UnicodeString& label, std::shared_ptr<rl3::SharedText> text, double weight = 1.0, unsigned int annotation_start = 0, unsigned int annotation_end = 0);

Create a new shared fact (i.e. a fact linked to a SharedText instance).
The label parameter is a unicode string.

label: a reference to the name (label) of a fact
text: a shared pointer to a SharedText instance
weight: fact weight
annotation_start: fact start position in the text
annotation_end: fact end position in the text
Returns: a shared pointer to a new Fact object
std::shared_ptr<rl3::Fact> create_fact(const std::string& label, std::shared_ptr<rl3::SharedText> text, double weight = 1.0, unsigned int annotation_start = 0, unsigned int annotation_end = 0);

Create a new shared fact (i.e. a fact linked to a SharedText instance).
The label parameter is a UTF-8 string.

label: a reference to the name (label) of a fact
text: a shared pointer to a SharedText instance
weight: fact weight
annotation_start: fact start position in the text
annotation_end: fact end position in the text
Returns: a shared pointer to a new Fact object
std::shared_ptr<rl3::Fact> create_fact(const char* label, std::shared_ptr<rl3::SharedText> text, double weight = 1.0, unsigned int annotation_start = 0, unsigned int annotation_end = 0);

Create a new shared fact (i.e. a fact linked to a SharedText instance).
The label parameter is a character pointer.

label: a pointer to the first character in the name (label) of a fact
text: a shared pointer to a SharedText instance
weight: fact weight
annotation_start: fact start position in the text
annotation_end: fact end position in the text
Returns: a shared pointer to a new Fact object
std::shared_ptr<rl3::Fact> create_fact_from_json(const std::string& json, std::shared_ptr<rl3::SharedText> root_text = NULL);

Create a new fact from JSON string.

json: an input JSON string
root_text: NULL if fact should be considered as independent / self-containing structure
Returns: a shared pointer to a new Fact object

create_factsheet functions

std::shared_ptr<rl3::Factsheet> create_factsheet();

Create a new factsheet.

Returns: a shared pointer to a new Factsheet object
std::shared_ptr<rl3::Factsheet> create_factsheet(std::shared_ptr<rl3::Factsheet>, bool local = false);

TBD: Clarify. Must be similar in function to rl3_factsheet_derive (in C API)

std::shared_ptr<rl3::Factsheet> load_factsheet(const std::string& file_path);

Load a factsheet from file.

file_path: a path to the file with a factsheet
Returns: a shared pointer to a new Factsheet object
std::shared_ptr<rl3::Factsheet> create_factsheet_from_json(const std::string& json, std::shared_ptr<rl3::SharedText> root_text = NULL);

Create a new factsheet from JSON string.

json: an input JSON string
root_text: NULL if factsheet should be considered as independent / self-containing structure
Returns: a shared pointer to a new Factsheet object
std::shared_ptr<rl3::Factsheet> create_factsheet_from_html(const std::string& html);

Create a new factsheet from HTML string.

html: an input HTML string
Returns: a shared pointer to a new Factsheet object

run functions

bool run(std::shared_ptr<rl3::Factsheet> factsheet);

Execute the engine on input factsheet and update it with new (resulting) facts.

factsheet: input and output factsheet
Returns: true if new fact were asserted, false otherwise
bool run(std::shared_ptr<rl3::Factsheet> premises, std::shared_ptr<rl3::Factsheet> conclusions);

Execute the engine on an input factsheet and add resulting facts to an output factsheet.

premises: input factsheet
conclusions: output factsheet
Returns: true if new fact were asserted, false otherwise

Helper functions

UnicodeString make_simple_annotation_def(const UnicodeString& target, const UnicodeString& pattern, const UnicodeString& name);

Create a simple (i.e. uncompouned) annotation pattern. All parameters are unicode strings.

target: targeted text
pattern: a pattern to be searched
name: fact name (label)
Returns: annotation definition (Unicode String)
string make_simple_annotation_def(const std::string& target, const std::string& pattern, const std::string& name);

Create a simple (i.e. uncompouned) annotation pattern. All parameters are UTF-8 strings.

target: targeted text
pattern: a pattern to be searched
name: fact name (label)
Returns: annotation definition (UTF-8 string)
string make_simple_annotation_def(const char* target, const char* pattern, const char* name);

Create a simple (i.e. uncompouned) annotation pattern. All parameters are character pointers.

target: targeted text
pattern: a pattern to be searched
name: fact name (label)
Returns: annotation definition (UTF-8 string)
UnicodeString html_to_text(const std::string& html, const std::string& section = "body");

Parse an HTML section

html: an input HTML string
section: a section to be extracted (body, title, description, keywords, abstract, author, copyright, publisher, classification, rating, coverage, category, pathway, apath, tlinks, hidden, frame_src, link_href, ads)
Returns: a parsed HTML section
string html_to_text_str(const std::string& html, const std::string& section = "body");

Parse an HTML section

html: an input HTML string
section: a section to be extracted (body, title, description, keywords, abstract, author, copyright, publisher, classification, rating, coverage, category, pathway, apath, tlinks, hidden, frame_src, link_href, ads)
Returns: a parsed HTML section