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: Union[List[str], Dict[str, Callable[[Any, Union[str, pathlib.Path]], None]], None] = None, output_dir: Optional[str] = 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() → collections.abc.KeysView[source]

Return all keys of the resources.

get(key: str)[source]

Get the corresponding resource by specifying the key.

update(**kwargs)[source]

Update the resources.

remove(key: str)[source]

Remove the corresponding resource by specifying the key.

load(keys: Union[List[str], Dict[str, Callable[[Union[str, pathlib.Path]], None]]], path: Optional[str] = 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.