function vec=word_vec(searchstring,words)
% vec=word_vec(searchstring,words)
% searchstring consists of several words separated by spaces
% words is a list of distinguished words
% vec is a vector of ones and zeros with a 1 in those
% positions corresponding to words that appear in searchstring

% M. M. Sussman
% $Id: word_vec.m,v 1.2 2011/03/30 20:49:41 mike Exp $

% make into incidence vector (column)
vec=zeros(length(words),1);
while ~isempty(searchstring)
  [v,searchstring]=strtok(searchstring);
  w=lower(v);
  if length(w)>0
    % get rid of trailing commas, etc.
    if ~isletter(w(end))
      w=w(1:end-1);
    end
    ind=strmatch(w,words,'exact');
    vec(ind)=1;
  end
end
  

