annotate make_list_files.m @ 2:def2b3fa1450 tip master

corrected README
author Gerard Roma <gerard.roma@upf.edu>
date Mon, 04 Nov 2013 10:46:05 +0000
parents 96b1b8697b60
children
rev   line source
gerard@1 1 % Copyright 2013 MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
gerard@1 2 %
gerard@1 3 % Written by Gerard Roma <gerard.roma@upf.edu>
gerard@1 4 %
gerard@1 5 % This program is free software: you can redistribute it and/or modify
gerard@1 6 % it under the terms of the GNU Affero General Public License as published by
gerard@1 7 % the Free Software Foundation, either version 3 of the License, or
gerard@1 8 % (at your option) any later version.
gerard@1 9 %
gerard@1 10 % This program is distributed in the hope that it will be useful,
gerard@1 11 % but WITHOUT ANY WARRANTY; without even the implied warranty of
gerard@1 12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
gerard@1 13 % GNU Affero General Public License for more details.
gerard@1 14 %
gerard@1 15 % You should have received a copy of the GNU Affero General Public License
gerard@1 16 % along with this program. If not, see <http://www.gnu.org/licenses/>.
gerard@1 17
gerard@1 18 function make_list_files
gerard@1 19 NUM_FOLDS = 5;
gerard@1 20 classes = {'bus' 'busystreet' 'office' 'openairmarket' 'park' 'quietstreet' 'restaurant' 'supermarket' 'tube' 'tubestation'};
gerard@1 21 [names,labels] = get_filenames('path_to_files');
gerard@1 22 cp = cvpartition(labels,'k',NUM_FOLDS);
gerard@1 23 for i = 1:NUM_FOLDS
gerard@1 24 tr_fnames = names(cp.training(i));
gerard@1 25 tr_classes = labels(cp.training(i));
gerard@1 26 te_fnames = names(cp.test(i));
gerard@1 27 te_classes = labels(cp.test(i));
gerard@1 28 train_filename = strcat('fold',num2str(i),'_train.txt');
gerard@1 29 train_fid = fopen(train_filename,'w+');
gerard@1 30 for j = 1:length(tr_fnames)
gerard@1 31 fprintf(train_fid,'%s\t',char(tr_fnames(j)));
gerard@1 32 fprintf(train_fid,'%s\n',char(classes(tr_classes(j))));
gerard@1 33 end
gerard@1 34 fclose(train_fid);
gerard@1 35
gerard@1 36 test_filename = strcat('fold',num2str(i),'_test.txt');
gerard@1 37 test_fid = fopen(test_filename,'w+');
gerard@1 38 gt_filename = strcat('fold',num2str(i),'_gt.txt');
gerard@1 39 gt_fid = fopen(gt_filename,'w+');
gerard@1 40 for j = 1:length(te_fnames)
gerard@1 41 fprintf(test_fid,'%s\n',[char(te_fnames(j))]);
gerard@1 42 fprintf(gt_fid,'%s\t',[char(te_fnames(j))]);
gerard@1 43 fprintf(gt_fid,'%s\n',[char(classes(te_classes(j)))]);
gerard@1 44 end
gerard@1 45 fclose(gt_fid);
gerard@1 46 fclose(test_fid);
gerard@1 47
gerard@1 48 end