function get_groups_by_sentence($sent_id, $user_id)
{
    $simple = get_simple_groups_by_sentence($sent_id, $user_id);
    return array('simple' => $simple, 'complex' => get_complex_groups_by_simple($simple, $user_id));
}
     $users[$gr['user_id']]++;
     $USERS[] = $gr['user_id'];
     $USERS = array_values(array_unique($USERS));
 }
 if (count($users) < 2) {
     continue;
 }
 // print "{$book['name']}, annotators: ".count($users).PHP_EOL;
 foreach (array_keys($users) as $index => $uid) {
     foreach (array_slice(array_keys($users), $index + 1) as $uid2) {
         // all possible combinations of two users
         $u1 = get_user_shown_name($uid);
         $u2 = get_user_shown_name($uid2);
         // print "$u1 $u2\n";
         $complex_groups1 = array_map('simplify', get_complex_groups_by_simple($simple_groups, $uid));
         $complex_groups2 = array_map('simplify', get_complex_groups_by_simple($simple_groups, $uid2));
         if (count($complex_groups1) === 0 or count($complex_groups2) === 0) {
             continue;
         }
         // print count($complex_groups1)." ".count($complex_groups2)." ".intersect($complex_groups1, $complex_groups2).PHP_EOL;
         // print count($groups_user1)." ".count($groups_user2)." ".intersect($groups_user1, $groups_user2).PHP_EOL;
         $matrix = array();
         $matrix['NONE']['NONE'] = 0;
         foreach ($COMPLEX_TYPES as $id1) {
             foreach ($COMPLEX_TYPES as $id2) {
                 $matrix[$id1][$id2] = count_matching_groups($complex_groups1, $complex_groups2, $id1, $id2);
             }
             $matrix[$id1]['NONE'] = count_matching_nones1($complex_groups1, $complex_groups2, $id1);
             $matrix['NONE'][$id1] = count_matching_nones1($complex_groups2, $complex_groups1, $id1);
         }
         $k = kappa_pairwise(array_merge($COMPLEX_TYPES, array('NONE')), $matrix, TRUE);