-
Notifications
You must be signed in to change notification settings - Fork 89
Resource Helper Class
arenou edited this page Aug 24, 2015
·
2 revisions
While ARC is mainly based on array structures, it also supports a basic "Resource" helper class for convenient access to elements in an ARC resource index. The resource class can auto-fetch and cache Linked Data, use a passed list of predicates/objects, or query an ARC RDF store (local or remote).
$conf = array(
'ns' => array(
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'dbpedia' => 'http://dbpedia.org/ontology/'
),
...
);
$res = ARC2::getResource($conf);
$res->setURI('http://dbpedia.org/resource/Madrid');
If no store or predicate array is set (see below), the resource object will automatically retrieve RDF data from the resource URI.
$population = $res->getPropValue('dbpedia:populationTotal');
$props = array(
"http://xmlns.com/foaf/0.1/name" => array(...),
...
);
$res->setProps($props);
$store = ARC2::getStore($conf);
$res->setStore($store);
$labels = $res->getPropValues('rdfs:label');
$props = $res->getProps();
$labels_full = $res->getProps('rdfs:label');
$is_eu_capital = $res->hasPropValue('rdf:type', 'http://dbpedia.org/class/yago/CapitalsInEurope');