Beispiel #1
0
def get_musics_from_file(file_name, list_of_all_tags):
    musics = []
    for line in get_content_from_file(file_name):
        list_from_line = line.strip().split()
        music = Music(list_from_line[0], list_from_line[1:], list_of_all_tags)
        musics.append(music)
    return musics
Beispiel #2
0
def get_set_of_tags_from_file(file_name):
    content = get_content_from_file(file_name)
    tags = set()
    for line in content:
        tags_from_line = line.strip().split()[1:]
        tags = tags.union(set(tags_from_line))
    return tags
Beispiel #3
0
def get_centroids_from_file(musics, k, file_name):
    centroids = []
    for line in get_content_from_file(file_name):
        try:
            centroids.append(Point(musics[int(line)].point.vector))
        except IndexError:
            exit('Specified observation ID doesn\'t exist')
    if len(centroids) != k:
        exit('Specified K differs from number of cluster in file')
    return centroids