示例#1
0
    def get_artists_from_echonest(self):
        """Get list of the artist for the metadata of the score from the echonest extractArtist method

        Returns:
            list of tuple(artist id, artist name)

        """

        query = self.get_metadata_text()
        query = utils.remove_multi_spaces_from_text(query)
        return echonest.extract_artist_from_text(query.lower())
示例#2
0
    def get_queries(self):
        """Get list of queries from the metadata of the score for querying audio sources spotify or echonest

        The list of queries are created from title composer and subtitle of the score.
        From lower index to higher of the list strictness of the length and coverage of the query decreases and probability of finding results for the query increases:

        | strictness:query 
        | 0:title + composer + subtitle 
        | 1:title + composer + subtitle with stopwords removed
        | 2:title + composer
        | 3:title + composer with stopwords removed
        | 4:title
        | 5:title with stopwords removed

        | Identical queries with lower strictness removed from the list

        Returns:
            list of tuples (query,strictness)
        """

        tokens = [self.title, self.composer, self.subtitle]
        for token in tokens:
            token = ' '.join(token.split())
        queries = []
        query_temp = []
        j = 0
        for i in range(len(tokens), 0, -1):
            query = ' '.join(tokens[:i])
            query = utils.remove_multi_spaces_from_text(query)
            query = utils.normalize(query)
            if query not in query_temp:
                queries.append((query, 2 * j))
                query_temp.append(query)
            queryFiltered = utils.filter_text(query)
            if queryFiltered != query:
                queryFiltered = ' '.join(queryFiltered.split())
                if queryFiltered not in query_temp:
                    queries.append((queryFiltered, 2 * j + 1))
            j = j + 1
        return queries