Python API class rl3.Fact

From RL3 Wiki
Jump to: navigation, search

rl3.Fact class overview

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

constructor

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.

__del__

def __del__(self):

Delete a fact.

get_label

def get_label(self):

Get fact name (label).

Returns: string (fact label)

get_value

def get_value(self):

Get fact value.

Returns: string (fact value)

get_weight

def get_weight(self):

Get fact weight.

Returns: floating number (weight)

get_annotation_start

def get_annotation_start(self):

Get the start position of fact annotation.

Returns: numeric value (position in text field)

get_annotation_end

def get_annotation_end(self):

Get the end position of fact annotation.

Returns: numeric value (position in text field)

get_annotation

def get_annotation(self):

Get fact annotation.

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

has_factsheet

def has_factsheet(self):

Check whether a fact has a factsheet inside.

Returns: boolean

get_factsheet

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

to_json

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.