comparison core/magnatagatune/LFMTagsDB.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 % ---
2 % This is the wrapper and loader class for Last.Fm db
3 % and related data
4 % ---
5
6 classdef LFMTagsDB < handle
7
8 properties
9
10 % connects the last.fm artists to MTTartist ids
11 matching_artists;
12
13 % saves the last fm tags for last.fm artist ids
14 tagdb;
15 end
16
17 properties(Dependent)
18
19 lexicon;
20 end
21
22
23 methods
24 function db = LFMTagsDB(artistdb)
25
26 % load data
27 load last.fm.mat;
28
29 % ---
30 % NOTE: here, we save the corresponding magnatagatune
31 % artists. There make sure that the last.fm artists
32 % are properly associated!
33 %
34 % finally, the central last.fm artist index will refer
35 % to both the MTT artist database and the tags
36 % ----
37
38 % get all the clips artists
39 artists = artistdb.lexicon;
40
41 % assign artists to Last.Fm artists
42 lexicon = [];
43 annots = [];
44
45 justfmartists = fmartists(:,2);
46 for i = 1:numel(justfmartists)
47
48 %get matching MTT for each Last.fm artist
49 pos = strcellfind(artists, justfmartists{i});
50
51 % save its id
52 if ~isempty(pos)
53 associds(i) = artistdb.get_annot_id(artists{pos});
54 end
55 end
56
57 % ---
58 % TODO: assert wheather if the fmartist id actually coincide
59 % justfmartists_ids = matching_artists.get_annotid(justfmartists);
60 % ---
61
62 % call superclass constructor
63 db.tagdb = AnnotDB(fmartist_annots_names, ...
64 fmartist_annots, associds);
65
66 % save the mathing artists
67 db.matching_artists = AnnotDB('clips_by_annot', ...
68 justfmartists, associds);
69
70 end
71 end
72
73
74 methods
75
76 % retrieve annot by clip
77 function [out, score, aid] = annots(db, clip)
78
79 % ---
80 % NOTE: we retrieve the tags for the artist matching the clips
81 % one
82 % ---
83
84 fma_id = db.matching_artists.annotids_for_owner(clip.artist_id());
85
86 artist = clip.artist();
87
88 if ~isempty(fma_id)
89
90 [out, score, aid] = db.tagdb.annots(fma_id);
91 else
92 warning('Artist %s not found in Last.fm tags DB', artist);
93 end
94 end
95
96 function out = annotids_for_owner(db, clip)
97
98 % ---
99 % NOTE: we retrieve the tags for the artist matching the clips
100 % one
101 % ---
102
103 fma_id = db.matching_artists.annotids_for_owner(clip.artist_id());
104
105 artist = clip.artist();
106
107 if ~isempty(fma_id)
108
109 out = db.tagdb.annotids_for_owner( fma_id );
110 else
111 warning('Artist %s not found in Last.fm tags DB', artist);
112 end
113 end
114
115 function out = get.lexicon(db)
116 % gives back all the tags
117
118 out = db.tagdb.lexicon;
119 end
120 end
121
122 methods(Static)
123
124
125 end
126 end
127
128
129