Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FeatureData.h « mert - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dc54c11bed345a64aa7d1d509247ecaeff1fa06b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 *  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_;
	size_t number_of_feature;
	
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(unsigned 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 FeatureSize(){ return number_of_feature; }
	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);
};


#endif