Support

User-defined classifiers

Dandelion provides a handy endpoint for managing all your Text Classification API models, following the CRUD(L) paradigm. With this endpoint you will be able to integrate our API into your own applications. If you have already created your model and you want to try it out, please refer to the Text Classification API Reference.

Model structure

A Text Classification API model is simply composed by a list of categories, each defined as a set of entities represented as (weighed) Wikipedia pages, which "describe" the category itself. Writing your own model is quite simple! Need a Sport category? You could represent it as:

  • http://en.wikipedia.org/wiki/Baseball
  • http://en.wikipedia.org/wiki/Basketball
  • http://en.wikipedia.org/wiki/Football
  • ...

around 10 entities per category usually do the trick.

In general, a model is defined following this structure:

{
  "lang": "The language the model will work on",
  "description": "A human-readable string you can use to describe this model",
  "categories": [
    {
      "name": "The category name",
      "topics": {
        "topic1": "weight",
        "topic2": "weight",
        "...": "...",
      }
    }
  ]
}

Topics are represented as wikipedia pages. You can refer to each topic by its URI http://en.wikipedia.org/wiki/Baseball, its title Baseball or its wikipedia page ID 3850. In this two last cases, the lang attribute will be used to select the Wikipedia to match against. To see a concrete example, check out the Example section.

Endpoint

https://api.dandelion.eu/datatxt/cl/models/v1

Depending on the HTTP method used to access this endpoint, a different functionality will be triggered.

Methods

Create a new model

POST https://api.dandelion.eu/datatxt/cl/models/v1
parameters
data required
The model you want to create, structured as described above.
response
{
  "id": "0123-abcd-45678901-cdefabcd",
  "created": "2014-03-02T00:04:16",
  "modified": "2014-03-02T00:04:16",
  "data": {
    "description": "My first model",
    "lang": "en",
    "categories": [
      {
        "name": "Sport",
        "topics": {
          "http://en.wikipedia.org/wiki/Sport": 2.0,
          "http://en.wikipedia.org/wiki/Baseball": 1.0,
          "http://en.wikipedia.org/wiki/Basketball": 1.0,
          "http://en.wikipedia.org/wiki/Football": 1.0
        }
      }
    ]
  }
}
example
curl -i --data-urlencode "data@model.json" -d "token=<YOUR_TOKEN>"   http://api.dandelion.eu/datatxt/cl/models/v1

This example assumes that you wrote your model in a file named model.json

Read a specific model

GET https://api.dandelion.eu/datatxt/cl/models/v1?id=<model-id>
parameters
id required
The id of the model you want to fetch.
response
Return the requested model, see example
example
curl -i http://api.dandelion.eu/datatxt/cl/models/v1?token=<YOUR_TOKEN>\&id=<MODEL_ID>

Update an existing model

PUT https://api.dandelion.eu/datatxt/cl/models/v1?id=<model-id>&data=<the-json>
parameters
id required
The id of the model you want to update.
data required
The updated model, structured as described above.
response
{
  "id": "82cf5f938180d3d780b376bfff6",
  "created": "2014-03-02T00:04:16",
  "modified": "2014-03-03T10:10:16",
  "data": {
    "description": "My first model",
    "lang": "en",
    "categories": [
      {
        "name": "Sport",
        "topics": {
          "http://en.wikipedia.org/wiki/Sport": 2.0,
          "http://en.wikipedia.org/wiki/Baseball": 1.0,
          "http://en.wikipedia.org/wiki/Football": 1.0
        }
      },
      {
        "name": "Politics",
        "topics": {
          "Politics": 2.0,
          "Politician": 1.5
        }
      }
    ]
  }
}
example
curl -i -X PUT --data-urlencode "data@model.json" -d "token=<YOUR_TOKEN>" -d "id=<MODEL_ID>"  http://api.dandelion.eu/datatxt/cl/models/v1

This example assumes that you wrote your model in a file named model.json

Delete a model

DELETE https://api.dandelion.eu/datatxt/cl/models/v1?id=<model-id>
parameters
id required
The id of the model you want to delete.
example
curl -i -X DELETE http://api.dandelion.eu/datatxt/cl/models/v1?token=<YOUR_TOKEN>\&id=<MODEL_ID>

List all your models

GET https://api.dandelion.eu/datatxt/cl/models/v1
response
{
  "count": 2,
  "items": [
    {
      "id": "0123-abcd-45678901-cdefabcd",
      "created": "2015-10-21T16:29:37",
      "modified": "2015-10-21T16:29:37",
      "data": {
        "lang": "en",
        "description": "",
        "categories": [
            "...": "..."
        ]
      }
    },
    {
      "id": "0123-abcd-45678901-cdefabce",
      "created": "2015-10-21T16:29:39",
      "modified": "2015-10-21T16:29:39",
      "data": {
        "lang": "it",
        "description": "",
        "categories": [
            "...": "..."
        ]
      }
    }
  ]
}
example
curl -i http://api.dandelion.eu/datatxt/cl/models/v1?token=<YOUR_TOKEN>

Model example

A very simple example to have an idea of what it means to define custom models in the Text Classification API. Quite easy, isn't it?

{
  "description": "My first model for classifying news",
  "lang": "en",
  "categories": [
    {
      "name": "Sport",
      "topics": {
        "http://en.wikipedia.org/wiki/Sport": 2.0,
        "http://en.wikipedia.org/wiki/Baseball": 1.0,
        "http://en.wikipedia.org/wiki/Basketball": 1.0,
        "http://en.wikipedia.org/wiki/Football": 1.0
      }
    },
    {
      "name": "Politics",
      "topics": {
        "Politics": 2.0,
        "Politician": 1.5,
        "Brack Obama": 1.0,
        "David Cameron": 1.0,
        "Angela Merkel": 1.0
      }
    }
  ]
}
        
SpazioDati Via A. Olivetti 13, 38122, Trento (TN) -


Dandelion API built with by

site privacy | api privacy | tos | cookies

Contact Us

@dandelionapi

Need more info or a custom project? Write us: hello@dandelion.eu

About Us

We're a startup based in Italy, specialized in Semantics & Big Data.
Find out more about us at spaziodati.eu