Annotations

Annotations one of the fundamental building blocks of extracted data. They say that a portion of a source has some special meaning

Create Annotation

POST https://api.annolab.ai/v1/annotation/create

Create an annotation of some type on a source file. For text file sources, an annotation may reside over an array of character offsets or may simply be a document level (manual) annotation.

Headers

Request Body

{
  "id": 44,
  "typeId": 51,
  "typeName": "Place Name",
  "layerId": 5,
  "sourceId": 145,
  "typeId": 112,
  "value": '{latitude:"37.983810", longitude:"23.727539"}',
  "rawValue": 'Athens',
  "offsets": [0, 5]
 }

Examples of how to make an annotation create request

import requests

ANNO_LAB_API_KEY = 'XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'

annotation = {
  'annoTypeIdentifier': 'Place Name',
  'projectIdentifier': 'New NER Project',
  'layerIdentifier': 'NER Gold',
  'sourceIdentifier': 145,
  'offsets': [0, 5],
  'directoryIdentifier': 'Wikipedia Subset',
  'value': '{latitude:"37.983810", longitude:"23.727539"}'
}

headers = {
  'Authorization': 'Api-Key '+ANNO_LAB_API_KEY,
}

url = 'https://api.annolab.ai/v1/annotation/create'

response = requests.post(url, headers=headers, json=annotation)

print(response.json())

Bulk Create Annotations

POST https://api.annolab.ai/v1/annotation/bulk-create

Create a set of up to 2000 annotations in one request (can be a mix of many different annotation types and spread across many source files). 80% faster than individual inserts in most cases

Headers

Request Body

Examples of how to bulk create annotations

import requests

ANNO_LAB_API_KEY = 'XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'

headers = {
  'Authorization': 'Api-Key '+ANNO_LAB_API_KEY,
}

bulk_request = {
  'preventDuplication': True
  'annotations': [
    {
      'annoTypeIdentifier': 'Place Name',
      'projectIdentifier': 'New NER Project',
      'schemaIdentifier': 'NER',
      'layerIdentifier': 'NER Gold',
      'sourceIdentifier': 145,
      'offsets': [0, 5],
      'directoryIdentifier': 'Wikipedia Subset',
      'value': '{latitude:"37.983810", longitude:"23.727539"}',
      'clientId': "24a"
    },
    {
      'annoTypeIdentifier': 'Place Name',
      'projectIdentifier': 'New NER Project',
      'schemaIdentifier': 'NER',
      'layerIdentifier': 'NER Gold',
      'sourceIdentifier': 145,
      'offsets': [120, 128],
      'directoryIdentifier': 'Wikipedia Subset',
      'value': '{latitude:"37.983810", longitude:"23.727539"}',
      'clientId': "24b"
    }
  ]
}

url = 'https://api.annolab.ai/v1/annotation/bulk-create'

response = requests.post(url, headers=headers, json=bulk_request)

Annotation Object

An object corresponding to a single annotation

{
    'annotationId': 403992,
    'sourceReferenceId': 12341, 
    'typeName': 'Grantor', 
    'value': ' Carsuo', 
    'pageNumber': 3, 
    'endPageNumber': null, 
    'offsets': [1320, 1326], 
    'textBounds': {'type': 'MultiPolygon', 'coordinates': [[[[0.565917551517487, 0.769474387168884], [0.609824299812317, 0.769511699676514], [0.609820425510406, 0.778583765029907], [0.565913617610931, 0.778546392917633], [0.565917551517487, 0.769474387168884]]]]}, 
    'imageBounds': null, 
    'createdBy': 5, 
    'updatedBy': null, 
    'confidence': 96.7900390625, 
    'score': 0.7074922025203705, 
    'layerId': 635, 
    'isReviewed': False, 
    'reviewedBy': null, 
    'reviewedAt': null, 
    'modelSourceId': 12, 
    'modelSource': 'Party Name Extractor'
}

CanonicalAnnotation Object

An abstract form of an annotation that is not grounded in any explicit mention or context, simplified to the components of name and value.

These objects cannot be created directly, instead they exist as attributes of CanonicalTag objects.

{
    "name": "Make",
    "value": "Cessna",
}

Last updated