function [words,counts]=parseDirectory(dname,dictionary) % [words,counts]=parseDirectory(dname,dictionary) % Parse all e-mail files in DNAME (those with extension .eml), and return % word counts for each (see parseEmail.m for details). % Uses DICTIONARY to select a subset of words (pass [] to include all % words that appear in a file). % Returns: % WORDS{I} is the cell array of words returned by parseEmail for I-th file; % COUNTS{I} is the counts vector for the I-th file. % remember were we are currd=pwd; cd(dname); % get the list of e-mail files flist=dir('*.eml'); % it's faster to pre-allocate memory words=cell(1,length(flist)); counts=cell(1,length(flist)); for i=1:length(flist) % parse i-th file [words{i},counts{i}]=parseEmail(flist(i).name,dictionary); fprintf('Parsed %s; %d words\n',flist(i).name,length(words{i})); end % restore working dir. cd(currd);