Python API class rl3.Factsheet

From RL3 Wiki
Jump to: navigation, search

rl3.Factsheet class overview

The class possesses members for management of Factsheet objects by means of:


New Factsheet objects are created only through the BaseEngine class factory (refer to create_factsheet , derive_factsheet and create_factsheet_from_json functions in classes derived from the rl3.BaseEngine class).

New Factsheet objects must not be created through the __init__ constructor directly.


def __del__(self):

Delete a factsheet.


def assert_fact(self, fact):

Assert a fact to a factsheet.
To use the function, a new fact object should be created first (refer to rl3.BaseEngine factory).

fact: an rl3.Fact object


def assert_simple_fact(self, label, value, weight=1.0):

Assert a simple fact to a factsheet with omitting the creation of a fact object.

label: a string name (label) of a fact
value: a string (text) value
weight: a floating number (fact weight)


def retract_fact(self, fact_iterator):

Remove a fact from a factsheet.

fact_iterator: an rl3.FactIterator object


def retract_facts(self, label):

Remove multiple facts (by name) from a factsheet.

label: fact object name (label)


def has_fact(self, label):

Check whether a fact is in a factsheet.

label: fact name (label)
Returns: a boolean


def get_facts_count(self, label=None):

Count facts (by name).

label: fact name (label)
Returns: a number


def get_facts(self, label=None):

Get facts by label.

label: fact name (label)
Returns: an rl3.FactIterator object


def get_facts_by_path(self, path):

Get facts by path.

path: fact path
Returns: an rl3.FactPathIterator object


def __len__(self):

Get the number of items (facts) in a factsheet.

Returns: a number


def to_json(self, root_text = None, include_text = True):

Save a Factsheet as a JSON string.

root_text: None if a factsheet should be considered as an independent / self-containing structure. By default is None.
include_text True if a text field should be included in the output; False otherwise. By default is True.
Returns: a JSON string.