Python API class rl3.FactPathIterator

From RL3 Wiki
Jump to: navigation, search

rl3.FactPathIterator class description

The rl3.FactPathIterator class implements the necessary set of functions that can be used in for/in loops to cycle through iterable objects:

# iterate and print all "continent" annotations
for i in factsheet.get_facts_by_path("*.fname"):
    print i.get_value()


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


def is_end(self):

Define whether an iterator has looked through all the items in a data structure.

Returns: a boolean


def next(self):

Obtain the next element in an iteration.

Returns: a reference to self


def get_label(self):

Get a fact name (label) when iterating.

Returns: a string


def get_value(self):

Get a fact value when iterating.

Returns: a string


def get_weight(self):

Get a fact weight when iterating.

Returns: a floating number


def get_annotation_start(self):

Get a fact annotation start (position in a text field) when iterating.

Returns: a number


def get_annotation_end(self):

Get a fact annotation end (position in a text field) when iterating.

Returns: a number


def get_annotation(self):

Get a fact annotation.

Returns: a tuple (a pair of numbers - annotation start and annotation end)


def has_factsheet(self):

Define whether a fact contains a factsheet when iterating.

Returns: a boolean


def get_factsheet(self):

Get a factsheet from a fact when iterating.

Returns: an rl3.Factsheet object or None if there is no factsheet


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

Save an associated Fact as a JSON string.

root_text: None if a fact 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.