Skip to main content
Skip table of contents

Context Space API

Behavior

Given a query, the system finds and returns a set of trends that are most strongly associated with the query by analyzing pre-indexed corpora of online textual data.

To build the context space, a set of leading-edge natural language processing models are combined with techniques adopted from association rule mining and graph theory to model the textual data into a latent semantic knowledge graph that is multi-lingual, geo-coded, and has a time dimension. This compressed data structure is able to represent the strength of the association between different ideas as they evolve over time, and is optimized for fast information retrieval time. Because the system is constantly acquiring more data, the graph is able to adapt to the new information and dynamically build new associations between ideas constantly.

GET /api/v1/query-terms/{term}/context-space

Request Attributes

Attribute

Description

term string

(Path Parameter - Required)
The query term

source emun or null

(Optional) The target data source to build the context space over. Of the possible values “SOCIAL“, “NEWS“, and “PATENTS“.

Defaults to “SOCIAL”

geo string or null

(Optional) ISO-2 geo code specifying the country where results should be filtered from.

Defaults to null for global

categories string or null

(Optional) Comma-separated words for the custom classifications

Response Attributes

Returns an array of hashes where each hash corresponds to a trend and the size of the set is up to 1000.

Attribute

Description

y_term_key string

The trend name.

category string

A category for custom classifications

relevancy float

A score between 0 and 100 representing the strength of the association, where 100 is the strongest.

document_ids array of strings

A sample of document ids that mention the trend in the context of the query. Can be used as input to the snippet api, to retrieve full documents.

labels array of strings

High level categories that the trend belongs too.

volume float

A score between 0 and 10 indicating how sparse occurrences of the trend are in the document corpus.

connected_trends array of strings

Trends within the returned set that are strongly associated.

Sample Request

CODE
GET /api/v1/query-terms/{term}/context-space HTTP/1.1
Content-Type: application/json
Authorization: Bearer <TOKEN>

Sample Response

CODE
HTTP/1.1 200 OK
Content-Type: text/html

[  
  {
        "y_term_key": "tempeh",
        "category": "ingredients",
        "relevancy": 18.15,
        "document_ids": [
            "1015459100000086714",
            "1293878719937941504",
            "1206612449786572800",
            "1168176820073705476",
            "1164562999199375362"
        ],
        "labels": [
            "food",
            "vegan",
            "protein",
            "recipe",
            "meal",
            "sauce",
            "dinner"
        ],
        "volume": 2.31,
        "connected_trends": [
            "tofu",
            "seitan", 
            "soy-based"
        ]
    },
    {
        "y_term_key": "lowers cholesterol",
        "category": "benefits"
        "relevancy": 13.81,
        "document_ids": [
            "1294409214295670784",
            "1294213332375928832"
        ],
        "labels": [
            "food",
            "health"
        ],
        "volume": 2.31,
        "connected_trends": []
    },
    ...
    {
        "y_term_key": "quorn mince",
        "category": "occasions",
        "relevancy": 19.22,
        "document_ids": [
            "1246868114857435140",
            "1144872612084027392",
            "997163346293088256"
        ],
        "labels": [
            "product",
            "vegan",
            "protein",
            "recipe",
            "vegetarian",
            "meal",
            "dinner",
            "quorn"
        ],
        "volume": 0.0,
        "connected_trends": []
    }
  ]

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.