Oncilla API | Location Intelligence | AWS

 

line

How to use the Oncilla API to geoparse your text.

Oncilla Logo

Step 1: Create an AWS IAM account.

Step 2: Subscribe to Oncilla in the AWS Marketplace.

Step 3: Configure your AWS credentials.

Step 4: Start using Oncilla!

Call the Oncilla API using the AWS CLI.

aws dataexchange send-api-asset \
--data-set-id 1b82649658ad97cadefe1728c0571881 \
--revision-id 16c060acfe4cc7cdf08c0ca499bc1093 \
--asset-id 5a779b06b6cfcdff958d4707afa6a5ae \
--method POST \
--path "/geoparse" \
--request-headers 'Content-Type=application/json' \
--body "[{\"recordId\": \"a1\", \"data\": {\"text\": \"The Africa CDC is based at the Africa CDC Coordinating Centre in Addis Ababa, Ethiopia, which also contains the agency's Emergency Operations Centre.\", \"lang\": \"en\", \"informal\": false}}]"

 

Call the Oncilla API using Python code.

import json
import boto3


aws_client = boto3.client('dataexchange')


def geoparse(api_data, client):
    response = client.send_api_asset(
      DataSetId='1b82649658ad97cadefe1728c0571881',
      RevisionId='16c060acfe4cc7cdf08c0ca499bc1093',
      AssetId='5a779b06b6cfcdff958d4707afa6a5ae',
      Method='POST',
      Path='/geoparse',
      RequestHeaders={
          'Content-Type': 'application/json'
      },
      Body=json.dumps(api_data)
    )
    return response


api_data = {
  "values": [{
      "recordId": 'a1',
      "data": {
        "text": 'Monsoon rains are forecast to continue over the deserts in the Southwest and up into the Rocky Mountains, with potential for flash flooding in Arizona, Utah, Colorado and Wyoming on Sunday.',
        "lang": "en",
        "informal": False
      }
    },
    {
      "recordId": 'a2',
      "data": {
        "text": 'The Africa CDC is based at the Africa CDC Coordinating Centre in Addis Ababa, Ethiopia, which also contains the agency\'s Emergency Operations Centre.',
        "lang": "en",
        "informal": False
      }
    }]
}

results = geoparse(api_data, aws_client)
output = json.loads(results['Body'].replace('\"', '"'))
# output contains the geoparsed results for the final batch
print(output)