ARC2

From Data-gov Wiki

(Redirected from ARC2 examples)
Jump to: navigation, search
Infobox (Technology) edit with form
  • name: ARC2

  • description: a flexible RDF system for semantic web and PHP practitioners.
  • homepage: http://arc.semsol.org/
  • modified: 2011-5-5


Note: this material is on its way to http://tw.rpi.edu/web/inside/endpoints/installing-arc2

Contents

Data-gov Usage

Demonstrations that use ARC2 Dcterms:creator Technology used
Demo: Public Safety Information for Troy, NY Alvaro Graves PHP
RDF
JQuery
ARC2
Simile Exhibit


Resources


Sample Code

Creating a SPARQL endpoint

Supposing there is a database already created.

<?php
 include_once('arc/ARC2.php');
 
 $config = array(
   /* db */
   'db_host' => 'myserver',
   'db_name' => 'dbname',
   'db_user' => 'user',
   'db_pwd' => 'pass',
   /* store name */
   'store_name' => 'my_endpoint_store',
   /* instructinos accepted */
   'endpoint_features' => array(
     'select', 'construct', 'ask', 'describe', 
     'load', 'insert', 'delete','dump'     
   ),
 
   'endpoint_timeout' => 60, /* not implemented in ARC2 preview */
   'endpoint_read_key' => , /* optional */
   'endpoint_write_key' => , /* optional */
   'endpoint_max_limit' => 0, /* optional */
 );
 
 /* instantiation */
 $ep = ARC2::getStoreEndpoint($config);
 
 /* If tables in DB does not exists, ARC will create it */ 
 if (!$ep->isSetUp()) {
   $ep->setUp(); /* create MySQL tables */
 }
 
 /* request handling */
 $ep->go();
 
 ?>


Loading data from a URI

 <?
 include_once('arc/ARC2.php');
 
 $parser = ARC2::getRDFXMLParser();
 
 $parser->parse("http://inference-web.org/registry/PUB/STE.owl");
 
 $triples = $parser->getTriples();
 
 foreach($triples as $k => $v){
   print "Subject: ".$v['s']." Predicate:".$v['p']." Object:".$v['o'];
 }
 
 ?>

Exporting RDF

 <?
 include_once('arc/ARC2.php');
 header('Content-Type: text/plain');
 
 $aux = array();
 
 //Subject
 $aux['s'] = "http://graves.cl/foaf.rdf#me";
 $aux['s_type'] = 'uri';
 
 //Predicate
 $aux['p'] = "http://xmlns.com/foaf/0.1/name";
 
 //Object
 $aux['o'] = "Alvaro Graves";
 $aux['o_type'] = "literal";
 $aux['o_datatype'] = "xsd:string";
 $aux['o_lang'] = "es";
 
 
 $triples = array();
 array_push($triples, $aux);
 
 $conf = array('ns' => array('foaf' => 'http://xmlns.com/foaf/0.1/'));
 $ser = ARC2::getRDFXMLSerializer($conf);
 
 $doc = $ser->getSerializedTriples($triples);
 
 echo $doc;
 ?>
Facts about ARC2RDF feed
Dcterms:descriptiona flexible RDF system for semantic web and PHP practitioners.
Dcterms:modified2011-5-5
Foaf:homepagehttp://arc.semsol.org/  +
Foaf:nameARC2
Skos:altLabelARC2  +, and arc2  +
Personal tools
internal pages