<?php $DEBUG = true; require_once __DIR__ . "/../parsing/parseQuery.php"; use parsing\ParseQuery; $queries = array("romantic comedies" => "feeling=>genre + genre(alias)", "comedies from before 1970" => "genre(alias) + daterange", "funny family movie" => "emotion->genre + genre", "thriller movies" => "genre", "sad movies" => "emotion->2 OK genres", "Scary movies rated higher than 7 on imdb" => "emotion(case)->genre + rating/imdb", "movies directed by Tom Hanks with rating higher than 61% on rotten tomato" => "this should check both critic and audiance and if matches either, report", "romantic comedy from before 1970" => "genre info", "romance or drama with ryan Gosling" => "logical and genre", "not thriller by Al Pacino" => "negative logical", "scary movie" => "return both the comedy and thrillers/horrors", "before sunset" => "return the movie", "movies like the expandables" => "pretty clear..", "Movies with Ryan Gosling before 2000" => "claer...", "quentin tarantino movies" => "ja..", "quenton tarantino movies" => "typo in his name", "ryan gosling movies like Drive" => "should match -movies like-", "movies like Drive and drama" => "should match -movies like-", "Hitchhiker's Guide to the Galaxy" => "missing 'the' from the beginning", "The Princess Bride" => "easy", "tarantino 2009" => "ahh", "movies since 2000 that are PG-13" => "jesus christ", "family movie that is shorter than 90 minutes" => "why not?", "Bob & Carol & Ted & Alice" => "special characters...", "Don't Look Back" => "more special characters...", "8 1/2" => "We are building something insanely robust here"); $iter = 0; foreach ($queries as $query => $descr) { # if ($iter > 3) break; $iter += 1; echo "-- query: {$query}\n"; echo " {$descr}\n"; $movieMatching = ParseQuery::parseQuery($query); $tmp = array(); foreach ($movieMatching as $movie) { $tmp[] = $movie->movie->mName . $movie->relevance; } echo "Number of matching results: "; print_r(count($tmp)); // //var_dump($tmp); echo "\n\n"; }
["movie"=<movie class>, "relevance"=<double between 0 and 1>] */ header('Content-Type: application/json'); require_once __DIR__ . "/../includes/parsing/parseQuery.php"; use parsing\ParseQuery as Pq; /* if started from commandline, wrap parameters to $_POST and $_GET */ if (!isset($_SERVER["HTTP_HOST"])) { parse_str($argv[1], $_GET); # parse_str($argv[1], $_POST); } $response = array("success" => false); if (isset($_GET['q'])) { $query = $_GET['q']; # echo "$query\n"; try { # Check if the front-end needs a specific page. If so, return the appropriate chunk $pageSize = -1; $pageNum = 0; if (isset($_GET['p']) && isset($_GET['s'])) { $pageSize = $_GET['s']; $pageNum = $_GET['p']; } $movies = Pq::parseQuery($query, $pageSize, $pageNum); # print_r($movies); $response["success"] = true; $response["data"] = $movies; } catch (Exception $e) { // TODO this doesn't seem right.. } } echo json_encode($response);