} return $times; case 'wikibase-entityid': switch ($value['entity-type']) { case 'item': return ['Q' . $value['numeric-id']]; case 'property': return ['P' . $value['numeric-id']]; } } } } $input = fopen($argv[1], 'r'); $output = fopen($argv[2], 'w'); $count = 0; $converter = new TsvConverter(); while ($line = fgets($input)) { $line = trim($line, ", \n\t\r"); if ($line === '' || $line[0] !== '{') { continue; } $json = json_decode($line, true); if (!array_key_exists('claims', $json)) { continue; } foreach ($json['claims'] as $claims) { foreach ($claims as $statement) { foreach ($converter->convertStatement($statement) as $tsv) { fwrite($output, $json['id'] . "\t" . implode("\t", $tsv) . "\n"); } }
case 'time': return $value['time'] . '/' . $value['precision']; case 'wikibase-entityid': switch ($value['entity-type']) { case 'item': return 'Q' . $value['numeric-id']; case 'property': return 'P' . $value['numeric-id']; } } } } $input = fopen($argv[1], 'r'); $output = fopen($argv[2], 'w'); $count = 0; $converter = new TsvConverter(); while ($line = fgets($input)) { $line = trim($line, ", \n\t\r"); if ($line === '' || $line[0] !== '{') { continue; } $json = json_decode($line, true); if (!array_key_exists('claims', $json)) { continue; } foreach ($json['claims'] as $claims) { foreach ($claims as $statement) { fwrite($output, $json['id'] . "\t" . $converter->convertStatement($statement) . "\n"); } } $count++;