blob: eb71746b07fb3d906086ea0c743725a19df80e4a (
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
|
/*
* nbest: tool to process moses n-best lists
*
* File: Tools.cpp
* basic utility functions
*
* Created by Holger Schwenk, University of Le Mans, 05/16/2008
*
*/
#ifndef _TOOLS_H_
#define _TOOLS_H_
using namespace std;
#include <iostream>
#include <fstream>
#include <vector>
class Weights
{
vector<float> val;
public:
Weights() {};
~Weights() {};
int Read(const char *);
friend class Hypo;
};
//******************************************************
/*
template<typename T>
inline T Scan(const std::string &input)
{
std::stringstream stream(input);
T ret;
stream >> ret;
return ret;
}
*/
//******************************************************
inline void Error (char *msg)
{
cerr << "ERROR: " << msg << endl;
exit(1);
}
//******************************************************
// From Moses code:
/*
* Outputting debugging/verbose information to stderr.
* Use TRACE_ENABLE flag to redirect tracing output into oblivion
* so that you can output your own ad-hoc debugging info.
* However, if you use stderr diretly, please delete calls to it once
* you finished debugging so that it won't clutter up.
* Also use TRACE_ENABLE to turn off output of any debugging info
* when compiling for a gui front-end so that running gui won't generate
* output on command line
* */
#ifdef TRACE_ENABLE
#define TRACE_ERR(str) std::cerr << str
#else
#define TRACE_ERR(str) {}
#endif
#endif
|