public function testGetTArrayAbout() { $tu = new \Tripod\Mongo\TriplesUtil(); $triples = array(); $triples[] = "<http://serials.talisaspire.com/issn/0893-0465> <http://xmlns.com/foaf/0.1/page> <http://www.ingentaconnect.com/content/bpl/ciso> . "; $triples[] = "<http://serials.talisaspire.com/issn/0893-0465> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/ontology/bibo/Journal> . "; $triples[] = "<http://serials.talisaspire.com/issn/0893-0465> <http://xmlns.com/foaf/0.1/page> <http://onlinelibrary.wiley.com/journal/10.1111/(ISSN)1548-744X> . "; $triples[] = "<http://serials.talisaspire.com/issn/0893-0465> <http://purl.org/ontology/bibo/eissn> \"1548-774X\" . "; $expectedDoc = array('_id' => array('r' => 'http://serials.talisaspire.com/issn/0893-0465', "c" => "http://talisaspire.com/"), 'foaf:page' => array(array('u' => 'http://www.ingentaconnect.com/content/bpl/ciso'), array('u' => 'http://onlinelibrary.wiley.com/journal/10.1111/(ISSN)1548-744X')), 'rdf:type' => array('u' => 'bibo:Journal'), 'bibo:eissn' => array('l' => '1548-774X')); $this->assertEquals($expectedDoc, $tu->getTArrayAbout('http://serials.talisaspire.com/issn/0893-0465', $triples, 'http://talisaspire.com/')); }
require_once dirname(__FILE__) . '/common.inc.php'; require_once dirname(dirname(dirname(__FILE__))) . '/src/tripod.inc.php'; if ($argc != 2) { echo "usage: ./triplesToBSON.php tripodconfig.json < ntriplesdata\n"; die; } array_shift($argv); $config = json_decode(file_get_contents($argv[0]), true); \Tripod\Mongo\Config::setConfig($config); $currentSubject = ""; $triples = array(); $docs = array(); $errors = array(); // array of subjects that failed to insert, even after retry... $tu = new \Tripod\Mongo\TriplesUtil(); while (($line = fgets(STDIN)) !== false) { $line = rtrim($line); $parts = preg_split("/\\s/", $line); $subject = trim($parts[0], '><'); if (empty($currentSubject)) { $currentSubject = $subject; } if ($currentSubject != $subject) { print json_encode($tu->getTArrayAbout($currentSubject, $triples, \Tripod\Mongo\Config::getInstance()->getDefaultContextAlias())) . "\n"; $currentSubject = $subject; // reset current subject to next subject $triples = array(); // reset triples } $triples[] = $line;
<?php require_once dirname(__FILE__) . '/common.inc.php'; require_once dirname(dirname(dirname(__FILE__))) . '/src/tripod.inc.php'; ini_set('memory_limit', '32M'); if ($argc != 1) { echo "usage: php detectNamespaces.php < triples\n"; die; } array_shift($argv); $dummyDbConfig = array("database" => "foo", "collection" => "bar", "connStr" => "baz"); $config = array("namespaces" => array(), "defaultContext" => "http://example.com/", "transaction_log" => $dummyDbConfig, "es_config" => array("endpoint" => "http://example.com/", "indexes" => array(), "search_document_specifications" => array()), "queue" => $dummyDbConfig, "databases" => array("default" => array("connStr" => "baz", "collections" => array()))); \Tripod\Mongo\Config::setConfig($config); $util = new \Tripod\Mongo\TriplesUtil(); $objectNs = array(); $i = 0; while (($line = fgets(STDIN)) !== false) { $i++; $line = rtrim($line); $parts = preg_split("/\\s/", $line); $subject = trim($parts[0], '><'); if ($i % 2500 == 0) { print '.'; } if ($i % 50000 == 0) { foreach ($objectNs as $key => $val) { if ($val < 5) { // flush unset($objectNs[$key]); } }