/**
  * Calculates the Jacard Similarity between the comparators' scalar attributes
  * @param  Comparator $a
  * @param  Comparator $b
  * @return float        Jaccard Similarity
  */
 public function analyse(Comparator $a, Comparator $b)
 {
     $aa = $a->getScalarAttributes();
     $ba = $b->getScalarAttributes();
     if (count($aa) != count($ba)) {
         throw new \LogicException("Cannot compute similary: attributes arrays are unequal");
     }
     if (count($aa) == 0 && count($ba) == 0) {
         return 1;
     }
     //follows the convention that two empty objects are equal
     $this->similarity = count(array_intersect_assoc($aa, $ba)) / count($aa);
     return $this->similarity;
 }
 /**
  * Accessor for the attribute filler before it is applied to the Comparators
  * This will compute the union set of attributes using the keys and return an array filled with the filler value specified
  * @param  string $attributeType vector|scalar
  * @param  mixed $replaceWith   The value to fill the missing attributes with
  * @return array                
  */
 public function getNormalizedAttributeFiller($attributeType, $replaceWith)
 {
     $filler = array_fill_keys(array_keys(array_diff_key($this->a->getAttributes($attributeType), $this->b->getAttributes($attributeType)) + array_diff_key($this->b->getAttributes($attributeType), $this->a->getAttributes($attributeType))), $replaceWith);
     ksort($filler);
     return $filler;
 }