diff options
-rw-r--r-- | mert/extractor.cpp | 6 | ||||
-rwxr-xr-x | mert/mert.cpp | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/mert/extractor.cpp b/mert/extractor.cpp index 0d38c2e25..99567281a 100644 --- a/mert/extractor.cpp +++ b/mert/extractor.cpp @@ -9,6 +9,7 @@ #include <vector> #include <getopt.h> +#include <boost/scoped_ptr.hpp> #include "Data.h" #include "Scorer.h" @@ -185,7 +186,8 @@ int main(int argc, char** argv) TRACE_ERR("Scorer type: " << option.scorerType << endl); - Scorer* scorer = ScorerFactory::getScorer(option.scorerType, option.scorerConfig); + boost::scoped_ptr<Scorer> scorer( + ScorerFactory::getScorer(option.scorerType, option.scorerConfig)); scorer->setFactors(option.scorerFactors); @@ -218,8 +220,6 @@ int main(int argc, char** argv) data.save(option.featureDataFile, option.scoreDataFile, option.binmode); PrintUserTime("Stopping..."); - delete scorer; - return EXIT_SUCCESS; } catch (const exception& e) { cerr << "Exception: " << e.what() << endl; diff --git a/mert/mert.cpp b/mert/mert.cpp index 20940c4bf..694b48e8e 100755 --- a/mert/mert.cpp +++ b/mert/mert.cpp @@ -11,6 +11,7 @@ #include <ctime> #include <getopt.h> +#include <boost/scoped_ptr.hpp> #include "Data.h" #include "Point.h" @@ -333,17 +334,18 @@ int main(int argc, char **argv) } // it make sense to know what parameter set were used to generate the nbest - Scorer *TheScorer = ScorerFactory::getScorer(option.scorer_type, option.scorer_config); + boost::scoped_ptr<Scorer> scorer( + ScorerFactory::getScorer(option.scorer_type, option.scorer_config)); //load data - Data data(*TheScorer); + Data data(*scorer); for (size_t i = 0; i < ScoreDataFiles.size(); i++) { cerr<<"Loading Data from: "<< ScoreDataFiles.at(i) << " and " << FeatureDataFiles.at(i) << endl; data.load(FeatureDataFiles.at(i), ScoreDataFiles.at(i)); } - TheScorer->setScoreData(data.getScoreData().get()); + scorer->setScoreData(data.getScoreData().get()); //ADDED_BY_TS data.remove_duplicates(); @@ -506,7 +508,6 @@ int main(int argc, char **argv) } } - delete TheScorer; PrintUserTime("Stopping..."); return 0; |