PLearn 0.1
Public Member Functions | Static Protected Attributes | Private Types
PLearn::ConfigParsing Class Reference

The first sentence should be a BRIEF DESCRIPTION of what the class does. More...

#include <ConfigParsing.h>

Inheritance diagram for PLearn::ConfigParsing:
Inheritance graph
[legend]
Collaboration diagram for PLearn::ConfigParsing:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ConfigParsing ()
virtual void run (const std::vector< std::string > &args)
 The actual implementation of the 'ConfigParsing' command.

Static Protected Attributes

static PLearnCommandRegistry reg_
 This allows to register the 'ConfigParsing' command in the command registry.

Private Types

typedef PLearnCommand inherited

Detailed Description

The first sentence should be a BRIEF DESCRIPTION of what the class does.

Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html

Todo:
Write class to-do's here if there are any.
Deprecated:
Write deprecated stuff here if there is any. Indicate what else should be used instead.

Definition at line 58 of file ConfigParsing.h.


Member Typedef Documentation

Definition at line 60 of file ConfigParsing.h.


Constructor & Destructor Documentation

PLearn::ConfigParsing::ConfigParsing ( )

Definition at line 52 of file ConfigParsing.cc.

    : PLearnCommand(
        "ConfigParsing",
        ">>>> INSERT A SHORT ONE LINE DESCRIPTION HERE",
        ">>>> INSERT SYNTAX AND \n"
        "FULL DETAILED HELP HERE \n"
        )
{}

Member Function Documentation

void PLearn::ConfigParsing::run ( const std::vector< std::string > &  args) [virtual]

The actual implementation of the 'ConfigParsing' command.

Implements PLearn::PLearnCommand.

Definition at line 62 of file ConfigParsing.cc.

References c, PLearn::endl(), i, PLearn::lowerstring(), NORMAL_LOG, PLearn::openFile(), PLCHECK, PLERROR, and PLearn::PStream::raw_ascii.

{
/*    args0 = conf/conf.all.csv;
    args1 = conf/1convertCSV0709toPLearn.inc;
    args2 = conf/3b_remove_col.inc;
    args3 = conf/3fix_missing.inc;
    args4 = conf/9dichotomize.inc;
    args5 = conf/global_imputation_specifications.inc;
*/
    PLCHECK(args.size()==6);
    TextFilesVMatrix input = TextFilesVMatrix();
    input.auto_build_map = 0  ;
    input.default_spec="char";
    input.build_vmatrix_stringmap = 1  ;
    input.delimiter = ",;"  ;
    input.quote_delimiter = '"';
    input.skipheader.append(1);
    input.reorder_fieldspec_from_headers=1;
    input.txtfilenames.append(args[0]);
    input.partial_match=1;
    input.setMetaDataDir("output.prepro/"+args[0]+".metadatadir");
    input.build();
    bool all_uptodate = true;
    for(int i=1;i<=5;i++)
        if(!input.isUpToDate(args[i])){
            all_uptodate = false;
            break;
        }
    if(all_uptodate){
        NORMAL_LOG << "All config file are uptodate. We don't regenerate them."<<endl;
        return;
    }
    PStream f_csv = openFile(PPath(args[1]),PStream::raw_ascii,"w");
    PStream f_remove = openFile(args[2],PStream::raw_ascii,"w");
    PStream f_missing = openFile(args[3],PStream::raw_ascii,"w");
    PStream f_dichotomize = openFile(args[4],PStream::raw_ascii,"w");
    PStream f_imputation = openFile(args[5],PStream::raw_ascii,"w");

    for(int i=0;i<input.length();i++){
        TVec<string> r = input.getTextFields(i);
        char c = r[0][0];
        if(c=='#' || r[0].empty())//comment
            continue;
        if(!r[1].empty()){
            f_csv << (r[0]);
            f_csv << (" : ");
            f_csv << (r[1]) << endl;
        }
        string y = lowerstring(r[2]);//TODO check that this is an accepted command.
        bool remove=false;
        if(y=="y" ||y=="yes"){//comment
            f_remove << (r[0]) << endl;
            remove=true;
        }else if(y=="n" ||y=="no"||y==""){
        }else{
            PLERROR("Unknow value in column C:'%s'",r[2].c_str());
        }
        if(!r[3].empty() && !remove){
            f_missing << (r[0]);
            f_missing << (" : ");
            f_missing << (r[3]);//TODO check that this is an accepted command.
            f_missing << endl;
        }
        if(!r[4].empty() && !remove){
            f_imputation << (r[0]);
            f_imputation << (" : ");
            f_imputation << (r[4]);//TODO check that this is an accepted command.
            f_imputation << endl;
        }
        if(!r[5].empty() && !remove){
            string s = r[0];
            if(s[s.length()-1]=='*')
                s=s.substr(0,s.length()-1);
            f_dichotomize << s <<" : ["<< r[5] << " ]"<<endl;
        }
    }
}

Here is the call graph for this function:


Member Data Documentation

This allows to register the 'ConfigParsing' command in the command registry.

Definition at line 67 of file ConfigParsing.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines