Esempio n. 1
0
 public static function pruneNarrowConcepts($concepts)
 {
     // Build a map with paths as keys
     $concepts = array_combine(Concept::toPathArray($concepts), $concepts);
     // Paths are sorted in advance to keep search O(n)
     ksort($concepts);
     // With sorting, the first element can't be a child
     $broad = current($concepts);
     next($concepts);
     // Start prunning concepts narrower than current broad one
     while ($concept = current($concepts)) {
         if ($concept->isNarrowerThan($broad)) {
             unset($concepts[key($concepts)]);
         } else {
             // End of prunable childs, beginning of a new concept
             $broad = $concept;
             next($concepts);
         }
     }
     return array_values($concepts);
 }
Esempio n. 2
0
 public static function childOfConcepts($databox_id, array $concepts)
 {
     return new self($databox_id, Concept::toPathArray($concepts));
 }