source/sample/transformer/train/TrainDataSet.cpp
Sample* TrainDataSet::LoadSample()
{
    int srcLen;
    int tgtLen;

    fread(&srcLen, sizeof(srcLen), 1, fp);
    fread(&tgtLen, sizeof(tgtLen), 1, fp);

    CheckNTErrors(srcLen > 0, "Invalid source sentence length");
    CheckNTErrors(tgtLen > 0, "Invalid target sentence length");

    IntList* srcSent = new IntList(srcLen);
    IntList* tgtSent = new IntList(tgtLen);
    srcSent->ReadFromFile(fp, srcLen);
    tgtSent->ReadFromFile(fp, tgtLen);

    Sample* sample = new Sample(srcSent, tgtSent, 0);
    
    return sample;
}
/* load a sample from the training file */
load a sample from the training file
load a sample from the training file
Sample* TrainDataSet::LoadSample()
{
    int srcLen;
    int tgtLen;
    fread(&srcLen, sizeof(srcLen), 1, fp);
    fread(&tgtLen, sizeof(tgtLen), 1, fp);
    CheckNTErrors(srcLen > 0, "Invalid source sentence length");
    CheckNTErrors(tgtLen > 0, "Invalid target sentence length");
    IntList* srcSent = new IntList(srcLen);
    IntList* tgtSent = new IntList(tgtLen);
    srcSent->ReadFromFile(fp, srcLen);
    tgtSent->ReadFromFile(fp, tgtLen);
    Sample* sample = new Sample(srcSent, tgtSent, 0);
    return sample;
}
Sample * TrainDataSet :: LoadSample ( ) { int srcLen ; int tgtLen ; fread ( & srcLen , sizeof ( srcLen ) , 1 , fp ) ; fread ( & tgtLen , sizeof ( tgtLen ) , 1 , fp ) ; CheckNTErrors ( srcLen > 0 , " " ) ; CheckNTErrors ( tgtLen > 0 , " " ) ; IntList * srcSent = new IntList ( srcLen ) ; IntList * tgtSent = new IntList ( tgtLen ) ; srcSent -> ReadFromFile ( fp , srcLen ) ; tgtSent -> ReadFromFile ( fp , tgtLen ) ; Sample * sample = new Sample ( srcSent , tgtSent , 0 ) ; return sample ; }
load a sample from the training file
load a sample from the training file