
function words_out = words_to_stems(words, word_to_stem_map)

    
    len = length(words);
    
    
    words_out = {};
    
    for i = 1:len

        word = char(words(i));
        
        if word_to_stem_map.containsKey(word)
            
            word_out = word_to_stem_map.get(word);
            
        else    % if word_to_stem_map.containsKey(word)
            
            word_out = word;
            
        end    % if word_to_stem_map.containsKey(word)
        
        words_out(i) = {['_' word_out]};    % '_' guarantees that stems and words will not overlap
        
    end     % for i = 1:len
    


end
