group.relatedTexts

Search for texts that are related to a group. Returns an array named "related_texts" containing the result.

Request Parameters

group_idint (required)
The group id the texts should be related to.
collection_scopeint (required)
The collection(s) in which we search for related texts.
waitint (default: 5)
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)
limitint (default: 10)

The max number of related texts you want in your result set. There is no guarantee that the number of results will equal the limit. Max 50.

Response Parameters

collection_idint
Collection id for resulting text.
text_idint
Id for resulting text.
relevancedecimal
The relevance value for the text compared to the context.
ext_text_idString

External text id

Code Examples

JSON

//Request
{
  "method":"group.relatedTexts",
  "params":{
    "group_id":2,
    "collection_scope":606
  },
  "id":0
}
 
 
//Response
{
 "id":0,
 "result":{
    "related_texts":[
        {
          "collection_id":606,
          "text_id":11,
          "relevance":0.91,
          "ext_text_id":"my-id-001A",
        },
        {
          "collection_id":606,
          "text_id":67,
          "relevance":0.83,
          "ext_text_id":"my-id-32141C",
        }
    ]
}

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 SaploGroupManager to work with groups
SaploGroupManager groupMgr = new SaploGroupManager(client);

// Assuming you already know the ID of your group
SaploGroup group = new SaploGroup();
group.setId(groupId);

// Find texts that are related to the group in a given set of collections
// waitTime is the number of seconds you would wait for the API to return
// limit is the maximum amount of texts
SaploCollection[] collectionScope = {col1, col2, col3};
groupMgr.relatedTexts(group, collectionScope, waitTime, limit);

// The related texts can now be retrieved by .getRelatedTexts(); 
// on the group object
// Print the result
for(SaploText related : group.getRelatedTexts())
    System.out.println("Related text Id: " + related.getId() 
        + " relevance: " + related.getRelatedRelevance());

PHP

$client = new SaploAPI("YOUR API KEY", "YOUR SECRET KEY");

$params = array(
    "group_id" => 21,
    "collection_scope" => 606
);

try {
    $result = $client->group->related_texts($params);
} catch(SaploException $e) {
    echo '(' . $e->getCode() . ') ' . $e->getMessage();
}
   
var_dump($result);

Matlab

params.group_id = 415;
params.wait = 10;
params.collection_scope = 2131;

response = saploRequest('group.relatedTexts', params)