diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/.DS_Store b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/.DS_Store index 2e326c57..9b6bd093 100644 Binary files a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/.DS_Store and b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/.DS_Store differ diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/.DS_Store b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/.DS_Store index 7e824193..a65dd5f0 100644 Binary files a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/.DS_Store and b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/.DS_Store differ diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/index.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/index.php index ce722855..d12a9f85 100644 --- a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/index.php +++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/index.php @@ -1,65 +1,31 @@ - - - - - - + -
- - This Page is only a small Semantic Web Application which allows you to find information - about movies using "Linked Movie Data Base" and "Freebase". -

- Which Movie are you interested in? -
- - -
- - Getting Infos for: " . $movieTitleByUser; - - echo '
searching . . .

'; - - - - $mainController = new controller(); - $mainController->getData($movieTitleByUser); - - - - } - - ?> - - - - -

- linkedmdb.org -
- freebase.com - -
- - + +include 'view/view.php'; +include 'logic/controller.php'; + +if(isset($_POST['buttonPressed'])){ + + + $movieTitleByUser =$_POST['movieTitleByUser']; + + //echo "

Getting Infos for: " . $movieTitleByUser; + + //echo '
searching . . .

'; + + + + $mainController = new controller(); + $mainController->getData($movieTitleByUser, 1); + + + + } + +?> \ No newline at end of file diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/rdfLib/.DS_Store b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/.DS_Store similarity index 89% rename from ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/rdfLib/.DS_Store rename to ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/.DS_Store index 0b1b5236..ad226433 100644 Binary files a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/rdfLib/.DS_Store and b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/.DS_Store differ diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/controller.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/controller.php index c6ff86cd..c9f871c6 100644 --- a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/controller.php +++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/controller.php @@ -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("
"); - - foreach( $fields as $field ) - { - print "
$field:
"; - } - //print ""; - while( $row = sparql_fetch_array( $result ) ) - { - //print ""; - foreach( $fields as $field ) - { - if($field == "links"){ - print "$row[$field]
"; - }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); + } + + } + } ?> diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/dbpediaController.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/dbpediaController.php index 1f8d4ca4..72aada4a 100644 --- a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/dbpediaController.php +++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/dbpediaController.php @@ -1,14 +1,10 @@ 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 ); + + } + + } diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/freebaseController.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/freebaseController.php deleted file mode 100644 index 28e3090a..00000000 --- a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/freebaseController.php +++ /dev/null @@ -1,31 +0,0 @@ -buildNamespaces(); - - - $sparql = ""; - - return $result = $db->query( $sparql ); - - - } -} - -?> diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/mdbController.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/mdbController.php index 292c299c..90eeef89 100644 --- a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/mdbController.php +++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/mdbController.php @@ -1,97 +1,138 @@ 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 + } + } ?> diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.properties b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.properties index 49665daa..87dd3455 100644 --- a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.properties +++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.properties @@ -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/ diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml.0.nblh~ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml.0.nblh~ deleted file mode 100644 index c1f155a7..00000000 --- a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml.0.nblh~ +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml.1.nblh~ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml.1.nblh~ deleted file mode 100644 index c1f155a7..00000000 --- a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml.1.nblh~ +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.xml b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.xml index 81dca232..60d3060a 100644 --- a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.xml +++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.xml @@ -3,7 +3,7 @@ org.netbeans.modules.php.project - SemanticWebApp + PhpProject1 diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/dbpedia.png b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/dbpedia.png new file mode 100644 index 00000000..0dad221b Binary files /dev/null and b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/dbpedia.png differ diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/freebase.jpg b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/freebase.jpg similarity index 100% rename from ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/freebase.jpg rename to ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/freebase.jpg diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/mdb.png b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/mdb.png similarity index 100% rename from ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/mdb.png rename to ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/mdb.png diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/view.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/view.php new file mode 100644 index 00000000..5eb8f35a --- /dev/null +++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/view/view.php @@ -0,0 +1,96 @@ +"); + + if( !$result ) + { print sparql_errno() . ": " . sparql_error(). "\n"; exit; } + + + $fields = $result->field_array( $result ); + + + print("
"); + + foreach( $fields as $field ) + { + print "
$field:
"; + $info = $field; //save typ of object + } + while( $row = sparql_fetch_array( $result ) ) + { + foreach( $fields as $field ) + { + if($ref == 1){ + print "$row[$field]
"; + }else if($ref == 2){ + print "" . $row[$field] . "
"; + }else if($ref == 3){ + print "\"$row[$field]\""; + }else{ + print $row[$field] . "
"; + } + + + } + + } + + print("
"); + } + +} + +?> + + + + + + + + + +
+ + This Page is only a small Semantic Web Application which allows you to find information + about movies using "Linked Movie Data Base" and "DBpedia". +

+ Which Movie are you interested in? +
+ + +
+ + +

+ linkedmdb.org +
+ dbpedia.org + +
+ + + + + +