Skip to content

Commit faab4b2

Browse files
author
Tetsuo Kiso
committed
Put global variables in mert/util.cpp in anonymous space.
We do not allow clients to access the following variables. Instead, use the APIs which we provide for that. Also, remove the unused function, and fix smoke tests.
1 parent 8c7dfe0 commit faab4b2

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

mert/Util.cpp

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,28 @@
1111

1212
using namespace std;
1313

14-
// global variables
15-
Timer g_timer;
16-
17-
int verbose = 0;
18-
1914
namespace {
2015

16+
Timer g_timer;
17+
int g_verbose = 0;
18+
2119
bool FindDelimiter(const std::string &str, const std::string &delim, size_t *pos)
2220
{
2321
*pos = str.find(delim);
2422
return *pos != std::string::npos ? true : false;
2523
}
24+
2625
} // namespace
2726

2827
int verboselevel()
2928
{
30-
return verbose;
29+
return g_verbose;
3130
}
3231

3332
int setverboselevel(int v)
3433
{
35-
verbose = v;
36-
return verbose;
34+
g_verbose = v;
35+
return g_verbose;
3736
}
3837

3938
size_t getNextPound(std::string &str, std::string &substr,
@@ -73,22 +72,6 @@ void Tokenize(const char *str, const char delim,
7372
}
7473
}
7574

76-
int swapbytes(char *p, int sz, int n)
77-
{
78-
char c, *l, *h;
79-
80-
if((n < 1) || (sz < 2)) return 0;
81-
for (; n--; p += sz) {
82-
for (h = (l = p) + sz; --h > l; l++) {
83-
c = *h;
84-
*h = *l;
85-
*l = c;
86-
}
87-
}
88-
return 0;
89-
90-
}
91-
9275
void ResetUserTime()
9376
{
9477
g_timer.start();

mert/example/gzipped_test.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ $extractor --nbest NBEST.gz --reference REF.0,REF.1,REF.2 \
1616
--ffile FEATSTAT_gz --scfile SCORESTAT_gz \
1717
--sctype BLEU 2> extractor_gz1.log
1818

19+
gzip -d NBEST.gz
20+
1921
$extractor --nbest NBEST --reference REF.0,REF.1,REF.2 \
2022
--prev-ffile FEATSTAT --prev-scfile SCORESTAT \
2123
--ffile FEATSTAT2 --scfile SCORESTAT2 \
@@ -30,10 +32,10 @@ for f in FEATSTAT_gz SCORESTAT_gz; do
3032
echo "done."
3133
done
3234

33-
$extractor --nbest NBEST.gz --reference REF.0,REF.1,REF.2 \
35+
$extractor --nbest NBEST --reference REF.0,REF.1,REF.2 \
3436
--prev-ffile FEATSTAT_gz.gz --prev-scfile SCORESTAT_gz.gz \
3537
--ffile FEATSTAT2_gz --scfile SCORESTAT2_gz \
3638
--sctype BLEU 2> extractor_gz3.log
3739

38-
gzip -d NBEST.gz FEATSTAT_gz.gz SCORESTAT_gz.gz
40+
gzip -d FEATSTAT_gz.gz SCORESTAT_gz.gz
3941
echo "Done."

0 commit comments

Comments
 (0)