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

ScoreArray.h « mert - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1240a704aa34d075967c3dc678b9d00347f68e1b (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 *  ScoreArray.h
 *  met - Minimum Error Training
 *
 *  Created by Nicola Bertoldi on 13/05/08.
 *
 */

#ifndef SCORE_ARRAY_H
#define SCORE_ARRAY_H

using namespace std;

#include <vector>
#include <iostream>
#include <string>

#include "ScoreStats.h"

const char SCORES_TXT_BEGIN[] = "SCORES_TXT_BEGIN_0";
const char SCORES_TXT_END[] = "SCORES_TXT_END_0";
const char SCORES_BIN_BEGIN[] = "SCORES_BIN_BEGIN_0";
const char SCORES_BIN_END[] = "SCORES_BIN_END_0";

class ScoreArray
{
protected:
  scorearray_t array_;
  std::string score_type;
  size_t number_of_scores;

private:
  // idx to identify the utterance.
  // It can differ from the index inside the vector.
  std::string  idx;

public:
  ScoreArray();
  ~ScoreArray() {}

  inline void clear() {
    array_.clear();
  }

  inline std::string getIndex() const {
    return idx;
  }
  inline void setIndex(const std::string& value) {
    idx=value;
  }

//	inline ScoreStats get(size_t i){ return array_.at(i); }

  inline ScoreStats&  get(size_t i) {
    return array_.at(i);
  }
  inline const ScoreStats&  get(size_t i)const {
    return array_.at(i);
  }

  void add(const ScoreStats& e) {
    array_.push_back(e);
  }

  void merge(ScoreArray& e);

  inline std::string name() const {
    return score_type;
  }

  inline void name(std::string &sctype) {
    score_type = sctype;
  }

  inline size_t size() const {
    return array_.size();
  }
  inline size_t NumberOfScores() const {
    return number_of_scores;
  }
  inline void NumberOfScores(size_t v) {
    number_of_scores = v;
  }

  void savetxt(ofstream& outFile, const std::string& sctype);
  void savebin(ofstream& outFile, const std::string& sctype);
  void save(ofstream& outFile, const std::string& sctype, bool bin=false);
  void save(const std::string &file, const std::string& sctype, bool bin=false);
  inline void save(const std::string& sctype, bool bin=false) {
    save("/dev/stdout", sctype, bin);
  }

  void loadtxt(ifstream& inFile, size_t n);
  void loadbin(ifstream& inFile, size_t n);
  void load(ifstream& inFile);
  void load(const std::string &file);

  bool check_consistency() const;
};

#endif  // SCORE_ARRAY_H