Beispiel #1
0
  /**
   * Recursive function to extract properties.
   *
   * @param string $uri
   *   URI of schema type.
   *
   * @return array|null
   *   Array of properties of the type and all parent types.
   */
  private function getProperties($uri) {
    $resource = array("type" => "uri", "value" => $uri);
    $property_list = $this->graph->resourcesMatching("http://schema.org/domainIncludes", $resource);
    $options = array();

    foreach ($property_list as $value) {
      // Omit deprecated properties.
      if ($value->get("schema:supersededBy")) {
        continue;
      }
      $options[$value->shorten()] = $value->get("rdfs:label")->getValue();
    }

    $parents = $this->graph->all($uri, "rdfs:subClassOf");
    foreach ($parents as $value) {
      $options += $this->getProperties($value->getUri());
    }
    return $options;
  }
 public function testResourcesMatching()
 {
     $data = readFixture('foaf.json');
     $graph = new EasyRdf_Graph('http://example.com/joe/foaf.rdf', $data);
     $matched = $graph->resourcesMatching('foaf:name', 'Joe Bloggs');
     $this->assertEquals(1, count($matched));
     $this->assertEquals('http://www.example.com/joe#me', $matched[0]->getUri());
 }
Beispiel #3
0
<?php 
if (isset($_REQUEST['term'])) {
    $uri = "http://dbpedia.org/resource/" . $_REQUEST['term'];
    $graph = new EasyRdf_Graph($uri);
    $village = $graph->resource($uri);
    print content_tag('h2', $village->label($LANG));
    if ($village->get('foaf:depiction')) {
        print image_tag($village->get('foaf:depiction'), array('style' => 'max-width:400px;max-height:250px;'));
    }
    print content_tag('p', $village->get('rdfs:comment', $LANG));
    if ($village->get('geo:long')) {
        $ll = $village->get('geo:lat') . ',' . $village->get('geo:long');
        print "<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&amp;sll={$ll}&amp;output=embed'></iframe>";
    }
    echo "<br /><br />";
    echo $graph->dump();
} else {
    $uri = "http://dbpedia.org/resource/Category:Villages_in_Fife";
    $graph = new EasyRdf_Graph($uri);
    $category = $graph->resource($uri);
    foreach ($graph->resourcesMatching('skos:subject', $category) as $resource) {
        $term = str_replace('http://dbpedia.org/resource/', '', $resource);
        $label = urldecode(str_replace('_', ' ', $term));
        print '<li>' . link_to_self($label, 'term=' . $term) . "</li>\n";
    }
}
?>
</body>
</html>
Beispiel #4
0
    } elseif ($onto === 'tcmls') {
        $onto_file = "tcmdemoen.rdf";
        $namespace = 'http://www.example.com/';
    } elseif ($onto === 'tcmlm') {
        $onto_file = 'tcmlm-zhuling.rdf';
        $namespace = 'http://www.example.com/';
    }
} else {
    $onto_file = "tcmdemoen.rdf";
    $namespace = 'http://www.example.com/';
}
$graph = new EasyRdf_Graph("http://localhost/lod/" . $onto_file);
$graph->load();
if (isset($_GET['label'])) {
    $first = true;
    foreach ($graph->resourcesMatching("rdfs:label", $_GET['label']) as $r) {
        if ($first) {
            $localname = $r->localname();
        } else {
            echo "<p>" . $r . "</p>";
        }
    }
}
if (!isset($localname)) {
    render_warning("对不起!本系统没有相关实体的信息!下面显示的是'kideny_yang_deficiency(肾阳虚)'这一示例实体。");
    $localname = 'kideny_yang_deficiency';
}
?>
<div class="container">

Beispiel #5
0
$uniqid = uniqid();
$suchbegriff = str_replace(" ", "+", $_GET["qname"]);
//$suchbegriff='123apfelkuchen';
$rdf = "";
if (isset($_GET["rdf"])) {
    $rdf = $_GET["rdf"];
}
$basedir = dirname(realpath(__FILE__));
$root = $basedir;
$ldfu = $root . '/ldfu/bin/ldfu.sh';
$n3_programm = $root . '/n3-files/chefkoch.n3';
$input = 'http://manke-hosting.de/wrapper/index.php/explore/' . $suchbegriff;
$output = $root . '/output/' . $suchbegriff . '.nt';
if (!file_exists($output)) {
    $command = 'sh ' . $ldfu . ' ' . '-i ' . $input . ' ' . '-p ' . $n3_programm . ' ' . '-o ' . $output;
    shell_exec($command);
}
$graph->parseFile($output);
//$graph ->parseFile('/Users/raphaelmanke/Downloads/linked-data-fu-0.9.9/streuselkuchen3.nt');
//$me = $foaf->primaryTopic();
//echo $graph->dump('html');
$resources = $graph->resources();
$namespace = new EasyRdf_Namespace();
$namespace->set('rezept', "http://manke-hosting.de/ns-syntax#");
$rezepte = $graph->resourcesMatching('rezept:RezeptName');
if ($rdf == "true") {
    header("Content-Type: text/turtle; charset=utf-8");
    echo $graph->serialise("turtle");
} else {
    include 'results/rezept.php';
}
 public function testResourcesMatchingInverse()
 {
     $data = readFixture('foaf.json');
     $graph = new EasyRdf_Graph('http://example.com/joe/foaf', $data);
     $matched = $graph->resourcesMatching('^foaf:homepage');
     $this->assertCount(2, $matched);
     $this->assertSame('http://www.example.com/joe/', $matched[0]->getUri());
     $this->assertSame('http://www.example.com/project', $matched[1]->getUri());
 }