Python API class rl3.Fact

From RL3 Wiki
Jump to: navigation, search

rl3.Fact class overview

rl3.Fact class members enable to manage Fact objects (created through the rl3.BaseEngine factory).
The get_factsheet() function should not be confused with similar functions in the rl3.FactIterator and rl3.FactPathIterator classes. For details, see below.


New Fact objects are created only through the BaseEngine class factory (refer to create_fact and create_simple_fact functions in classes derived from the rl3.BaseEngine class).

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


def __del__(self):

Delete a fact.


def get_label(self):

Get fact name (label).

Returns: string (fact label)


def get_value(self):

Get fact value.

Returns: string (fact value)


def get_weight(self):

Get fact weight.

Returns: floating number (weight)


def get_annotation_start(self):

Get the start position of fact annotation.

Returns: numeric value (position in text field)


def get_annotation_end(self):

Get the end position of fact annotation.

Returns: numeric value (position in text field)


def get_annotation(self):

Get fact annotation.

Returns: tuple (pair of annotation start and annotation end values)


def has_factsheet(self):

Check whether a fact has a factsheet inside.

Returns: boolean


def get_factsheet(self):

Get a factsheet from a fact. New empty factsheet will be created if there was no factsheet in fact object.

Returns: rl3.Factsheet object


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

Save Fact as JSON string.

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