From: <an...@us...> - 2008-11-09 22:49:56
|
Revision: 1498 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1498&view=rev Author: anitaj Date: 2008-11-09 22:49:54 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/music-recommender/ajax.php trunk/src/music-recommender/index.php trunk/src/music-recommender/settings.ini Modified: trunk/src/music-recommender/ajax.php =================================================================== --- trunk/src/music-recommender/ajax.php 2008-11-07 18:41:48 UTC (rev 1497) +++ trunk/src/music-recommender/ajax.php 2008-11-09 22:49:54 UTC (rev 1498) @@ -36,7 +36,7 @@ // register functions $xajax->registerFunction("doSearch"); - +$xajax->registerFunction("doSearchTitle"); $xajax->processRequest(); // search for songs matching the search string @@ -57,21 +57,64 @@ LIMIT 1';*/ // unfortunately full text search does not work yet - I am in contact with Yves Raimond to find a solution // currently, we look for exact matches + $query = ' - SELECT ?artist ?name ?image ?homepage + PREFIX map: <file:/home/moustaki/work/motools/musicbrainz/d2r-server-0.4/mbz_mapping_raw.n3#> +PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> +PREFIX owl: <http://www.w3.org/2002/07/owl#> +PREFIX event: <http://purl.org/NET/c4dm/event.owl#> +PREFIX rel: <http://purl.org/vocab/relationship/> +PREFIX lingvoj: <http://www.lingvoj.org/ontology#> +PREFIX foaf: <http://xmlns.com/foaf/0.1/> +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> +PREFIX tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> +PREFIX db: <http://dbtune.org/musicbrainz/resource/> +PREFIX dc: <http://purl.org/dc/elements/1.1/> +PREFIX geo: <http://www.geonames.org/ontology#> +PREFIX bio: <http://purl.org/vocab/bio/0.1/> +PREFIX mo: <http://purl.org/ontology/mo/> +PREFIX vocab: <http://dbtune.org/musicbrainz/resource/vocab/> +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> +PREFIX mbz: <http://purl.org/ontology/mbz#> +SELECT ?homepage ?title ?image + WHERE { + ?artist a mo:MusicArtist . + ?artist foaf:name "'.$searchString.'" . + ?artist foaf:homepage ?homepage . + ?record foaf:maker ?artist . + ?record dc:title ?title . + ?record mo:image ?image . + + }'; + + /*$query = ' //altes Select + SELECT ?artist ?name ?image ?homepage ?title WHERE { ?artist a mo:MusicArtist . ?artist foaf:name "'.$searchString.'" . ?artist foaf:name ?name . ?artist foaf:img ?image . ?artist foaf:homepage ?homepage . + ?artist foaf:made ?album . + ?album dc:title ?title } - LIMIT 10'; + '; Ausgabe ! + $newContent .= '<img style="float:right" src="'.$bindings[0]->image->value.'" />'; + $newContent .= '<b>'.$bindings[0]->name->value.'</b><br />'; + $newContent .= '<a href="'.$bindings[0]->homepage->value.'">'.$bindings[0]->homepage->value.'</a><br />'; + $newContent .= 'TODO: make author name clickable such that people can get tracks from this artist and listen to them<br/>'; + + foreach($bindings as $binding) { + $speicherTitel[] .= $binding->title->value; + } + $newContent .= '<a href="">'.sizeof($speicherTitel).'</a><br />'; + */ /*PREFIX geo: <http://www.geonames.org/ontology#> PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#> SELECT DISTINCT ?an ?lat ?long ?name ?population - WHERE { + WHERE { ?album mo:track ?track . + ?track dc:title ?title . ?a a mo:MusicArtist; foaf:based_near ?place; foaf:name ?an; @@ -104,19 +147,93 @@ // var_dump($bindings); // $newContent = 'searching for '.$searchString.' ... not implemented <pre>test</pre>'; $newContent = '<h3>Search Results</h3>'; + //$speicher = $bindings->title->value; + if (sizeof($bindings) == 0){ throw new Exception('kein Ergebnis'); + } + + $newContent .= '<b>'.$bindings[0]->name->value.'</b><br />'; + $newContent .= '<a href="'.$bindings[0]->homepage->value.'">'.$bindings[0]->homepage->value.'</a><br />'; + $newContent .= 'TODO: make author name clickable such that people can get tracks from this artist and listen to them<br/>'; + foreach($bindings as $binding) { - $newContent .= '<img style="float:right" src="'.$binding->image->value.'" />'; - $newContent .= '<b>'.$binding->name->value.'</b><br />'; - $newContent .= '<a href="'.$binding->homepage->value.'">'.$binding->homepage->value.'</a><br />'; - $newContent .= 'TODO: make author name clickable such that people can get tracks from this artist and listen to them'; + $newContent .= '<div><b>'.$binding->title->value.'</b><br /></div>'; + $newContent .= '<div><img style="float:right" src="'.$binding->image->value.'" /><br /></div>'; } + //$newContent .= '<a href="">'.sizeof($speicherTitel).'</a><br />'; + } catch (Exception $e) { - $newContent = '<b>Search aborted: '.$e->getMessage().'</b>'; + $newContent = '<b>Suche ergibt: '.$e->getMessage().'</b>'; } $objResponse = new xajaxResponse(); $objResponse->assign("searchElement","innerHTML", $newContent); return $objResponse; } +function doSearchTitle($searchTitle) +{ + // ToDo: execute a SPARQL query (find labels matching search string) by contacting DL-Learner web service + + $queryTitle = ' + PREFIX map: <file:/home/moustaki/work/motools/musicbrainz/d2r-server-0.4/mbz_mapping_raw.n3#> +PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> +PREFIX owl: <http://www.w3.org/2002/07/owl#> +PREFIX event: <http://purl.org/NET/c4dm/event.owl#> +PREFIX rel: <http://purl.org/vocab/relationship/> +PREFIX lingvoj: <http://www.lingvoj.org/ontology#> +PREFIX foaf: <http://xmlns.com/foaf/0.1/> +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> +PREFIX tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> +PREFIX db: <http://dbtune.org/musicbrainz/resource/> +PREFIX dc: <http://purl.org/dc/elements/1.1/> +PREFIX geo: <http://www.geonames.org/ontology#> +PREFIX bio: <http://purl.org/vocab/bio/0.1/> +PREFIX mo: <http://purl.org/ontology/mo/> +PREFIX vocab: <http://dbtune.org/musicbrainz/resource/vocab/> +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> +PREFIX mbz: <http://purl.org/ontology/mbz#> +SELECT ?name ?recordname ?tracksname + WHERE { +?track a mo:Track . +?track dc:title "'.$searchTitle.'" . +?track foaf:maker ?artist. +?artist foaf:name ?name. +?track dc:title ?tracksname. + ?record mo:track ?track. +?record dc:title ?recordname. + } +'; + + + + try { + $connection = new DLLearnerConnection(); + $json = $connection->sparqlQuery($queryTitle); + $result = json_decode($json); + $bindings = $result->results->bindings; + + $newContent = '<h3>Search Results</h3>'; + //$speicher = $bindings->title->value; + + $newContent .= '<div style="float:left; width:50%;">'.Artist.'</div>'; + $newContent .= '<div style="float:left; width:50%;">'.Album.'</div><br />'; + //$newContent .= '<div style="float:right; width:30%;">'.Track.'</div></div>'; + + foreach($bindings as $binding) { + $newContent .= '<br /><div style="float:left; width:50%;">'.$binding->name->value.'</div>'; + $newContent .= '<div style="float:left; width:50%;">'.$binding->recordname->value.'</div><br /><br />'; + //$newContent .= '<div style="float:right; width:30%;">'.$binding->tracksname->value.'</div>'; + } + //$newContent .= '<a href="">'.sizeof($speicherTitel).'</a><br />'; + if(sizeof($bindings) <= 0){throw new Exception('nichts gefunden');} + + } catch (Exception $e) { + $newContent = '<b>Suche ergibt: '.$e->getMessage().'</b>'; + } + + $objResponse = new xajaxResponse(); + $objResponse->assign("searchElement","innerHTML", $newContent); + return $objResponse; +} + ?> \ No newline at end of file Modified: trunk/src/music-recommender/index.php =================================================================== --- trunk/src/music-recommender/index.php 2008-11-07 18:41:48 UTC (rev 1497) +++ trunk/src/music-recommender/index.php 2008-11-09 22:49:54 UTC (rev 1498) @@ -58,24 +58,45 @@ <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <?php $xajax->printJavascript('../music-recommender/xajax/'); ?> <script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script> + <style type="text/css"> + <!-- + body { height:100%;color: #000; background: #bff2bf; padding: 10px; margin: 1px; text-align: center; } + #a {padding:10px;margin:10px;height:86%;background: #dff9df;} + #b {padding:10px;margin:10px;height:86%;} + #c {padding:10px;margin:10px;height:86%;background: #669966;} + + //--></style> + </head> <body> - <h1>Music Recommender</h1> + <div id="a"> + <h1>Music Recommender</h1> + </div> + <div id="b"> <h2>Search</h2> <!-- search form --> <input type="text" id="label" /> - <button onclick="xajax_doSearch(document.getElementById('label').value);">search</button> - <p>Enter an artist and click the search button. (TODO: Enable search also for tracks and tags. Enable hitting enter instead of clicking button.)</p> + <button type="submit" onclick="xajax_doSearch(document.getElementById('label').value);">search</button> + <p>Enter an artist and click the search button. </p><!--(TODO: Enable search also for tracks and tags.)--> <p>Example artist: Allison Crowe</p> + </div> + <!-- suche nach Titlen --> + <div id="c" style="color: #fff;"> + <input type="text" id="label2" /> + <button type="submit" onclick="xajax_doSearchTitle(document.getElementById('label2').value);">Titlen</button> + <p>Enter a Title and click the Title button. </p> + </div> <!-- search result display --> - <div id="searchElement" style="max-width:500px;"></div> - + <div id="searchElement" style="max-width:500px;"> + </div> + <div id="song"> <h2>Song List</h2> <a href="http://mediaplayer.yahoo.com/example1.mp3">song 1</a> <br /> <a href="http://mediaplayer.yahoo.com/example2.mp3">song 2</a> <br /> <a href="http://mediaplayer.yahoo.com/example3.mp3">song 3</a> + </div> </body> </html> Modified: trunk/src/music-recommender/settings.ini =================================================================== --- trunk/src/music-recommender/settings.ini 2008-11-07 18:41:48 UTC (rev 1497) +++ trunk/src/music-recommender/settings.ini 2008-11-09 22:49:54 UTC (rev 1498) @@ -4,4 +4,5 @@ wsdlURL = "http://localhost:8181/services?wsdl" wsdlURLLocal= "main.wsdl" -endpointURL = "http://dbtune.org:2105/sparql/" +endpointURL = "http://dbtune.org/musicbrainz/sparql" +endpointURL1 = "http://dbtune.org:2105/sparql/" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |