public function get_top_recommendations($query_name, $number) { $auth = Clarifai::get_auth($this->client_id, $this->client_secret); $matches = $this->get_initial_recommendations($query_name, $number); // Get initial recommended movies $number = count($matches); if ($number <= 0) { return NULL; } $query = new Search($query_name); $query_links = $query->get_links(); // Get links to query stills using Google Images API $links = array(); $links[$query_name] = $query_links; // Array containing links foreach ($matches as $match) { // Get stills to each of the initial recommended movies $match_search = new Search($match); $links[$match] = $match_search->get_links(); // Add links to array } $tags_array = Clarifai::get_unique_tags($links, $auth); // Get tags using Clarifai API $results = array(); foreach (array_slice($tags_array, 1, $number) as $key => $tags) { $results[$key] = count(array_intersect($tags, $tags_array[$query_name])); } arsort($results); return array_keys($results); }
public function get_tags($auth) { foreach ($this->still_urls as $still_url) { $tags_search = Clarifai::get_tags($still_url, $auth); if (is_array($tags_search)) { foreach ($tags_search as $tag) { if (!in_array($tag, $this->tags)) { $this->tags[] = $tag; } } } } return $this->tags; }