return false; } list($yearA, $monthA, $dayA) = $this->explodeTimestamp($a->getTime()); list($yearB, $monthB, $dayB) = $this->explodeTimestamp($b->getTime()); return $yearA === $yearB && !($b->getPrecision() >= TimeValue::PRECISION_MONTH && $monthA !== $monthB) && !($b->getPrecision() >= TimeValue::PRECISION_DAY && $dayA !== $dayB); } private function explodeTimestamp($timestamp) { preg_match('/^([-+]\\d+)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)Z$/', $timestamp, $m); array_shift($m); return $m; } //Very, very hacky private function hasMeaningfulReference(Statement $statement) { foreach ($statement->getReferences() as $reference) { foreach ($reference->getSnaks() as $snak) { if (!$snak->equals(new PropertyValueSnak(new PropertyId('P248'), new EntityIdValue(new ItemId('Q36578')))) && !$snak->getPropertyId()->equals(new PropertyId('P813')) && !$snak->getPropertyId()->equals(new PropertyId('P143'))) { return true; } } } return false; } } $api = new MediawikiApi('https://www.wikidata.org/w/api.php'); $api->login(new ApiUser(MY_USERNAME, MY_PASSWORD)); //TODO $bot = new Bot($api); $bot->addStatementFromTsvFile($argv[1]); //$bot->addStatementFromPrimarySourcesQuery(['property' => 'P1771']);