2008-05-15 12:35:56 +04:00
|
|
|
/*
|
|
|
|
* Data.h
|
|
|
|
* met - Minimum Error Training
|
|
|
|
*
|
|
|
|
* Created by Nicola Bertoldi on 13/05/08.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DATA_H
|
|
|
|
#define DATA_H
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "Util.h"
|
|
|
|
#include "FeatureData.h"
|
|
|
|
#include "ScoreData.h"
|
|
|
|
|
|
|
|
class Scorer;
|
|
|
|
|
|
|
|
class Data
|
|
|
|
{
|
|
|
|
protected:
|
2011-02-24 15:42:19 +03:00
|
|
|
ScoreData* scoredata;
|
|
|
|
FeatureData* featdata;
|
|
|
|
|
2008-05-15 12:35:56 +04:00
|
|
|
private:
|
2011-02-24 15:42:19 +03:00
|
|
|
Scorer* theScorer;
|
2008-05-27 20:50:52 +04:00
|
|
|
std::string score_type;
|
2011-02-24 15:42:19 +03:00
|
|
|
size_t number_of_scores; //number of scores
|
|
|
|
|
2008-05-15 12:35:56 +04:00
|
|
|
public:
|
2011-02-24 15:42:19 +03:00
|
|
|
Data(Scorer& sc);
|
|
|
|
|
|
|
|
~Data() {};
|
|
|
|
|
|
|
|
inline void clear() {
|
|
|
|
scoredata->clear();
|
|
|
|
featdata->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScoreData* getScoreData() {
|
|
|
|
return scoredata;
|
|
|
|
};
|
|
|
|
FeatureData* getFeatureData() {
|
|
|
|
return featdata;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline size_t NumberOfFeatures() const {
|
|
|
|
return featdata->NumberOfFeatures();
|
|
|
|
}
|
|
|
|
inline void NumberOfFeatures(size_t v) {
|
|
|
|
featdata->NumberOfFeatures(v);
|
|
|
|
}
|
|
|
|
inline std::string Features() const {
|
|
|
|
return featdata->Features();
|
|
|
|
}
|
|
|
|
inline void Features(const std::string f) {
|
|
|
|
featdata->Features(f);
|
2008-05-27 20:50:52 +04:00
|
|
|
}
|
2011-02-24 15:42:19 +03:00
|
|
|
|
|
|
|
void loadnbest(const std::string &file);
|
|
|
|
|
|
|
|
void load(const std::string &featfile,const std::string &scorefile) {
|
|
|
|
featdata->load(featfile);
|
|
|
|
scoredata->load(scorefile);
|
|
|
|
}
|
|
|
|
|
|
|
|
void save(const std::string &featfile,const std::string &scorefile, bool bin=false) {
|
|
|
|
|
|
|
|
if (bin) cerr << "Binary write mode is selected" << endl;
|
|
|
|
else cerr << "Binary write mode is NOT selected" << endl;
|
|
|
|
|
|
|
|
featdata->save(featfile, bin);
|
|
|
|
scoredata->save(scorefile, bin);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool existsFeatureNames() {
|
|
|
|
return featdata->existsFeatureNames();
|
|
|
|
};
|
|
|
|
|
|
|
|
inline std::string getFeatureName(size_t idx) {
|
|
|
|
return featdata->getFeatureName(idx);
|
|
|
|
};
|
|
|
|
inline size_t getFeatureIndex(const std::string& name) {
|
|
|
|
return featdata->getFeatureIndex(name);
|
|
|
|
};
|
2008-05-15 12:35:56 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|