$referencesUrls[$statement->toTSV()] = array_slice($parts, 3);
        }
    } catch (Mappingfailure $e) {
    } catch (Exception $e) {
        echo $e->getMessage() . ': ' . $line . "\n";
    }
    $count++;
    if ($count % 100000 === 0) {
        echo '.';
    }
}
fclose($referencesInput);
//Do mapping
echo "\nMapping\n";
rewind($input);
$mapping->resetStatistics();
$count = 0;
$freebaseMappedFile = fopen($outputdirectory . '/freebase-mapped.tsv', 'w');
$coordinatesMappedFile = fopen($outputdirectory . '/coordinates-mapped.tsv', 'w');
$reviewedMappedFile = fopen($outputdirectory . '/reviewed-mapped.tsv', 'w');
while ($line = fgets($input)) {
    list($s, $p, $o) = explode("\t", trim($line, " .\t\n\r\v"), 3);
    $statement = new Statement($s, $p, $o);
    try {
        $statements = $mapping->mapFreebaseStatement($statement);
    } catch (Mappingfailure $e) {
        continue;
    } catch (Exception $e) {
        echo $e->getMessage() . ': ' . $line . "\n";
        //TODO change to have verbose output
        continue;