mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Remove buffers from feature git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1761 1f5c12ca-751b-0410-a591-d2e778427230
75 lines
1.3 KiB
C++
75 lines
1.3 KiB
C++
/*
|
|
* FeatureData.h
|
|
* met - Minimum Error Training
|
|
*
|
|
* Created by Nicola Bertoldi on 13/05/08.
|
|
*
|
|
*/
|
|
|
|
#ifndef FEATURE_DATA_H
|
|
#define FEATURE_DATA_H
|
|
|
|
using namespace std;
|
|
|
|
#include <limits>
|
|
#include <vector>
|
|
#include <iostream>
|
|
|
|
#include "Util.h"
|
|
#include "FeatureArray.h"
|
|
|
|
class FeatureData
|
|
{
|
|
protected:
|
|
vector<FeatureArray> array_;
|
|
vector<int> idxmap_;
|
|
|
|
private:
|
|
|
|
public:
|
|
FeatureData();
|
|
|
|
~FeatureData(){};
|
|
|
|
inline void clear() { array_.clear(); }
|
|
|
|
inline FeatureArray& get(int i){
|
|
#ifdef DEBUG
|
|
return array_.at(i);
|
|
#else
|
|
return array_[i];
|
|
#endif
|
|
}
|
|
inline const FeatureArray& get(int i)const{
|
|
#ifdef DEBUG
|
|
return array_.at(i);
|
|
#else
|
|
return array_[i];
|
|
#endif
|
|
}
|
|
inline bool exists(int i){ return (i<array_.size())?true:false; }
|
|
|
|
inline void setIndex(){ };
|
|
|
|
inline FeatureStats& get(int i, int j){ return array_.at(i).get(j); }
|
|
inline const FeatureStats& get(int i, int j)const{ return array_.at(i).get(j); }
|
|
|
|
void add(FeatureArray& e);
|
|
void add(FeatureStats e, int sent_idx);
|
|
|
|
inline size_t size(){ return array_.size(); }
|
|
|
|
void save(const std::string &file, bool bin=false);
|
|
void save(ofstream& outFile, bool bin=false);
|
|
inline void save(bool bin=false){ save("/dev/stdout", bin); }
|
|
|
|
void load(ifstream& inFile);
|
|
void load(const std::string &file);
|
|
|
|
void loadnbest(const std::string &file);
|
|
};
|
|
|
|
|
|
#endif
|
|
|