arsort($wdProps); $amount = reset($wdProps); $freq = $amount / $occurences[$fProp]; if ($freq < 0.1 || $amount < 10) { continue; //Filter very bad guess } $matchingAmount[$fProp] = $amount; $frequency[$fProp] = $freq; $mostProbableProperty[$fProp] = key($wdProps); } //Compare with existing mapping $compareProps = 0; $diffProps = 0; foreach ($mostProbableProperty as $fProp => $wdProp) { if ($mapping->isPropertyMapped($fProp)) { $compareProps++; $existingWdProp = $mapping->mapFreebaseProperty('<http://rdf.freebase.com' . $fProp . '>'); if ($existingWdProp instanceof WikidataProperty && $existingWdProp->getPid() !== $wdProp) { echo "Conflict for property {$fProp}: {$wdProp} with frequency {$frequency[$fProp]} instead of {$existingWdProp->getPid()}\n"; $diffProps++; } } } echo "{$compareProps} compared and {$diffProps} are different\n"; //Output the other suggestions $output = fopen($argv[4], 'w'); arsort($matchingAmount); fputcsv($output, ['Freebase property', 'Wikidata property', 'Matching frequency', 'Number of matched']); foreach ($matchingAmount as $fProp => $amount) { if ($mapping->isPropertyMapped($fProp)) {