text.tags
Get all entity tags that exists in the text. Categorized as person, organization, location, url, unknown.
If no entity tags where found in the text, an empty result will be returned.
Request Parameters
| collection_id | int (required) |
Collection id where text is stored.
Id of the text.
Maximum time you want to wait for a result to be calculated. Maximum wait time is 60 sec. If wait time is zero (0) you will only start the process and disconnect and can check out the result later. An exception will be thrown saying processing request. (See Error Codes)
| skip_categorization | boolean (default: FALSE) |
Setting to TRUE will turn categorization off. This might improve the speed.
Get tags based on external text id.
Response Parameters
Tag word being extracted.
What type of tag it is categorized as.
Currently following category types are detected. A category doesn't have any sub-categories and may contain tags as stated below.
Person - A living, dead or fictive person.
Organization - A company, department, organization or product.
Location - A geographical place.
Unknown - When we couldn't predict the category.
URL - An Internet location or mail address.
The value for how relevant the tag is for the text in relation to the other tags in the text. This value is between 0-1.
Code Examples
JSON
//Request
{
"method":"text.tags",
"params":{
"collection_id":607,
"text_id":3,
"wait":15
},
"id":0
}
//Response
{
"id":0,
"result":{
"tags":[
{
"tag":"Saplo",
"category":"organization",
"relevance":1
},
{
"tag":"Sweden",
"category":"location",
"relevance":0.81
}
]
}
Java
// You need to have a ready-to-use client to use the other methods
SaploClient client = new SaploClient("YOUR_API_KEY", "YOUR_SECRET_KEY");
// Create a SaploTextManager to work with texts
SaploTextManager textMgr = new SaploTextManager(client);
// Assuming you already have a text object and it's stored in the API
// Get a list of tags that exist in your text
List tags = textMgr.tags(text);
// Print them out
for(SaploTag tag : tags)
System.out.println("Category: " + tag.getCategory()
+ " TagWord: " + tag.getTagWord());
PHP
$client = new SaploAPI("YOUR API KEY", "YOUR SECRET KEY");
$params = array(
"collection_id" => 15,
"text_id" => 1
);
try {
$result = $client->text->tags($params);
} catch(SaploException $e) {
echo '(' . $e->getCode() . ') ' . $e->getMessage();
}
var_dump($result);
Python
client = SaploJSONClient("YOUR API KEY", "YOUR SECRET KEY")
tags = client.text.tags(
collection_id=678,
text_id=2,
wait=10
)
print "Retrieved these tags from the text:", tags
Matlab
params.collection_id = 2131;
params.text_id = 1;
params.wait = 10;
response = saploRequest('text.tags', params)
Notes
This method is optimized for editorial texts which means that a text needs to be written using "correct" formatting (e.g. capital letters, punctuation etc.) where it should exist otherwise it may result in an empty result (no tags found).