function F = mkfactor(U,X)
% MKFACTOR Generate a wordfactor from the discriminant and a feature
%
% F = MKFACTOR(U,X) where U is the discriminant and X is an
% appropriate feature
  
% WORDFACTORDISCR.MKFACTOR
    
    
% Jerod Weinman
% jerod@acm.org
    
% $Id: mkfactor.m 1 2009-06-17 20:04:43Z weinman $
 
% Jerod Weinman
% jerod@acm.org
% Copyright 2006, 2008, 2009, 2011
 
%    This file is part of VIDI.
%
%    VIDI is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    VIDI is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with VIDI.  If not, see <http://www.gnu.org/licenses/>.
    
    
  if get(U.factordiscr,'template')  ~= get(X,'template')
	error('Factor template mismatch');
  end;
  
  
  N = get(X,'variables');
  
  % NOTE: Assumes that the word variable is last in the
  % list. Expects the feature to be the word list matrix.
  % Probably should sub-class X to wordfactorfeature 
  
  M = N(end);
  N = N(1:end-1);

  F = wordfactor(N, U.numLabels, M, get(X,'feature'));
