clear all clc % newWordslist = textread('mycorpus.txt', '%s', 'delimiter', ','); load('ContTab.mat')%, contTab=newContTab; for k=1:length(newWordslist) newWordslist{k}=strrep(newWordslist{k},' "','');%remove speech marks and last space at the end newWordslist{k}=strrep(newWordslist{k},'" ','');%remove speech marks and first space at the start newWordslist{k}=strrep(newWordslist{k},'"','');%remove other speech marks newWordslist{k} = strtrim(newWordslist{k});%remove leading and trailing white space end synLogCounter=0; i=1; while i <= length(newWordslist) [~,syn]=dictionary(newWordslist{i}); if length(syn(:,1))==1 %only do synonym matching if there is only one row (onw word in newWordlist{i}) indSyn=[]; synLogCounter=synLogCounter+1; for j=1:length(syn) indSynNew=find(strcmp([newWordslist], syn{j})); indSyn=[indSyn; indSynNew]; end % synLog{synLogCounter}.WordUsed=newWordslist(indSyn(1)); %synLog so we know what words have been replaced in % synLog{synLogCounter}.Syns=newWordslist(indSyn(2:end)); % synLog.(newWordslist(indSyn(1)))=newWordslist(indSyn(2:end)); fldname=char(newWordslist(indSyn(1))); fldname=strrep(fldname,'.',''); %remove . from misc. synLog.(fldname)=newWordslist(indSyn(1:end)); contTab(:,indSyn(1))=sum(contTab(:,indSyn),2); %pool contTab(:,indSyn(2:end))=[]; % newWordslist(indSyn(2:end))=[]; %delete other words end i=i+1; end save('pooledAllContTab.mat', 'contTab','newWordslist','synLog');