Quickstart Code Example

Annotate a document and read the entities back — in Python

This page submits one document with the Python SDK and reads the coded entities out of the result. It is the shortest path from an API key to structured output; the Quickstart covers the same ground from the command line, and Building your own client goes deeper.

Install the SDK and set your key in the environment:

$pip install emtellipro
$export EMTELLIPRO_API_KEY='...'

Create a client

The SDK takes the server URL and your credentials. A single string is an API key; a (access key, shared secret) tuple selects HMAC authentication instead.

Pass the server URL explicitly, as below. Do not use Emtellipro.DEFAULT_SERVER — the value compiled into the SDK is api.emtelligent.com, which is deprecated and no longer answers.

1import os
2
3from emtellipro import Emtellipro
4
5client = Emtellipro(
6 "https://api.us.emtelligent.com:50001",
7 os.environ["EMTELLIPRO_API_KEY"],
8)

Submit a document

Every document needs an id unique within the submission, plus a category and subcategory — these are validated against the sets the engine accepts, so they are not free text.

1from emtellipro.data import InputDocument
2
3doc = InputDocument(
4 "doc-1",
5 "Clinical",
6 "generic",
7 "The 2.4 cm melanoma on his left shin has become larger since 2 months ago.",
8)
9
10future = client.submit([doc])

submit returns immediately with a ResultFuture. Passing features= narrows what the engine computes; the default is every feature.

Wait for the result

1future.done(timeout=300)
2result = future.result()

Read the entities

A Result holds annotated_docs, one per document you submitted. Each found entity carries the text it matched, its assertion attributes, and the concepts it resolved to — which is how one mention maps into several ontologies at once.

1for annotated_doc in result.annotated_docs:
2 for entity in annotated_doc.found_entities:
3 print(entity.text, entity.polarity, entity.section_name)

The shape of what comes back — how concept_links and locations resolve — is laid out with a real payload on the JSON Result Format page.

The whole thing

nlp_quickstart.py
1import os
2
3from emtellipro import Emtellipro
4from emtellipro.data import InputDocument
5
6client = Emtellipro(
7 "https://api.us.emtelligent.com:50001",
8 os.environ["EMTELLIPRO_API_KEY"],
9)
10
11doc = InputDocument(
12 "doc-1",
13 "Clinical",
14 "generic",
15 "The 2.4 cm melanoma on his left shin has become larger since 2 months ago.",
16)
17
18future = client.submit([doc])
19future.done(timeout=300)
20result = future.result()
21
22for annotated_doc in result.annotated_docs:
23 for entity in annotated_doc.found_entities:
24 print(entity.text, entity.polarity, entity.section_name)

Next