Common

Exceptions

class forte.common.PackIndexError[source]

Raise this error when there is a problem accessing the indexes pack data.

class forte.common.IncompleteEntryError[source]

Raise this error when the entry is not complete.

class forte.common.EntryNotFoundError[source]

Raise this error when the entry is not found in the data pack.

Resources

class forte.common.Resources(**kwargs)[source]

The Resources object is a global registry used in the pipeline. Objects defined as Resources will be passed on to the processors in the pipeline for initialization.

save(keys=None, output_dir=None)[source]

Save the resources specified by keys in binary format.

Parameters
  • keys (optional) –

    list or dict

    • If keys is a list, the objects corresponding to those keys are saved

    • If keys is a dict mapping from a key to a serialize function, then the serialize function will be used to save the object corresponding to that key

    • If keys is None, all objects in this resource will be saved.

  • output_dir (optional) – str A directory specifying the location to save the resources.

keys()[source]

Return all keys of the resources.

contains(key)[source]

Return whether the specified key exists.

get(key)[source]

Get the corresponding resource by specifying the key.

update(**kwargs)[source]

Update the resources.

remove(key)[source]

Remove the corresponding resource by specifying the key.

load(keys, path=None)[source]

Load the resources specified by keys.

Parameters
  • keys

    list or dict

    • If keys is a list, the objects corresponding to those keys are loaded

    • If keys is a dict mapping from a key to a deserialize function, then the deserialize function will be used to load the object corresponding to that key

  • path (optional) – str A directory specifying the location to load the resources from.