
function model = do_work(filename, corpus, max_rows, only_read_files, stem_est_words, min_word_len, min_wordcount, use_separate_files, filename2, skip_rows) 


    if nargin<3 || isempty(max_rows)
        max_rows = -1;
    end
    
    if nargin<4 || isempty(only_read_files)
        only_read_files = 0;
    end
    
    if nargin<5 || isempty(stem_est_words)
        stem_est_words = 1;
    end
    
    if nargin<6 || isempty(min_word_len)
        min_word_len = 4;
    end
    
    if nargin<7 || isempty(min_wordcount)
        min_wordcount = 1;
    end
    
    if nargin<8 || isempty(use_separate_files)
        use_separate_files = 0;
    end
    
    if nargin<10 || isempty(skip_rows)
        skip_rows = 0;
    end
    
    
    % min_word_len = 3;
    
    


    if nargin<1 || isempty(filename)
        
        % if (1)
        if ~use_separate_files
            
            filename = 'x0000_et-en.par';
            % filename2 = '';
            % skip_rows = 0;
            % output_registered_est_words_file = 'est';
            
        else    % if ~use_separate_files
            
            filename = 'hansard.36.1.senate.debates.1997-09-22.001.e';
            
            % if nargin<9 || isempty(filename2)
            %    filename2 = 'hansard.36.1.senate.debates.1997-09-22.001.f';
            % end
            
            % skip_rows = 0; % 21;  % first lines repeat later and cause eigs to fail!
            % output_registered_est_words_file = [];
            
        end    % if ~use_separate_files
        
    else    % if nargin<1 || isempty(filename)
        
        % skip_rows = 0;
        % output_registered_est_words_file = 'est';
        
    end     % if nargin<1 || isempty(filename)
    
    
    if ~use_separate_files

        filename2 = '';

    else    % if ~use_separate_files

        if nargin<9 || isempty(filename2)
            filename2 = 'hansard.36.1.senate.debates.1997-09-22.001.f';
        end
        
    end     % if ~use_separate_files   
    
    
    if nargin<2 || isempty(corpus)
        corpus = readcorpus(filename, max_rows, filename2, skip_rows);
    end

    

    
        
    model = struct;
    model.corpus = corpus;
    model.min_wordcount = min_wordcount;
    model.min_word_len = min_word_len; % min_word_len;
    model.stem_est_words = stem_est_words;

    
    if model.stem_est_words

        output_registered_est_words_file = 'est';
        [model.hashmap_size_est, model.hashmap_est, model.lines_est1, model.word_to_stem_map] = registreerisonad(model, corpus.est, [], output_registered_est_words_file);

    else    % if model.stem_est_words

        [model.hashmap_size_est, model.hashmap_est, model.lines_est1] = registreerisonad(model, corpus.est);

    end    % if model.stem_est_words
    
    [model.hashmap_size_eng, model.hashmap_eng, model.lines_eng1] = registreerisonad(model, corpus.eng);

    
    
    if ~only_read_files
        
        model = lines_to_vectors(model);


        [solution, model.alfa, model.beta, model.f_est, model.f_eng] = build_problem(model);


        model.est_projections = build_projections(model, 'est');
        model.eng_projections = build_projections(model, 'eng');
    
    end     % if ~only_read_files
    

end
