SemanticWebApp
This commit is contained in:
parent
76408c014f
commit
d8791d5824
Binary file not shown.
Binary file not shown.
@ -1,65 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<?php
|
||||
/**
|
||||
* Description of index
|
||||
*
|
||||
* @author Michael Scholz | Ulf Gebhardt
|
||||
*/
|
||||
|
||||
<body>
|
||||
<div align=center>
|
||||
|
||||
This Page is only a small Semantic Web Application which allows you to find information
|
||||
about movies using "Linked Movie Data Base" and "Freebase".
|
||||
</p>
|
||||
Which Movie are you interested in?</tab>
|
||||
<form method="post" action="">
|
||||
<input type="text" name="movieTitleByUser" size="45">
|
||||
<input type="submit" name="buttonPressed" value="Search">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
include 'logic/controller.php';
|
||||
|
||||
if(isset($_POST['buttonPressed'])){
|
||||
|
||||
|
||||
|
||||
$movieTitleByUser =$_POST['movieTitleByUser'];
|
||||
|
||||
echo "</p>Getting Infos for: " . $movieTitleByUser;
|
||||
|
||||
echo '</br><progress id="p" value=$counter max="100">searching . . .</p></progress>';
|
||||
|
||||
|
||||
|
||||
$mainController = new controller();
|
||||
$mainController->getData($movieTitleByUser);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- <section>
|
||||
<p>Progress: <progress id="p" max=100><span>0</span>%</progress></p>
|
||||
<script>
|
||||
var progressBar = document.getElementById('p');
|
||||
function updateProgress(newValue) {
|
||||
progressBar.value = newValue;
|
||||
progressBar.getElementsByTagName('span')[0].textContent = newValue;
|
||||
}
|
||||
</script>
|
||||
</section>-->
|
||||
|
||||
|
||||
|
||||
</p>
|
||||
<a href="http://www.linkedmdb.org/" target="_blank"><img src="logos/mdb.png" alt="linkedmdb.org"></a>
|
||||
</br>
|
||||
<a href="http://www.freebase.com/" target="_blank"><img src="logos/freebase.jpg" alt="freebase.com"></a>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
include 'view/view.php';
|
||||
include 'logic/controller.php';
|
||||
|
||||
if(isset($_POST['buttonPressed'])){
|
||||
|
||||
|
||||
$movieTitleByUser =$_POST['movieTitleByUser'];
|
||||
|
||||
//echo "</p>Getting Infos for: " . $movieTitleByUser;
|
||||
|
||||
//echo '</br><progress id="p" value=$counter max="100">searching . . .</p></progress>';
|
||||
|
||||
|
||||
|
||||
$mainController = new controller();
|
||||
$mainController->getData($movieTitleByUser, 1);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Binary file not shown.
@ -2,24 +2,50 @@
|
||||
/**
|
||||
* Description of controller
|
||||
*
|
||||
* @author Michael
|
||||
* @author Michael Scholz | Ulf Gebhardt
|
||||
*/
|
||||
|
||||
|
||||
|
||||
include_once './rdfLib/sparqllib.php';
|
||||
include_once dirname(__FILE__) . '/../rdfLib/sparqllib.php';
|
||||
include_once dirname(__FILE__) . '/../view/view.php';
|
||||
//include_once '../lib/sparqllib.php';
|
||||
//include_once '../view/view.php';
|
||||
include_once 'mdbController.php';
|
||||
include_once 'freebaseController.php';
|
||||
include_once 'dbpediaController.php';
|
||||
|
||||
|
||||
|
||||
if(isset($_GET['title']) || isset($_GET['thing'])){
|
||||
|
||||
$title = $_GET['title'];
|
||||
$thing = $_GET['thing'];
|
||||
|
||||
$controller = new controller();
|
||||
|
||||
|
||||
if($thing == "actors" || $thing == 'writers' || $thing == 'director' || $thing == 'editor'){
|
||||
|
||||
$controller->getData($title, 3); //get persondata from dbpedia
|
||||
|
||||
}else if($thing == "filmtitle"){
|
||||
|
||||
$controller->getData($title, 2); //get filmdata form linkedopenmdb
|
||||
|
||||
}else{
|
||||
|
||||
//do nothing
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class controller {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Build the most important namespaces
|
||||
public function buildNamespaces(){
|
||||
sparql_ns("owl", "http://www.w3.org/2002/07/owl#");
|
||||
sparql_ns("xsd", "http://www.w3.org/2001/XMLSchema#");
|
||||
@ -28,81 +54,70 @@ class controller {
|
||||
sparql_ns("foaf", "http://xmlns.com/foaf/0.1/");
|
||||
sparql_ns("dc", "http://purl.org/dc/elements/1.1/");
|
||||
sparql_ns("linkedmdbRes", "http://data.linkedmdb.org/resource/movie/");
|
||||
sparql_ns("fn", "http://www.w3.org/2005/xpath-functions#");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Funktion organisiert die verschiedenen Quellen und gibt diese
|
||||
* an die View weiter.
|
||||
*
|
||||
*
|
||||
* Gets Data from the other controllers
|
||||
*
|
||||
* @param type $searchString
|
||||
* @param type $data
|
||||
*/
|
||||
public function getData($movieTitle){
|
||||
|
||||
|
||||
|
||||
$resultsReady = false;
|
||||
|
||||
$mdbC = new mdbController();
|
||||
$freebaseC = new freebaseController();
|
||||
$dbpediaC = new dbpediaController;
|
||||
|
||||
$result = $mdbC->getMovieData($movieTitle);
|
||||
|
||||
$resultsReady = true;
|
||||
|
||||
//$this->printData($result);
|
||||
|
||||
|
||||
//return resultsReady;
|
||||
//$result = $freebaseC->getData($movieTitle);
|
||||
|
||||
// $result = $dbpediaC->getPersonData($movieTitle);
|
||||
|
||||
//$resultsReady = true;
|
||||
|
||||
|
||||
|
||||
|
||||
if( !$result )
|
||||
{ print sparql_errno() . ": " . sparql_error(). "\n"; exit; }
|
||||
|
||||
|
||||
foreach($result as $result){
|
||||
|
||||
|
||||
|
||||
$fields = $result->field_array( $result );
|
||||
|
||||
|
||||
print("<div text-align=left>");
|
||||
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
print "<br><b>$field:</b><br>";
|
||||
}
|
||||
//print "</tr>";
|
||||
while( $row = sparql_fetch_array( $result ) )
|
||||
{
|
||||
//print "<tr>";
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
if($field == "links"){
|
||||
print "<a href=\"$row[$field]\" target=blank>$row[$field]</a><br>";
|
||||
}else
|
||||
{
|
||||
print "$row[$field], ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public function getData($searchString, $data){
|
||||
|
||||
|
||||
$view = new view();
|
||||
|
||||
if($data == 1){
|
||||
|
||||
$mdbC = new mdbController();
|
||||
|
||||
$result = $mdbC->getOriginalFilmtitle($searchString);
|
||||
//ab hier schmiert es ab!
|
||||
$view->printSparqlResult($result, 1);
|
||||
|
||||
}
|
||||
if($data == 2){
|
||||
|
||||
$mdbC = new mdbController();
|
||||
|
||||
$result = $mdbC->getDate($searchString);
|
||||
$view->printSparqlResult($result, 0);
|
||||
|
||||
$result = $mdbC->getRuntime($searchString);
|
||||
$view->printSparqlResult($result, 0);
|
||||
|
||||
$result = $mdbC->getActors($searchString);
|
||||
$view->printSparqlResult($result, 1);
|
||||
|
||||
$result = $mdbC->getWriters($searchString);
|
||||
$view->printSparqlResult($result, 1);
|
||||
|
||||
$result = $mdbC->getDirectors($searchString);
|
||||
$view->printSparqlResult($result, 1);
|
||||
|
||||
$result = $mdbC->getEditors($searchString);
|
||||
$view->printSparqlResult($result, 1);
|
||||
|
||||
$result = $mdbC->getLinks($searchString);
|
||||
$view->printSparqlResult($result, 2);
|
||||
}
|
||||
if($data == 3){
|
||||
|
||||
$dbpC = new dbpediaController();
|
||||
$result = $dbpC->getPersonData($searchString);
|
||||
$view->printSparqlResult($result, 0);
|
||||
|
||||
$result = $dbpC->getPersonPicture($searchString);
|
||||
$view->printSparqlResult($result, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1,14 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of dbpediaController
|
||||
*
|
||||
* @author Michael
|
||||
* @author Michael Scholz | Ulf Gebhardt
|
||||
*/
|
||||
class dbpediaController extends controller{
|
||||
|
||||
@ -16,14 +12,14 @@ class dbpediaController extends controller{
|
||||
public function getPersonData($personName){
|
||||
|
||||
|
||||
$db = sparql_connect("http://dpbedia.org/sparql");
|
||||
$db = sparql_connect("http://dbpedia.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
|
||||
|
||||
$sparql = "SELECT ?actors WHERE { ?film rdfs:label \"". $personName . "\" .
|
||||
?film linkedmdbRes:actor ?actor .
|
||||
?actor linkedmdbRes:actor_name ?actors}
|
||||
";
|
||||
$sparql = "select ?text where { ?person foaf:name \"" . $personName . "\"@en ;
|
||||
dbpedia-owl:abstract ?text .
|
||||
FILTER langMatches(lang(?text), \"EN\") .
|
||||
}";
|
||||
|
||||
return $result = $db->query( $sparql );
|
||||
|
||||
@ -33,6 +29,21 @@ class dbpediaController extends controller{
|
||||
}
|
||||
|
||||
|
||||
public function getPersonPicture($personName){
|
||||
|
||||
$db = sparql_connect("http://dbpedia.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
|
||||
|
||||
$sparql = "select ?personImage where { ?person foaf:name \"" . $personName . "\"@en ;
|
||||
dbpedia-owl:thumbnail ?personImage .
|
||||
}";
|
||||
|
||||
return $result = $db->query( $sparql );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of freebaseController
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
class freebaseController extends controller{
|
||||
//put your code here
|
||||
|
||||
|
||||
public function getPersonData($personName){
|
||||
|
||||
$db = sparql_connect("");
|
||||
$this->buildNamespaces();
|
||||
|
||||
|
||||
$sparql = "";
|
||||
|
||||
return $result = $db->query( $sparql );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,97 +1,138 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of mdbController
|
||||
*
|
||||
* @author Michael
|
||||
* @author Michael Scholz | Ulf Gebhardt
|
||||
*/
|
||||
class mdbController extends controller{
|
||||
|
||||
|
||||
|
||||
public function getMovieData($movieTitle){
|
||||
|
||||
|
||||
public function getOriginalFilmtitle($movieTitle){
|
||||
|
||||
|
||||
$result = array();
|
||||
$db = sparql_connect("http://data.linkedmdb.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
//film titles
|
||||
$sparql = "SELECT ?filmtitle WHERE { ?film rdfs:label ?filmtitle .
|
||||
FILTER regex(?filmtitle, \"" . $movieTitle . "\", \"i\") .
|
||||
}";
|
||||
|
||||
|
||||
return $db->query( $sparql ); //returns a sparql result
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getRuntime($movieTitle){
|
||||
|
||||
$db = sparql_connect("http://data.linkedmdb.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
|
||||
|
||||
//runtime
|
||||
$sparql = "SELECT ?runtime WHERE { ?film rdfs:label \"". $movieTitle . "\" .
|
||||
?film linkedmdbRes:runtime ?runtime . }";
|
||||
$sparql = "SELECT ?runtime WHERE { ?film rdfs:label \"". $movieTitle . "\" ;
|
||||
linkedmdbRes:runtime ?runtime . }";
|
||||
|
||||
|
||||
$result[0] = $db->query( $sparql );
|
||||
|
||||
return $db->query( $sparql ); //returns a sparql result
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getWriters($movieTitle){
|
||||
|
||||
$db = sparql_connect("http://data.linkedmdb.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
|
||||
//writers
|
||||
$sparql = "SELECT ?writers WHERE { ?film rdfs:label \"". $movieTitle . "\" .
|
||||
?film linkedmdbRes:writer ?writerL .
|
||||
$sparql = "SELECT ?writers WHERE { ?film rdfs:label \"". $movieTitle . "\" ;
|
||||
linkedmdbRes:writer ?writerL .
|
||||
?writerL linkedmdbRes:writer_name ?writers . }";
|
||||
|
||||
|
||||
$result[1] = $db->query( $sparql );
|
||||
|
||||
|
||||
|
||||
//actors
|
||||
$sparql = "SELECT ?actors WHERE { ?film rdfs:label \"". $movieTitle . "\" .
|
||||
?film linkedmdbRes:actor ?actor .
|
||||
?actor linkedmdbRes:actor_name ?actors}
|
||||
|
||||
|
||||
ORDER BY ?actors";
|
||||
|
||||
$result[2] = $db->query( $sparql );
|
||||
|
||||
|
||||
|
||||
//date
|
||||
$sparql = "SELECT ?date WHERE { ?film rdfs:label \"". $movieTitle . "\" .
|
||||
?film linkedmdbRes:initial_release_date ?date .}";
|
||||
|
||||
$result[3] = $db->query( $sparql );
|
||||
|
||||
|
||||
|
||||
//director
|
||||
$sparql = "SELECT ?director WHERE { ?film rdfs:label \"". $movieTitle . "\" .
|
||||
?film linkedmdbRes:director ?directorL .
|
||||
?directorL linkedmdbRes:director_name ?director . }";
|
||||
|
||||
$result[4] = $db->query( $sparql );
|
||||
|
||||
|
||||
|
||||
//editors
|
||||
$sparql = "SELECT DISTINCT ?editor WHERE { ?film rdfs:label \"". $movieTitle . "\" .
|
||||
?film linkedmdbRes:editor ?editorL .
|
||||
?editorL linkedmdbRes:editor_name ?editor . }";
|
||||
|
||||
$result[5] = $db->query( $sparql );
|
||||
|
||||
|
||||
|
||||
//Links
|
||||
$sparql = "SELECT ?links WHERE { ?film rdfs:label \"". $movieTitle . "\" .
|
||||
?film foaf:page ?links . }";
|
||||
|
||||
$result[6] = $db->query( $sparql );
|
||||
|
||||
|
||||
return $result;
|
||||
return $db->query( $sparql ); //returns a sparql result
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getActors($movieTitle){
|
||||
|
||||
$db = sparql_connect("http://data.linkedmdb.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
|
||||
//actors
|
||||
$sparql = "SELECT ?actors WHERE { ?film rdfs:label \"". $movieTitle . "\" ;
|
||||
linkedmdbRes:actor ?actor .
|
||||
?actor linkedmdbRes:actor_name ?actors}
|
||||
ORDER BY ?actors";
|
||||
|
||||
|
||||
return $db->query( $sparql ); //returns a sparql result
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getDate($movieTitle){
|
||||
|
||||
$db = sparql_connect("http://data.linkedmdb.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
|
||||
//date
|
||||
$sparql = "SELECT ?date WHERE { ?film rdfs:label \"". $movieTitle . "\" ;
|
||||
linkedmdbRes:initial_release_date ?date .}";
|
||||
|
||||
return $db->query( $sparql ); //returns a sparql result
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getDirectors($movieTitle){
|
||||
|
||||
$db = sparql_connect("http://data.linkedmdb.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
|
||||
//director
|
||||
$sparql = "SELECT ?director WHERE { ?film rdfs:label \"". $movieTitle . "\" ;
|
||||
linkedmdbRes:director ?directorL .
|
||||
?directorL linkedmdbRes:director_name ?director . }";
|
||||
|
||||
return $db->query( $sparql ); //returns a sparql result
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getEditors($movieTitle){
|
||||
|
||||
$db = sparql_connect("http://data.linkedmdb.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
|
||||
//editors
|
||||
$sparql = "SELECT DISTINCT ?editor WHERE { ?film rdfs:label \"". $movieTitle . "\" ;
|
||||
linkedmdbRes:editor ?editorL .
|
||||
?editorL linkedmdbRes:editor_name ?editor . }";
|
||||
|
||||
return $db->query( $sparql ); //returns a sparql result
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getLinks($movieTitle){
|
||||
|
||||
$db = sparql_connect("http://data.linkedmdb.org/sparql");
|
||||
$this->buildNamespaces();
|
||||
|
||||
//Links
|
||||
$sparql = "SELECT ?links WHERE { ?film rdfs:label \"". $movieTitle . "\" ;
|
||||
foaf:page ?links . }";
|
||||
|
||||
return $db->query( $sparql ); //returns a sparql result
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
copy.src.files=true
|
||||
copy.src.target=/Applications/XAMPP/htdocs/SemanticWebApp
|
||||
copy.src.files=false
|
||||
copy.src.target=
|
||||
index.file=index.php
|
||||
run.as=LOCAL
|
||||
url=http://localhost/SemanticWebApp/
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||
</project-private>
|
||||
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||
</project-private>
|
||||
@ -3,7 +3,7 @@
|
||||
<type>org.netbeans.modules.php.project</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/php-project/1">
|
||||
<name>SemanticWebApp</name>
|
||||
<name>PhpProject1</name>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Description of view
|
||||
*
|
||||
* @author Michael Scholz | Ulf Gebhardt
|
||||
*/
|
||||
|
||||
class view{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Print the Sparql resultset in HTML
|
||||
*
|
||||
* @param type $result
|
||||
* @param type $ref
|
||||
*
|
||||
*/
|
||||
public function printSparqlResult($result, $ref){
|
||||
|
||||
|
||||
|
||||
print("<div align=center>");
|
||||
|
||||
if( !$result )
|
||||
{ print sparql_errno() . ": " . sparql_error(). "\n"; exit; }
|
||||
|
||||
|
||||
$fields = $result->field_array( $result );
|
||||
|
||||
|
||||
print("<div text-align=left>");
|
||||
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
print "<br><b>$field:</b><br>";
|
||||
$info = $field; //save typ of object
|
||||
}
|
||||
while( $row = sparql_fetch_array( $result ) )
|
||||
{
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
if($ref == 1){
|
||||
print "<a href=\"/SemanticWebApp/logic/controller.php?title=$row[$field]&thing=$info\">$row[$field]</a><br>";
|
||||
}else if($ref == 2){
|
||||
print "<a href=$row[$field] target=blank>" . $row[$field] . "</a><br>";
|
||||
}else if($ref == 3){
|
||||
print "<img src=\"$row[$field]\" alt=\"$row[$field]\">";
|
||||
}else{
|
||||
print $row[$field] . "<br>";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print("</div>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div align=center>
|
||||
|
||||
This Page is only a small Semantic Web Application which allows you to find information
|
||||
about movies using "Linked Movie Data Base" and "DBpedia".
|
||||
</p>
|
||||
Which Movie are you interested in?</tab>
|
||||
<form method="post" action="">
|
||||
<input type="text" name="movieTitleByUser" size="45">
|
||||
<input type="submit" name="buttonPressed" value="Search">
|
||||
</form>
|
||||
|
||||
|
||||
</p>
|
||||
<a href="http://www.linkedmdb.org/" target="_blank"><img src="./view/mdb.png" alt="linkedmdb.org"></a>
|
||||
</br>
|
||||
<a href="http://www.dbpedia.org/" target="_blank"><img src="./view/dbpedia.png" alt="dbpedia.org"></a>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user