⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 解码器是基于短语的统计机器翻译系统的核心模块
💻 CPP
字号:
/** main.cpp  -  Camel a phrase based smt decoder* * version 1.0* * Copyright (C) 2006 by Zhongjun He <zjhe@ict.ac.cn>                         Yajuan Lv <lvyajuan@ict.ac.cn>Multilingual Interaction Technology and Evaluation Laboratory, ICT, CAS* Begin       : 04/31/2006* Last Change : 04/31/2006** This program is free software; you can redistribute it and/or* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.** You should have received a copy of the GNU Lesser General Public* License along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*/
#include <iostream>
#include <vector>
#include "Decoder.h"
#include <math.h>
using namespace std;

void ParseArg(int argc, char *argv[], Decoder &d);
void Help();

int main(int argc, char *argv[])
{

	cout << "Camel v1.0, written by Zhongjun He and Yajuan Lv\n";
	cout << "a beam search decoder for phrase-based statistical machine translation models\n";
	cout << "(c) 2006 Institute of Computing Technology, Chinese Academy of Sciences\n";
	
	Decoder d;

	ParseArg(argc, argv,d);

//	d.ReadConfigure("searchconfigure.txt");
	d.Initialize();
//	string s = "中国 经济 发展 十分 迅速";
//	d.TranslateSent(s);

	d.TranslateFile();
}

/************************************************************************/
/* Parse Arguments                                                      */
/************************************************************************/
void ParseArg(int argc, char *argv[], Decoder &d)
{
	int stack = -1, distortion = -1, ttable_limit = -1, nbest_list = -1;
	int print_info = -1, print_nbest = -1;
	string test_file, result_file, nbest_file;

	if(argc == 1)
	{
		Help();
		exit(1);
	}

	for (int i=1; i<argc; i++)
	{
		string t(argv[i]);

		if (t == "-conf")
		{
			d.ReadConfigure(argv[++i]);
		}

		else if (t == "-stack")
			stack = atoi(argv[++i]);
		
		else if (t =="-distortion")
			distortion = atoi(argv[++i]);
		
		else if (t == "-ttable-limit")
			ttable_limit = atoi(argv[++i]);
		
		else if (t =="-nbest-list")
			nbest_list = atoi(argv[++i]);

		else if (t =="-print-info")
		    print_info = atoi(argv[++i]);

		else if (t == "-print-nbest")
			print_nbest = atoi(argv[++i]);

		else if (t == "-test-file")
			test_file = argv[++i];

		else if (t == "-result-file")
            result_file = argv[++i];

		else if (t == "-nbest-file")
			nbest_file = argv[++i];

		else
		{
			Help();
			exit(1);
		}
	}

	d.SetArg(ttable_limit, distortion, stack, nbest_list, print_nbest, print_info,
		     test_file, result_file, nbest_file);
}

/************************************************************************/
/* print help                                                           */
/************************************************************************/
void Help()
{
	cerr << "Camel v1.0 Command Line Help: \n\n";
	cerr << "-conf : specifies the configure file\n\n";
	cerr << "-stack: maximum size of the beam (default 100)\n\n";
	cerr << "-distortion: maximum distance between two foreign phrases (default 5, 0 for monotone search)\n\n";
	cerr << "-ttable-limit: number of phrase translations for each foreign phrase (default 10)\n\n";
	cerr << "-nbest-list: number of candidate translations for each input sentence (default 100)\n\n";
	cerr << "-print-info: print decoding information or not (default 0)\n\n";
	cerr << "-print-nbest: print nbest-list or not (default 0)\n\n";
	cerr << "-test-file: specifies test file\n\n";
	cerr << "-result-file: specifies result file\n\n";
	cerr << "-nbest-file: specifies nbest-list file (if -print-nbest is set to 1, nbest-list will be dumped to this file)\n\n";

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -