-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (39 loc) · 1.35 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
__author__ = 'luke.luke'
import dbWrapper
import os
import csv
import numpy
class driver:
def __init__(self):
self.db = dbWrapper.db()
self.vectorPath = os.path.normpath('C:/Dev/bakeOff/bakeOff/ent12vq/')
def generateSongByFeatureMatrix(self):
artists = self.db.fetchArtistIDs(200)
ids = self.db.fetchTrackIDs(artists)
songByFeature = list()
index = 0;
self.songIndex = dict()
for id in ids:
if type(id) is tuple:
id = id[0]
vector = open(self.vectorPath + "\\" + str(id) + ".ent12-vq-full512-01.csv", 'r')
reader = csv.reader(vector, dialect='excel')
songByFeature.append(list())
self.songIndex[str(id)] = index
index+=1
value = reader.next()
while True:
try:
songByFeature[self.songIndex[str(id)]].append(float(value[0]))
value = reader.next()
except StopIteration as error:
break
return songByFeature
def dotProductSelf(self, matrix):
result = numpy.inner(matrix, matrix)
return result
def makeArtistByArtist(self, songBySong):
for id in self.songIndex:
driver = driver()
matrix = driver.generateSongByFeatureMatrix()
matrix = driver.dotProductSelf(matrix)