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.
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:
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.
Depending on the HTTP method used to access this endpoint, a different functionality will be triggered.
{
"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
}
}
]
}
}
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
curl -i http://api.dandelion.eu/datatxt/cl/models/v1?token=<YOUR_TOKEN>\&id=<MODEL_ID>
{
"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
}
}
]
}
}
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
curl -i -X DELETE http://api.dandelion.eu/datatxt/cl/models/v1?token=<YOUR_TOKEN>\&id=<MODEL_ID>
{
"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": [
"...": "..."
]
}
}
]
}
curl -i http://api.dandelion.eu/datatxt/cl/models/v1?token=<YOUR_TOKEN>
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
}
}
]
}
Dandelion API
built with ❤ by SpazioDati S.r.l.
Company subject to management and coordination of Cerved Group S.p.A.
site privacy | api privacy | tos | cookies
We're a startup based in Italy, specialized in Semantics & Big Data.
Find out more about us at spaziodati.eu