mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1657 1f5c12ca-751b-0410-a591-d2e778427230
66 lines
1.3 KiB
C++
66 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:
|
|
char databuf_[BUFSIZ];
|
|
size_t bufLen_;
|
|
|
|
public:
|
|
FeatureData();
|
|
|
|
~FeatureData(){};
|
|
|
|
inline void clear() { array_.clear(); }
|
|
|
|
inline FeatureArray& get(int i){ return array_.at(i); }
|
|
inline const FeatureArray& get(int i)const{ return array_.at(i); }
|
|
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(); }
|
|
|
|
inline size_t memsize(){ return bufLen_; }
|
|
|
|
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
|