Minimize using #include headers in headers.

Should use it in .cpp files.
This commit is contained in:
Tetsuo Kiso 2011-11-14 15:15:30 +09:00
parent be1506e759
commit 29c16d252a
35 changed files with 93 additions and 146 deletions

View File

@ -1,4 +1,9 @@
#include "BleuScorer.h"
#include <cmath>
#include <fstream>
#include <iterator>
#include <stdexcept>
#include "Util.h"
BleuScorer::BleuScorer(const string& config)
: StatisticsBasedScorer("BLEU",config),

View File

@ -1,16 +1,10 @@
#ifndef __BLEUSCORER_H__
#define __BLEUSCORER_H__
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include <limits.h>
#include "Types.h"
#include "ScoreData.h"
#include "Scorer.h"

View File

@ -1,8 +1,6 @@
#include "CderScorer.h"
#include <fstream>
#include <stdexcept>
#include <iostream>
#include <algorithm>
CderScorer::CderScorer(const string& config)
: StatisticsBasedScorer("CDER",config) {}

View File

@ -3,10 +3,10 @@
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include "Types.h"
#include "ScoreData.h"
#include "Scorer.h"
using namespace std;

View File

@ -7,6 +7,7 @@
*/
#include <cassert>
#include <cmath>
#include <fstream>
#include "Data.h"

View File

@ -6,10 +6,9 @@
*
*/
#include <fstream>
#include "FeatureArray.h"
#include "Util.h"
#include "FileStream.h"
#include "Util.h"
namespace {
const char FEATURES_TXT_BEGIN[] = "FEATURES_TXT_BEGIN_0";

View File

@ -9,16 +9,13 @@
#ifndef FEATURE_ARRAY_H
#define FEATURE_ARRAY_H
using namespace std;
#include <limits>
#include <vector>
#include <iostream>
#include <fstream>
#include "Util.h"
#include "FeatureStats.h"
using namespace std;
class FeatureArray
{
private:

View File

@ -6,8 +6,9 @@
*
*/
#include <fstream>
#include "FeatureData.h"
#include <limits>
#include "FileStream.h"
#include "Util.h"

View File

@ -11,11 +11,9 @@
using namespace std;
#include <limits>
#include <vector>
#include <iostream>
#include "Util.h"
#include <stdexcept>
#include "FeatureArray.h"
class FeatureData

View File

@ -6,10 +6,11 @@
*
*/
#include <cmath>
#include <fstream>
#include "FeatureStats.h"
#include <cmath>
#include "Util.h"
namespace {
const int kAvailableSize = 8;
} // namespace

View File

@ -11,11 +11,12 @@
using namespace std;
#include <limits>
#include <vector>
#include <fstream>
#include <iostream>
#include "Util.h"
#include <map>
#include <string>
#include <vector>
#include "Types.h"
// Minimal sparse vector
class SparseVector {

View File

@ -13,6 +13,7 @@ BleuScorer.cpp \
Point.cpp \
PerScorer.cpp \
Scorer.cpp \
ScorerFactory.cpp \
Optimizer.cpp \
TERsrc/alignmentStruct.cpp \
TERsrc/hashMap.cpp \

View File

@ -1,9 +1,17 @@
#include "MergeScorer.h"
#include <cmath>
#include <stdexcept>
#include "ScoreStats.h"
#include "TerScorer.h"
#include "BleuScorer.h"
#include "PerScorer.h"
#include "CderScorer.h"
#include "TERsrc/tercalc.h"
#include "TERsrc/terAlignment.h"
using namespace TERCpp;
using namespace std;
MergeScorer::MergeScorer(const string& config)
: StatisticsBasedScorer("MERGE",config), kLENGTH(4) {}

View File

@ -1,31 +1,19 @@
#ifndef __MERGESCORER_H__
#define __MERGESCORER_H__
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include <limits.h>
#include "Types.h"
#include "ScoreData.h"
#include "Scorer.h"
#include "TerScorer.h"
#include "BleuScorer.h"
#include "PerScorer.h"
#include "CderScorer.h"
//#include "TERsrc/tercalc.h"
//#include "TERsrc/terAlignment.h"
using namespace std;
using namespace TERCpp;
// enum MergeReferenceLengthStrategy { MERGE_AVERAGE, MERGE_SHORTEST, MERGE_CLOSEST };
class PerScorer;
class ScoreStats;
/**
* Merge scoring.

View File

@ -1,11 +1,15 @@
#include "Optimizer.h"
#include <cmath>
#include <cassert>
#include <vector>
#include <limits>
#include <list>
#include <map>
#include <cfloat>
#include <iostream>
#include "Optimizer.h"
#include "Point.h"
#include "Util.h"
using namespace std;

View File

@ -2,16 +2,16 @@
#define OPTIMIZER_H
#include <vector>
#include "FeatureStats.h"
#include <string>
#include "FeatureData.h"
#include "FeatureArray.h"
#include "Scorer.h"
#include "Point.h"
#include "Types.h"
using namespace std;
typedef float featurescore;
using namespace std;
class Point;
/**
* Abstract optimizer class.

View File

@ -1,5 +1,13 @@
#include "PerScorer.h"
#include <fstream>
#include <stdexcept>
#include "ScoreStats.h"
#include "Util.h"
using namespace std;
PerScorer::PerScorer(const string& config)
: StatisticsBasedScorer("PER",config) {}

View File

@ -1,22 +1,18 @@
#ifndef __PERSCORER_H__
#define __PERSCORER_H__
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include "Types.h"
#include "ScoreData.h"
#include "Scorer.h"
using namespace std;
class ScoreStats;
/**
* An implementation of position-independent word error rate.
* This is defined as

View File

@ -1,7 +1,9 @@
#include "Point.h"
#include <cmath>
#include <cstdlib>
#include <cassert>
#include "FeatureStats.h"
using namespace std;

View File

@ -1,10 +1,12 @@
#ifndef POINT_H
#define POINT_H
#include <fstream>
#include <map>
#include <vector>
#include "Types.h"
#include "FeatureStats.h"
class FeatureStats;
class Optimizer;
/**

View File

@ -6,7 +6,6 @@
*
*/
#include <fstream>
#include "ScoreArray.h"
#include "Util.h"
#include "FileStream.h"

View File

@ -11,12 +11,10 @@
using namespace std;
#include <limits>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include "Util.h"
#include "ScoreStats.h"
class ScoreArray

View File

@ -6,7 +6,6 @@
*
*/
#include <fstream>
#include "ScoreData.h"
#include "Scorer.h"
#include "Util.h"

View File

@ -9,14 +9,15 @@
#ifndef SCORE_DATA_H
#define SCORE_DATA_H
using namespace std;
#include <limits>
#include <fstream>
#include <vector>
#include <iostream>
#include "Util.h"
#include <stdexcept>
#include <string>
#include "ScoreArray.h"
#include "ScoreStats.h"
using namespace std;
class Scorer;

View File

@ -6,7 +6,7 @@
*
*/
#include <fstream>
#include "Util.h"
#include "ScoreStats.h"
namespace {

View File

@ -9,14 +9,15 @@
#ifndef SCORE_STATS_H
#define SCORE_STATS_H
using namespace std;
#include <limits>
#include <vector>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include "Util.h"
#include "Types.h"
using namespace std;
class ScoreStats
{

View File

@ -1,12 +1,7 @@
#ifndef __SCORER_H__
#define __SCORER_H__
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <limits>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>

View File

@ -1,53 +1,17 @@
#ifndef __SCORER_FACTORY_H
#define __SCORER_FACTORY_H
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include "Types.h"
#include "Scorer.h"
#include "BleuScorer.h"
#include "PerScorer.h"
#include "TerScorer.h"
#include "CderScorer.h"
#include "MergeScorer.h"
#include <string>
using namespace std;
class Scorer;
class ScorerFactory
{
public:
static vector<string> getTypes() {
vector<string> types;
types.push_back(string("BLEU"));
types.push_back(string("PER"));
types.push_back(string("TER"));
types.push_back(string("CDER"));
types.push_back(string("MERGE"));
return types;
}
static std::vector<std::string> getTypes();
static Scorer* getScorer(const string& type, const string& config = "") {
if (type == "BLEU") {
return (BleuScorer*) new BleuScorer(config);
} else if (type == "PER") {
return (PerScorer*) new PerScorer(config);
} else if (type == "TER") {
return (TerScorer*) new TerScorer(config);
} else if (type == "CDER") {
return (CderScorer*) new CderScorer(config);
} else if (type == "MERGE") {
return (MergeScorer*) new MergeScorer(config);
} else {
throw runtime_error("Unknown scorer type: " + type);
}
}
static Scorer* getScorer(const std::string& type, const std::string& config = "");
private:
ScorerFactory() {}

View File

@ -1,9 +1,15 @@
#include "TerScorer.h"
#include <cmath>
#include <sstream>
#include <stdexcept>
#include "ScoreStats.h"
#include "TERsrc/tercalc.h"
#include "TERsrc/terAlignment.h"
#include "Util.h"
using namespace TERCpp;
using namespace std;
TerScorer::TerScorer(const string& config)
: StatisticsBasedScorer("TER",config), kLENGTH(2) {}

View File

@ -1,27 +1,19 @@
#ifndef __TERSCORER_H__
#define __TERSCORER_H__
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include <limits.h>
#include "Types.h"
#include "ScoreData.h"
#include "Scorer.h"
#include "TERsrc/tercalc.h"
#include "TERsrc/terAlignment.h"
using namespace std;
using namespace TERCpp;
// enum TerReferenceLengthStrategy { TER_AVERAGE, TER_SHORTEST, TER_CLOSEST };
class ScoreStats;
/**
* TER scoring

View File

@ -1,8 +1,5 @@
#include <ctime>
#include <iostream>
#include <iomanip>
#include "Util.h"
#include "Timer.h"
#include "Util.h"
double Timer::elapsed_time()
{

View File

@ -4,7 +4,6 @@
#include <ctime>
#include <iostream>
#include <iomanip>
#include "Util.h"
class Timer
{

View File

@ -6,9 +6,7 @@
*
*/
#include <stdexcept>
#include "Util.h"
#include "Timer.h"
using namespace std;

View File

@ -9,15 +9,8 @@
#ifndef UTIL_H
#define UTIL_H
using namespace std;
#include <stdexcept>
#include <limits>
#define US_NOSET (numeric_limits<unsigned short>::max())
#define MAX_LINE 1024
#include <vector>
#include <map>
#include <iostream>
@ -26,11 +19,11 @@ using namespace std;
#include <cstring>
#include "Types.h"
#include "ScoreStats.h"
#include "FeatureStats.h"
class ScoreStats;
class FeatureStats;
using namespace std;
#define US_NOSET (numeric_limits<unsigned short>::max())
#define MAX_LINE 1024
#ifdef TRACE_ENABLE
#define TRACE_ERR(str) { std::cerr << str; }

View File

@ -1,3 +1,4 @@
#include <fstream>
#include <iostream>
#include <string>
#include <vector>