engine
This module contains the Emtellipro class and related classes for
interacting with the engine.
Module Contents
Classes
Functions
Data
FEATURES
CATEGORIES
API
emtellipro.engine.FEATURES
These are the complete list of available features.
emtellipro.engine.CATEGORIES
This is a mapping from category names to subcategories that are supported by this version of the emtelliPro SDK.
emtellipro.engine.ResultFutureStatus
Bases: object
This class is returned by ResultFuture.done, and contains information about the processing status of the job.
Note: this class implements __bool__ with the same semantics as
.done
Attributes:
done: whether the job has completed processing (can either be a successful, failed, or cancelled job; both are considered “done”)success: whether the job has completed successfully; note if the job is not done, this will be falseprogress: a number in [0, 1] representing the percentage of completed documentsstate: The value of the “state” field in the status returned by emtelliPro.
ResultFutureStatus.__bool__
emtellipro.engine.Result
Bases: object
This is the result from the engine containing parsed annotated docs, and other information about this processing run.
It is possible to iterate over this object, which will have the effect of iterating over the annotated docs.
Attributes:
task_id: The task ID for the task that produced this result.engine_version: The engine version returned by the engine.annotated_docs: A list ofAnnotatedDocumentinstances.raw: The unparsed original text that was returned by the engine.json: The parsed JSON for the result class.
Initialization
Result.task_id
Result.engine_version
Result.raw
Result.annotated_docs
Type: typing.List[AnnotatedDocument]
Result.json
Return type: dict
Result.fail
Create a Result instance where all the annotated documents are failed.
Parameters:
The task ID to insert into the fake result.
The engine version to insert in to the fake result.
The input docs that were submitted for this result. Only the ID and category/subcategory attributes are used to generate fake annotated document objects.
The JSON string to set at the ‘raw’ attribute.
Result.__iter__
emtellipro.engine.ResultFuture
Bases: object
This class mimics asyncio.Future and concurrent.futures.Future in terms of some of the available methods and semantics, but you cannot await or yield from any of its methods.
ResultFuture instances will be created by the Emtellipro and should not be created directly.
Note: ResultFuture objects are pickle-able.
Attributes:
task_id: The task ID as returned by the emtelliPro API. This can be stored and then used withEmtellipro.check_task()to recreate a ResultFuture instance.
Initialization
Parameters:
- task_id: a string representing the ID of the task submitted to the server.
- api: instance of _api.Api used for retrieving results and checking status.
- num_docs: the number of documents this result future is handling, if known.
ResultFuture.num_docs
The total number of documents submitted for processing.
ResultFuture.cancel
Cancel the task being represented by this ResultFuture.
ResultFuture.cancelled
Check if the task is cancelled.
Returns:
The cancellation status of the task (a boolean).
ResultFuture.done
Check if task is done (i.e. cancelled, successful, failed).
Parameters:
Returns:
The processing status, which can be used in an if statement since
it will evaluate to True if the task is done.
Return type: ResultFutureStatus
when checking the status of the job, the server may keep the connection open up to this amount of time or until the job is completed, whichever is quicker.
ResultFuture.result
Retrieve the results of the task.
The response from emtelliPro is cached, so calling this multiple times will not lead to multiple calls to emtelliPro.
If you’d like the unparsed raw API response, use .raw_result()
instead.
Returns:
The result of processing the task.
Raises:
exc.TaskFailedError:
The task has a status of ‘failure’.
exc.TaskNotFoundError:
The task is not found on the server.
Return type: Result
ResultFuture.engine_version
The engine version as returned in the result. This can only be accessed
after calling .result(); accessing this attribute before will
result in an AttributeError.
ResultFuture.raw_result
Return the raw text result from the API, unparsed. The text is cached, so multiple calls to this method will not result in multiple API calls.
If you’d like the parsed result, use .result() instead.
Raises:
exc.TaskFailedError:
The task has a status of ‘failure’.
exc.TaskNotFoundError:
The task is not found on the server.
emtellipro.engine.Emtellipro
Bases: object
This is the main way of interacting with the API. It handles all the necessary details for submitting documents for processing and retrieving results.
Example:
Attributes:
server: The emtelliPro server URL.
Initialization
Parameters:
- server: The URL of the server to connect to. If you wish to use the
default global server, you should pass
Emtellipro.DEFAULT_SERVERhere. - auth: The authentication keys; this must be a tuple of (access key, shared secret) for HMAC based authentication, or a single string for API-key based authentication.
New in version 6.10.
Support for API key authentication.
- max_retries (optional): the number of times to retry failed API requests; there may be failures due to network issues, so this should be a positive integer.
- extra_headers: Any extra headers to include in all requests.
Emtellipro.DEFAULT_MAX_RETRIES
Value: 5
Emtellipro.DEFAULT_SERVER
The default global server that can be passed as the argument to server.
Value: https://nlp.emtelligent.com
Emtellipro.submit
Submit documents for annotating.
Parameters:
An iterable of Document objects to be annotated. The
category and subcategory attributes of each document
will be validated against CATEGORIES.
A list of features to enable in the processing of the documents. Default of None means “enable all”.
See FEATURES for complete list of options.
String containing the document type to be used for all
documents which don’t specify their own type. Default is
'plain'
Returns:
A ResultFuture object representing the current status of the annotation process.
This will not check that the submitted batch of documents is too
big. You should use batch_documents to
split up a large number of documents into smaller batches that do
not go over the maximum submission limit.
Return type: ResultFuture
Emtellipro.check_task
Create a ResultFuture instance from a task_id.
Parameters:
Returns:
A new future object that can be used to monitor processing status and retrieve results.
Raises:
exc.TaskNotFoundError:
Raised if the task ID wasn’t found on the server.
Return type: ResultFuture
the task ID. This is available on
ResultFuture instances as the .task_id
attribute, however it is simply the task ID as returned by the
emtelliPro API’s /submit call, so that can be provided
regardless of how it was obtained (e.g. if you obtained it from
our Java SDK, that will work, too).
Emtellipro.user
The user information as known by the Emtellipro server.
Return type: User

