def find_song(self, name, alt_titles=None, artists=None, collaborators=None, album=None, genres=None): ngrmas = extract_unique_normalized_ngrmas(name) candidate_songs = self._get_songs_with_best_idf(ngrmas, self._match_config.top_k_blocking_function()) candidate_songs = self._get_most_similar_songs(original_str=name, candidate_songs=candidate_songs, top_k_results=self._match_config.top_k_results()) return candidate_songs
def find_song(self, name, alt_titles=None, artists=None, collaborators=None, album=None, genres=None): ngrmas = extract_unique_normalized_ngrmas(name) candidate_songs = self._get_songs_with_best_idf(ngrmas, self._match_config.top_k_blocking_function()) candidate_songs = self._get_most_similar_songs(original_str=name, candidate_songs=candidate_songs, top_k_results=self._match_config.top_k_results()) if artists is not None: for an_artist in artists: candidate_songs = self._refine_songs_by_artist_name(candidate_songs, an_artist) candidate_songs = self._discard_results_with_low_total_score(candidate_songs, ORDER_FIND_SONG) candidate_songs.sort(reverse=True) return candidate_songs[:self._match_config.top_k_results()]
def find_artist(self, name, country=None, songs=None, albums=None, namevars=None, genres=None): """ Name should be provided and should be an string. Country is optional and is expected to be a string. The rest of the params could be an string or a list of strings, and they are optional. The method returns... :param name: :param songs: :param albums: :param namevars: :param genres: :return: """ # TODO: right now, just working with name ngrmas = extract_unique_normalized_ngrmas(name) # Done candidate_artists = self._get_artist_with_best_idf(ngrmas, self._match_config.top_k_blocking_function()) # Done candidate_artists = self._get_most_similar_artist(original_str=name, candidate_artist=candidate_artists, top_k_results=self._match_config.top_k_results()) # Done return candidate_artists # TODO : just adapt to other possible and probable formats.
def update_ngrams_of_entity(repo, entity_uri, str_text): tuples = [] for ngram in extract_unique_normalized_ngrmas(str_text): tuples.append((ngram, 1)) repo.update_ngrams_of_entity(entity=entity_uri, list_of_tuples_ngram_apparitions=tuples)