function [names,scores,lengths] = load_tapes_1_sentence (fname) % [names,scores,lengths] = load_tapes_1_sentence (fname) % % can read tapes just from one sentence. Will stop at the first dot. % names - of keywrds % scores % lengths % hard hack: comm = ['!head -1 ' fname ' > /tmp/load_tapes_aux.txt']; eval(comm); % load keywords f = fopen('/tmp/load_tapes_aux.txt','r'); cnt = 1; while (1) s = fscanf(f,'%s',[1 1]); if isempty(s) break end names{cnt} = s; cnt = cnt +1; end fclose (f); NWORDS = size (names,2) %%%%%%%%%%% ok, now load the real data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f = fopen(fname,'r'); % skip the lines w/ names of keywrds and filename l = fgetl(f); l = fgetl(f); % now load the data till the dot - alloc a matrix of 10000 (100 sec) to % prevent realloc of mem all the time. aux = zeros(10000, 2 * NWORDS); cnt = 1; while (1) l = fgetl(f); if (strcmp(l,'.')) % break on dot break end likes_paths = sscanf(l,'%f',[1 inf]); aux (cnt,:) = likes_paths; cnt = cnt +1; end fclose(f); scores = aux(1:(cnt-1), 1:NWORDS); lengths = aux(1:(cnt-1), NWORDS+1:2*NWORDS);