-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNBestList.h
73 lines (52 loc) · 1.42 KB
/
NBestList.h
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
/*
* NBestList.h
*
* Created on: Feb 3, 2017
* Author: louis
*/
#ifndef NBESTLIST_H_
#define NBESTLIST_H_
#include <string>
#include <vector>
namespace SLM {
class NBestItem {
public:
NBestItem(const std::string& aSentence, int cRank, double aScore, double lScore, double words);
void setRescore(double score);
void setRank(int rank);
std::string toString(bool fileFormat = false) const;
double getAmScore() const;
double getLmScore() const;
double getReScore() const;
bool operator < (const NBestItem& rhs) const
{
// return (amScore + lmScore + reScore < rhs.getAmScore() + rhs.getLmScore() + rhs.getReScore());
return (lmScore < rhs.getLmScore());
}
private:
std::string sentence;
double amScore;
double lmScore;
double nrWords;
int currentRank;
double reScore;
int newRank;
};
class FileRenamer {
public:
std::string rename(const std::string& original, const std::string& outputDir = "");
};
class NBestList {
public:
NBestList();
virtual ~NBestList();
void add(NBestItem* item);
void determineNewRanks();
void print(bool fileFormat = false);
void printToFile(const std::string& originalName, const std::string& outputDirectory);
private:
std::vector<NBestItem*> items;
FileRenamer fr;
};
} /* namespace SLM */
#endif /* NBESTLIST_H_ */