
function word_to_stem_map = stemmer_output_to_stemlist(filename)


    % fid_in = fopen(filename, 'r');
    fid_out = fopen([filename '.stemlist'], 'w');
    
    
    in = textread(filename, '%s', 'delimiter', '\n');
    len = rows(in);
    
    
    word_to_stem_map = java.util.Properties;
    
    
    next_line_is_word = -1;
    
    for i = 1:len
        
        line = cell2mat(in(i, :));
        
    
        if strcmp(line, '$LA$')
            
            next_line_is_word = 3;   
            continue;
            
        end
        
        if strcmp(line, '$.') && (next_line_is_word == 1)   % $.
            
            laststem = steminfo_to_stem(laststem);
            
            word_to_stem_map.put(lastword, laststem);
            
            fprintf(fid_out, '%s\n', laststem);
            
            next_line_is_word = -1;   
            continue;
            
        end
        
        if next_line_is_word == 3   %     ####
            next_line_is_word = 2;
            continue;
        end
        
        if next_line_is_word == 2   %   word
            next_line_is_word = 1;
            
            lastword = line;
            
            continue;
        end
        
        if next_line_is_word == 1   % stems
            next_line_is_word = 1;
            
            laststem = line;   
            
        end
            
            
        
        
    end     % for i = 1:len
    
    
    
    % fclose(fid_in);
    fclose(fid_out);


end
