0001 function [dict, uniqModels]=dictRead(dictFile)
0002
0003
0004
0005
0006
0007 contents = textread(dictFile, '%s', 'delimiter', '\n', 'whitespace', '');
0008 n=length(contents);
0009 dict=struct('word', mat2cell(1:n, 1, ones(1,n)));
0010 for i=1:length(contents)
0011 if mod(i, 1000)==0
0012 fprintf('%d/%d\n', i, length(contents));
0013 end
0014 line=contents{i};
0015 if isempty(line)
0016 continue;
0017 end
0018 items=split(line, [9, 32]);
0019 if isempty(items{end})
0020 items(end)=[];
0021 end
0022 dict(i).word=items{1};
0023 for j=2:length(items)
0024 dict(i).model{j-1}=items{j};
0025 end
0026 end
0027
0028 if nargout>1
0029 uniqModels=unique([dict.model]);
0030 end