T2TTester.h 1.51 KB
Newer Older
xiaotong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/* NiuTrans.Tensor - an open-source tensor library
 * Copyright (C) 2019, Natural Language Processing Lab, Northestern University.
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Created by: XIAO Tong (xiaotong@mail.neu.edu.cn) 2019-03-27
 * A week with no trips :)
 */

#ifndef __T2TTESTER_H__
#define __T2TTESTER_H__

#include "T2TSearch.h"
xiaotong committed
27
#include "T2TBatchLoader.h"
xiaotong committed
28 29 30

namespace transformer
{
xiaotong committed
31 32 33 34 35

/* This class translates test sentences with a trained model. */
class T2TTester
{
public:
xiaotong committed
36 37 38 39 40 41 42 43 44 45 46 47 48
    /* vocabulary size of the source side */
    int vSize;

    /* vocabulary size of the target side */
    int vSizeTgt;
    
    /* for batching */
    T2TBatchLoader batchLoader;

    /* decoder for inference */
    T2TSearch seacher;

public:
xiaotong committed
49 50 51 52 53 54 55
    /* constructor */
    T2TTester();

    /* de-constructor */
    ~T2TTester();

    /* initialize the model */
xiaotong committed
56
    void Init(int argc, char ** argv);
xiaotong committed
57 58 59

    /* test the model */
    void Test(const char * fn, const char * ofn, T2TModel * model);
xiaotong committed
60 61
};

xiaotong committed
62 63 64
}

#endif