group.relatedGroups

Get related groups. Returns a result with an array named "related_groups" with groups that are related to the specified group.

Request Parameters

group_idint (required)
Id for the group you want to find related groups to.
group_scopeint/array

Define which groups you want to get results for. Defining a group scope will decrease the calculation time.

If no group_scope is defined it will by default add all your existing groups to the group_scope. Groups that don't contain any texts or groups with a different language are discarded.
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)

Response Parameters

group_idint
Id of result group.
relevancedecimal
The relevance for the result context. Between 0.0-1.0

Code Examples

JSON

//Request
{
  "method":"group.relatedGroups", 
  "params":{
    "group_id":2
  }, 
  "id":0
}


//Response
{ 
 "id":0,
 "result":{
    "related_groups":[
        {
          "group_id":2,
          "relevance":0.91
        },
        {
          "group_id":12,
          "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 SaploGroupManager to work with groups
SaploGroupManager groupMgr = new SaploGroupManager(client);

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

// Find the related groups for the group, with a given group scope, 
// relatedBy, and wait time
SaploGroup[] groupScope = {group1, group2, group3};
groupMgr.relatedGroups(group, RelatedBy.automatic, groupScope);

// The related groups can now be retrieved by .getRelatedGroups(); 
// on the group object
// Print the result
for(SaploGroup related : group.getRelatedGroups())
    System.out.println("Related Group Id: " + related.getId() 
        + " relevance: " + related.getRelatedRelevance());

PHP

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

$params = array(
    "group_id" => 21
);
  
try {
    $result = $client->group->related_groups($params);
} catch(SaploException $e) {
    echo '(' . $e->getCode() . ') ' . $e->getMessage();
}
   
var_dump($result);

Matlab

params.group_id = 415;
params.wait = 10;
 
response = saploRequest('group.relatedGroups', params)