comparison core/magnatagatune/makro_import_magnatagatune.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 % makro_import_magnatatatune
2
3 csv2cell('annotations_final.csv','fromfile')
4 clip_info_final = csv2cell('clip_info_final.csv','fromfile');
5 comparisons_final = csv2cell('comparisons_final.csv','fromfile');
6
7 % tag annotations
8 annots = strcell2matrix(annotations_final,[1 0],[0 1]);
9 annots_descripts = {annotations_final{1,:}};
10 annots_filenames = cat(1,{annotations_final{:,1}},{annotations_final{:,end}})';
11
12 % comparison measures
13 comp = strcell2matrix(comparisons_final,[0 0], [0 3]);
14 comp_descripts = {comparisons_final{1,:}};
15
16 %%
17 % -----------------------------------------------------------
18 % ---
19 % part two: extracting and associating Genre
20 %
21 % at first we filter out the relevant positions in clip_info_final-
22 % ---
23
24 % prepare clip_info
25 info_ids = {clip_info_final{:,1}};
26 info_ids = strcell2matrix(info_ids);
27
28 % ---
29 % CAUTION: a offset because of table header is added
30 % ---
31 info_ids = info_ids(2:end);
32
33 % prepare file annots
34 file_ids = {annots_filenames{:,1}};
35 file_ids = strcell2matrix(file_ids);
36 file_ids = file_ids(2:end);
37
38 % intersect ids
39 [c, ia, ib] = intersect(file_ids, info_ids);
40
41 % and save into proper
42 clip_info_proper_names = clip_info_final(1,:);
43 clip_info_proper = clip_info_final(ib+1,:);
44
45 % clean proper for mysterious beginnings
46 for i = 1:size(clip_info_proper,1)
47 % leave out first row;
48 for j = 2:size(clip_info_proper,2)
49 clip_info_proper{i,j} = clip_info_proper{i,j}(2:end);
50 end
51 end
52
53 % ---
54 % % GENRE extraction
55 %
56 % now, we load the new file and search for the information on the
57 % actual excerpts we have
58 % ---
59 tmp = csv2cell('song_info.csv','fromfile');
60
61 %%
62 % these are for keeping book of missing items
63 not_found = [];
64 man_album_name = {};
65
66 rel_cols = [6,7];
67 % make header
68 clip_info_extra_names = {'clip_id',tmp{1,rel_cols}};
69 clip_info_extra = {};
70
71 for i = 1:size(clip_info_proper,1)
72 % ---
73 % search by url
74 % ---
75 % convert search string
76 s = char(clip_info_proper{i,9});
77 idx = strcellfind(tmp(:,9),s);
78
79 % we'll have to loosen the search
80 if idx < 1
81 warning(sprintf('! %s, album %s, artist %s!',clip_info_proper{i,1},...
82 clip_info_proper{i,5},clip_info_proper{i,4}));
83
84 % make note ...
85 not_found = cat(1,not_found,[str2num(clip_info_proper{i,1}), 0]);
86
87 not_found(end,2) = 1;
88 % ---
89 % ok, no problem, lets look for the album!
90 % ---
91 s = char(clip_info_proper{i,5});
92 idx = strcellfind(tmp(:,3),s);
93
94 if idx < 1
95
96 not_found(end,2) = 2;
97 % ---
98 % search for artist
99 % ---
100 s = char(clip_info_proper{i,4});
101 idx = strcellfind(tmp(:,1),s);
102 end
103
104 if idx < 1
105
106 not_found(end,2) = 3;
107 % ---
108 % this is the last try to get hold of such artists
109 % they may be noted as a trackname or description substring in a compilation
110 % ---
111 s = char(clip_info_proper{i,4});
112 idx = substrcellfind(tmp(:,2),s);
113 end
114
115 if idx < 1
116
117 warning(sprintf(' - %s, %s \n',clip_info_proper{i,1},clip_info_proper{i,4}));
118 newinfo = {''};
119
120 % reset suspected success
121 not_found(end,2) = 0;
122 else
123
124 warning(sprintf(' + associated album %s, artist %s \n',tmp{idx,3},tmp{idx,1}));
125
126 % get relevant data
127 newinfo = {tmp{idx,[3 1 12]}};
128
129 % ---
130 % save genre
131 % ---
132 clip_info_extra = cat(1,clip_info_extra,{clip_info_proper{i,1},tmp{idx,rel_cols}});
133 end
134
135 % report new location/info of album
136 s = char(clip_info_proper{i,5});
137 if isempty(man_album_name) || strcellfind(man_album_name(:,1),s) == -1 ;
138 man_album_name = cat(1, man_album_name, {clip_info_proper{i,5},newinfo{:}});
139 end
140
141 else
142 % ---
143 % save genre
144 % ---
145 clip_info_extra = cat(1,clip_info_extra,{clip_info_proper{i,1},tmp{idx,rel_cols}});
146 end
147 end
148
149 clear('newinfo','i','j','idx','s','ia','ib','rel_cols')
150
151
152
153
154