function lookup($user, $operation, $acl, $type) { $id = (string) $user->id; if (isset($acl->users->{$id}) and ($acl->users->{$id}->{$type} === '*' or in_array($operation, $acl->users->{$id}->{$type}))) { return true; } elseif ($groups = intersect($acl->groups, $user->groups)) { foreach ($groups as $group) { if (isset($group->{$type}) and ($group->{$type} === '*' or in_array($operation, $group->{$type}))) { return true; } } } if (isset($acl->parent)) { return lookup($user, $operation, $acl->parent, $type); } else { return false; } }
<? $intersect = intersect($in) ?> <? if ($intersect->intersects): ?> <table border=1 class="results intersect-results"> <tr> <td></td> <? foreach ($intersect->titles as $code => $title): ?> <td class="title"><?php echo html($title); ?> </td> <? endforeach ?> </tr> <? foreach ($intersect->intersects as $actorCode => $actor): ?> <tr> <td class="actor"><a href="http://www.imdb.com/name/<?php echo $actorCode; ?> /"><?php echo html($actor); ?> </a></td> <? foreach ($intersect->titles as $titleCode => $title): ?> <td class="character"><?php echo html($intersect->casts[$titleCode]->characters[$actorCode]); ?> </td> <? endforeach ?> </tr> <? endforeach ?>
function processGuitar4svg() { global $guitar, $threshold; //test strings ends are on nut and bridge //if not dont to partials $numStrings = sizeof($guitar['strings']); $doPartials = true; $parallelFrets = true; $nut = new Segment($guitar['strings'][0]->end1(), $guitar['strings'][$numStrings - 1]->end1()); $bridge = new Segment($guitar['strings'][0]->end2(), $guitar['strings'][$numStrings - 1]->end2()); $midline = new Segment(new Point(($nut->end2->x + $nut->end1->x) / 2, ($nut->end2->y + $nut->end1->y) / 2), new Point(($bridge->end2->x + $bridge->end1->x) / 2, ($bridge->end2->y + $bridge->end1->y) / 2)); foreach ($guitar['strings'] as $string) { if (!($nut->distanceToPoint($string->end1()) < $threshold) || !($bridge->distanceToPoint($string->end2()) < $threshold)) { echo $string->toString(), '<br />'; echo $nut->distanceToPoint($string->end1()), '<br />'; echo $bridge->distanceToPoint($string->end2()), '<br />'; $doPartials = false; break; } } $denom = ($bridge->end2->y - $bridge->end1->y) * ($nut->end2->x - $nut->end1->x) - ($bridge->end2->x - $bridge->end1->x) * ($nut->end2->y - $nut->end1->y); if ($denom != 0) { $parallelFrets = false; } $intersection = intersect($nut, $bridge); $strings = array(); $tones = sizeof($guitar['scale']['steps']) - 1; $totalWidth = array(); $scale = $guitar['scale']['steps']; for ($i = 0; $i < $numStrings; $i++) { $base = $guitar['tuning'][$i]; $frets = array(); $frets[0]['fret'] = $doPartials ? new Segment($guitar['meta'][$i]->end1, $guitar['meta'][$i + 1]->end1) : new Segment($guitar['strings'][$i]->end1, $guitar['strings'][$i]->end1); $frets[0]['intersection'] = $guitar['strings'][$i]->end1; for ($j = 1; $j <= $guitar['frets']; $j++) { $step = ($base + $j - 1) % $tones + 1; // $step=(($base+$j)%($tones-1))+1; // $step=$step==0?1:$step; $ratio = 1 - $scale[$step][1] * $scale[$step - 1][0] / ($scale[$step][0] * $scale[$step - 1][1]); $x = $frets[$j - 1]['intersection']->x + $ratio * ($guitar['strings'][$i]->end2->x - $frets[$j - 1]['intersection']->x); $y = $frets[$j - 1]['intersection']->y + $ratio * ($guitar['strings'][$i]->end2->y - $frets[$j - 1]['intersection']->y); $frets[$j]['intersection'] = new Point($x, $y); $temp = new Segment($guitar['strings'][$i]->end1(), $frets[$j]['intersection']); $frets[$j]['nutDist'] = $temp->length(); $frets[$j]['totalRatio'] = $frets[$j]['nutDist'] / $guitar['strings'][$i]->length(); if ($doPartials) { /* //partials depending on nut bridge intersection (bad) $temp=$parallelFrets? $nut->createParallel($frets[$j]['intersection']): new Segment($intersection,$frets[$j]['intersection']); $frets[$j]['fret']=new Segment(intersect($temp,$guitar['meta'][$i]), intersect($temp,$guitar['meta'][$i+1])); //partials depending on meta lines (questionable) if ($parallelFrets) { $frets[$j]['fret']=$nut->createParallel($frets[$j]['intersection']); } else { $frets[$j]['fret']=new Segment( $guitar['meta'][$i]->pointAt($guitar['meta'][$i]->length()* $frets[$j]['totalRatio']), $guitar['meta'][$i+1]->pointAt($guitar['meta'][$i+1]->length()* $frets[$j]['totalRatio']) ); } */ //partials depending on outer strings (questionable) if ($parallelFrets) { $temp = $nut->createParallel($frets[$j]['intersection']); } else { $temp = new Segment($guitar['strings'][0]->pointAt($guitar['strings'][0]->length() * $frets[$j]['totalRatio']), $guitar['strings'][$numStrings - 1]->pointAt($guitar['strings'][$numStrings - 1]->length() * $frets[$j]['totalRatio'])); } $frets[$j]['fret'] = new Segment(intersect($temp, $guitar['meta'][$i]), intersect($temp, $guitar['meta'][$i + 1])); } else { $frets[$j]['fret'] = new Segment($frets[$j]['intersection'], $frets[$j]['intersection']); } } $strings[] = $frets; } return array('strings' => $strings, 'midline' => $midline, 'nut' => $nut, 'bridge' => $bridge); }
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); $matrixes[$k['kappa']] = $matrix; $kappas[] = array_merge($k, array('user1' => $u1, 'user2' => $u2, 'book_id' => $book['id'], 'book_title' => $book['name'], 'u1count' => count($complex_groups1), 'u2count' => count($complex_groups2), 'with_m' => $u1 === $mod or $u2 === $mod, 'intersect' => intersect($complex_groups1, $complex_groups2))); // print PHP_EOL; } } } print "<h1>Cohen's kappa, complex groups</h1>"; print "<h2>All annotators and moderator</h2>"; foreach ($USERS as $user1) { $user1 = get_user_shown_name($user1); print "{$user1} with mod <br />"; $stats = kappa_stats_with_filter($kappas, function ($e) use($user1) { return $e['user1'] == $user1 && $e['with_m'] or $e['user2'] == $user1 && $e['with_m']; }); if ($stats) { list($min, $max, $avg) = $stats; print sprintf("%.4f (%s, %s) [%.4f] %.4f (%s, %s)<br />", $min['kappa'], $min['user1'], $min['user2'], $avg, $max['kappa'], $max['user1'], $max['user2']);