// file: $isip/class/pr/RegressionDecisionTree/rdt_03.cc // version: $Id: rdt_03.cc 9459 2004-04-19 16:06:08Z gao $ // // isip include files // #include "RegressionDecisionTree.h" //------------------------------------------------------------------ // these methods have to be in the same file so they can use the same // static parser pointer //------------------------------------------------------------------ // declare a static sof parser pointer // static SofParser* parser_d = (SofParser*)NULL; // method: setParser // // arguments: // SofParser* parser: (input) sof file object // // return: a bool8 value indicating status // // this method sets the parser from the parent object to be used in // the next readData method. // bool8 RegressionDecisionTree::setParser(SofParser* parser_a) { // set the parser // parser_d = parser_a; // exit gracefully // return true; } // method: read // // arguments: // Sof& sof: (input) sof file object // int32 tag: (input) sof object instance tag // const String& name: (input) sof object instance name // // return: a bool8 value indicating status // // this method has the object read itself from an Sof file // bool8 RegressionDecisionTree::read(Sof& sof_a, int32 tag_a, const String& name_a) { // get the instance of the object from the Sof file // if (!sof_a.find(name_a, tag_a)) { return false; } // read the actual data from the sof file // return readData(sof_a); } // method: readData // // arguments: // Sof& sof: (input) sof file object // const String& pname: (input) parameter name // int32 size: (input) size of the object // bool8 param: (input) is the parameter specified? // bool8 nested: (input) is this nested? // // return: a bool8 value indicating status // // this method has the object read itself from an Sof file. it assumes // that the Sof file is already positioned correctly. // bool8 RegressionDecisionTree::readData(Sof& sof_a, const String& pname_a, int32 size_a, bool8 param_a, bool8 nested_a) { // declare local variables // bool8 status = true; // we need a parser // if (parser_d == (SofParser*)NULL) { parser_d = new SofParser; if (nested_a) { parser_d->setNest(); } // load the parse // if (!parser_d->load(sof_a, size_a)) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } // set the debug level of the parser // parser_d->setDebug(debug_level_d.getIndex()); // get the algorithm name // if (parser_d->isPresent(sof_a, PARAM_ALGORITHM)) { if (!ALGO_MAP.readElementData((int32&)algorithm_d, sof_a, PARAM_ALGORITHM, parser_d->getEntry(sof_a, PARAM_ALGORITHM))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { algorithm_d = DEF_ALGORITHM; } // get the implementation // if (parser_d->isPresent(sof_a, PARAM_IMPLEMENTATION)) { if (!IMPL_MAP.readElementData((int32&)implementation_d, sof_a, PARAM_IMPLEMENTATION, parser_d->getEntry(sof_a, PARAM_IMPLEMENTATION))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { implementation_d = DEF_IMPLEMENTATION; } // get the split threshold // if (parser_d->isPresent(sof_a, PARAM_SPEECH_FLAG)) { if (!speech_flag_d.readData(sof_a, PARAM_SPEECH_FLAG, parser_d->getEntry(sof_a, PARAM_SPEECH_FLAG))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { speech_flag_d = DEF_SPEECH_FLAG; } // get the number of terminals // if (parser_d->isPresent(sof_a, PARAM_NUM_TERMINALS)) { if (!num_terminals_d.readData(sof_a, PARAM_NUM_TERMINALS, parser_d->getEntry(sof_a, PARAM_NUM_TERMINALS))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { num_terminals_d = DEF_NUM_TERMINALS; } // get the perturb depth // if (parser_d->isPresent(sof_a, PARAM_PERTURB_DEPTH)) { if (!perturb_depth_d.readData(sof_a, PARAM_PERTURB_DEPTH, parser_d->getEntry(sof_a, PARAM_PERTURB_DEPTH))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { perturb_depth_d = DEF_PERTURB_DEPTH; } // get the occ threshold // if (parser_d->isPresent(sof_a, PARAM_OCC_THRESHOLD)) { if (!occ_threshold_d.readData(sof_a, PARAM_OCC_THRESHOLD, parser_d->getEntry(sof_a, PARAM_OCC_THRESHOLD))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { occ_threshold_d = DEF_OCC_THRESHOLD; } // get the components threshold // if (parser_d->isPresent(sof_a, PARAM_COMPONENTS_THRESHOLD)) { if (!components_threshold_d.readData(sof_a, PARAM_COMPONENTS_THRESHOLD, parser_d->getEntry(sof_a, PARAM_COMPONENTS_THRESHOLD))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { components_threshold_d = DEF_COMPONENTS_THRESHOLD; } // get the mixture offset // if (parser_d->isPresent(sof_a, PARAM_MIXTURE_OFFSET)) { if (!mixture_offset_d.readData(sof_a, PARAM_MIXTURE_OFFSET, parser_d->getEntry(sof_a, PARAM_MIXTURE_OFFSET))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } // get the map_stat_to_trans // if (parser_d->isPresent(sof_a, PARAM_MAP_STAT_TO_TRANS)) { if (!map_stat_to_trans_d.readData(sof_a, PARAM_MAP_STAT_TO_TRANS, parser_d->getEntry(sof_a, PARAM_MAP_STAT_TO_TRANS))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } // read the BiGraph // if (parser_d->isPresent(sof_a, PARAM_BDT)) { if (!BiGraph::readData(sof_a, PARAM_BDT)) { return Error::handle(name(), L"readData", Error::ARG, __FILE__, __LINE__); } } // get the debug level // if (parser_d->isPresent(sof_a, PARAM_DBGL)) { if (!debug_level_d.readData(sof_a, PARAM_DBGL, parser_d->getEntry(sof_a, PARAM_DBGL))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::IO, __FILE__, __LINE__, Error::WARNING); } } else { debug_level_d = Integral::DEF_DEBUG; } // check that all parameters are accounted for // if (!parser_d->checkParams(sof_a)) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::IO, __FILE__, __LINE__, Error::WARNING); } // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // exit gracefully // return status; }