Skip to content

Instantly share code, notes, and snippets.

@njh
Last active August 29, 2015 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njh/4e6f78939f3cb0a33c81 to your computer and use it in GitHub Desktop.
Save njh/4e6f78939f3cb0a33c81 to your computer and use it in GitHub Desktop.
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "EasyRdf.php";
EasyRdf_Namespace::set('ont', 'http://www.semanticweb.org/augunipov/ontologies/m_ontology#');
$graph = new EasyRdf_Graph();
$graph->parseFile('29138.ttl', 'turtle');
echo "<ul>\n";
foreach($graph->allOfType('ont:Book') as $book) {
if (preg_match('/Yankee/i', $book->get('ont:bookHasTitle'))) {
echo "<li>Author: ".$book->get("^ont:authorHasAuthorshipOfBook/ont:authorName")."</li>\n";
}
}
echo "</ul>\n";
@prefix ont: <http://www.semanticweb.org/augunipov/ontologies/m_ontology#> .
<http://example.com/author1>
a ont:Author;
ont:authorName "Mary Ann Rodman";
ont:authorHasAuthorshipOfBook <http://example.com/book1> .
<http://example.com/author2>
a ont:Author;
ont:authorName "William Boyd";
ont:authorHasAuthorshipOfBook <http://example.com/book2> .
<http://example.com/author3>
a ont:Author;
ont:authorName "felipezkn";
ont:authorHasAuthorshipOfBook <http://example.com/book3> .
<http://example.com/book1>
a ont:Book;
ont:bookhasIsbn <urn:isbn:0746067496>;
ont:bookHasTitle "Yankee Girl" .
<http://example.com/book2>
a ont:Book;
ont:bookhasIsbn <urn:isbn:0140093478>;
ont:bookHasTitle "On the yankee station" .
<http://example.com/book3>
a ont:Book;
ont:bookHasTitle "How to run a query against a local RDF file" .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment