Clean up including headers; delete using namespace std in headers.

This commit is contained in:
Tetsuo Kiso 2012-05-07 23:41:18 +09:00
parent 1c8e2a2eb7
commit 42e07d23a8
9 changed files with 50 additions and 42 deletions

View File

@ -1,4 +1,6 @@
#include "Alignment.h"
#include <fstream>
#include <string>
#include <stdlib.h>
#include <cstring>

View File

@ -1,5 +1,10 @@
#include "PhrasePair.h"
#include <iostream>
#include "TargetCorpus.h"
#include "Alignment.h"
#include "Vocabulary.h"
#include "SuffixArray.h"
using namespace std;

View File

@ -1,16 +1,10 @@
#pragma once
#include <string>
#include <stdlib.h>
#include <cstring>
#include <fstream>
#include <sstream>
#include <iostream>
#include "SuffixArray.h"
#include "TargetCorpus.h"
#include "Alignment.h"
#include <iosfwd>
using namespace std;
class Alignment;
class SuffixArray;
class TargetCorpus;
class PhrasePair
{
@ -23,7 +17,7 @@ private:
Alignment *m_alignment;
INDEX m_sentence_id;
char m_target_length;
SuffixArray::INDEX m_source_position;
INDEX m_source_position;
char m_source_start, m_source_end;
char m_target_start, m_target_end;
char m_start_null, m_end_null;
@ -48,8 +42,8 @@ public:
{}
~PhrasePair () {}
void PrintTarget( ostream* out );
void Print( ostream* out, int width );
void PrintHTML( ostream* out );
void PrintClippedHTML( ostream* out, int width );
void PrintTarget( std::ostream* out );
void Print( std::ostream* out, int width );
void PrintHTML( std::ostream* out );
void PrintClippedHTML( std::ostream* out, int width );
};

View File

@ -1,9 +1,16 @@
#include "PhrasePairCollection.h"
#include <string>
#include <stdlib.h>
#include <cstring>
#include <algorithm>
#include "Vocabulary.h"
#include "SuffixArray.h"
#include "TargetCorpus.h"
#include "Alignment.h"
#include "PhrasePair.h"
#include "Mismatch.h"
using namespace std;
PhrasePairCollection::PhrasePairCollection( SuffixArray *sa, TargetCorpus *tc, Alignment *a )

View File

@ -1,11 +1,13 @@
#pragma once
#include "Vocabulary.h"
#include "SuffixArray.h"
#include "TargetCorpus.h"
#include "Alignment.h"
#include "PhrasePair.h"
#include "Mismatch.h"
#include <vector>
#include <string>
class Alignment;
class PhrasePair;
class SuffixArray;
class TargetCorpus;
class Mismatch;
class PhrasePairCollection
{
@ -16,8 +18,8 @@ private:
SuffixArray *m_suffixArray;
TargetCorpus *m_targetCorpus;
Alignment *m_alignment;
vector< vector<PhrasePair*> > m_collection;
vector< Mismatch* > m_mismatch, m_unaligned;
std::vector<std::vector<PhrasePair*> > m_collection;
std::vector< Mismatch* > m_mismatch, m_unaligned;
int m_size;
int m_max_lookup;
int m_max_pp_target;
@ -27,14 +29,14 @@ public:
PhrasePairCollection ( SuffixArray *, TargetCorpus *, Alignment * );
~PhrasePairCollection ();
bool GetCollection( const vector< string > sourceString );
bool GetCollection( const std::vector<std::string > sourceString );
void Print();
void PrintHTML();
};
// sorting helper
struct CompareBySize {
bool operator()(const vector<PhrasePair*> a, const vector<PhrasePair*> b ) const {
bool operator()(const std::vector<PhrasePair*> a, const std::vector<PhrasePair*> b ) const {
return a.size() > b.size();
}
};

View File

@ -1,4 +1,6 @@
#include "SuffixArray.h"
#include <fstream>
#include <string>
#include <stdlib.h>
#include <cstring>

View File

@ -1,5 +1,6 @@
#include "TargetCorpus.h"
#include <fstream>
#include <string>
#include <stdlib.h>
#include <cstring>

View File

@ -1,5 +1,6 @@
// $Id: Vocabulary.cpp 1565 2008-02-22 14:42:01Z bojar $
#include "Vocabulary.h"
#include <fstream>
namespace {

View File

@ -3,43 +3,37 @@
#pragma once
#include <iostream>
#include <fstream>
#include <assert.h>
#include <stdlib.h>
#include <cstdlib>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <vector>
using namespace std;
#define SAFE_GETLINE(_IS, _LINE, _SIZE, _DELIM) { \
_IS.getline(_LINE, _SIZE, _DELIM); \
if(_IS.fail() && !_IS.bad() && !_IS.eof()) _IS.clear(); \
if (_IS.gcount() == _SIZE-1) { \
cerr << "Line too long! Buffer overflow. Delete lines >=" \
std::cerr << "Line too long! Buffer overflow. Delete lines >=" \
<< _SIZE << " chars or raise MAX_LENGTH in phrase-extract/tables-core.cpp" \
<< endl; \
exit(1); \
<< std::endl; \
std::exit(1); \
} \
}
typedef string WORD;
typedef std::string WORD;
typedef unsigned int WORD_ID;
class Vocabulary
{
public:
map<WORD, WORD_ID> lookup;
vector< WORD > vocab;
std::map<WORD, WORD_ID> lookup;
std::vector< WORD > vocab;
WORD_ID StoreIfNew( const WORD& );
WORD_ID GetWordID( const WORD& );
vector<WORD_ID> Tokenize( const char[] );
std::vector<WORD_ID> Tokenize( const char[] );
inline WORD &GetWord( WORD_ID id ) const {
WORD &i = (WORD&) vocab[ id ];
return i;
}
void Save(const string& fileName );
void Load(const string& fileName );
void Save(const std::string& fileName );
void Load(const std::string& fileName );
};