mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
use standard c++ getline instead of old Moses SAFE_GETLINE
This commit is contained in:
parent
d979b24314
commit
23ba0de224
@ -54,7 +54,11 @@ bool SentenceAlignment::processSourceSentence(const char * sourceString, int, bo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SentenceAlignment::create( char targetString[], char sourceString[], char alignmentString[], char weightString[], int sentenceID, bool boundaryRules)
|
||||
bool SentenceAlignment::create(const char targetString[],
|
||||
const char sourceString[],
|
||||
const char alignmentString[],
|
||||
const char weightString[],
|
||||
int sentenceID, bool boundaryRules)
|
||||
{
|
||||
using namespace std;
|
||||
this->sentenceID = sentenceID;
|
||||
|
@ -43,8 +43,11 @@ public:
|
||||
|
||||
virtual bool processSourceSentence(const char *, int, bool boundaryRules);
|
||||
|
||||
bool create(char targetString[], char sourceString[],
|
||||
char alignmentString[], char weightString[], int sentenceID, bool boundaryRules);
|
||||
bool create(const char targetString[],
|
||||
const char sourceString[],
|
||||
const char alignmentString[],
|
||||
const char weightString[],
|
||||
int sentenceID, bool boundaryRules);
|
||||
|
||||
void invertAlignment();
|
||||
|
||||
|
@ -32,10 +32,6 @@ using namespace MosesTraining;
|
||||
namespace MosesTraining
|
||||
{
|
||||
|
||||
|
||||
const long int LINE_MAX_LENGTH = 500000 ;
|
||||
|
||||
|
||||
// HPhraseVertex represents a point in the alignment matrix
|
||||
typedef pair <int, int> HPhraseVertex;
|
||||
|
||||
@ -277,20 +273,18 @@ int main(int argc, char* argv[])
|
||||
|
||||
int i = sentenceOffset;
|
||||
|
||||
while(true) {
|
||||
string englishString, foreignString, alignmentString, weightString;
|
||||
|
||||
while(getline(*eFileP, englishString)) {
|
||||
i++;
|
||||
if (i%10000 == 0) cerr << "." << flush;
|
||||
char englishString[LINE_MAX_LENGTH];
|
||||
char foreignString[LINE_MAX_LENGTH];
|
||||
char alignmentString[LINE_MAX_LENGTH];
|
||||
char weightString[LINE_MAX_LENGTH];
|
||||
SAFE_GETLINE((*eFileP), englishString, LINE_MAX_LENGTH, '\n', __FILE__);
|
||||
if (eFileP->eof()) break;
|
||||
SAFE_GETLINE((*fFileP), foreignString, LINE_MAX_LENGTH, '\n', __FILE__);
|
||||
SAFE_GETLINE((*aFileP), alignmentString, LINE_MAX_LENGTH, '\n', __FILE__);
|
||||
|
||||
getline(*fFileP, foreignString);
|
||||
getline(*aFileP, alignmentString);
|
||||
if (iwFileP) {
|
||||
SAFE_GETLINE((*iwFileP), weightString, LINE_MAX_LENGTH, '\n', __FILE__);
|
||||
getline(*iwFileP, weightString);
|
||||
}
|
||||
|
||||
SentenceAlignment sentence;
|
||||
// cout << "read in: " << englishString << " & " << foreignString << " & " << alignmentString << endl;
|
||||
//az: output src, tgt, and alingment line
|
||||
@ -300,7 +294,11 @@ int main(int argc, char* argv[])
|
||||
cout << "LOG: ALT: " << alignmentString << endl;
|
||||
cout << "LOG: PHRASES_BEGIN:" << endl;
|
||||
}
|
||||
if (sentence.create( englishString, foreignString, alignmentString, weightString, i, false)) {
|
||||
if (sentence.create( englishString.c_str(),
|
||||
foreignString.c_str(),
|
||||
alignmentString.c_str(),
|
||||
weightString.c_str(),
|
||||
i, false)) {
|
||||
if (options.placeholders.size()) {
|
||||
sentence.invertAlignment();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user