caravan.dpr

来自「解码器是基于短语的统计机器翻译系统的核心模块」· DPR 代码 · 共 112 行

DPR
112
字号
(*
* CARAVAN.DPR  -  The main program** Copyright (C) 2006 by Yidong Chen <ydchen@xmu.edu.cn>Institute of Artificial Intelligence, Xiamen University* Begin       : 09/18/2006* Last Change : 09/18/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.*)
PROGRAM CARAVAN;

{$APPTYPE CONSOLE}

USES
  SysUtils,
  Classes,
  FSTRLIST IN 'FSTRLIST.PAS',
  HASH IN 'HASH.pas',
  COMMON IN 'COMMON.PAS',
  CONFFILE IN 'CONFFILE.PAS',
  DPDRIVER IN 'DPDRIVER.PAS',
  LM IN 'LM.PAS',
  BP IN 'BP.PAS',
  PREPROC IN 'PREPROC.pas',
  SEGTAG IN 'SEGTAG.PAS',
  ICTCLAS IN 'ICTCLAS.PAS',
  NEON IN 'NEON.PAS',
  PERIOD IN 'PERIOD.PAS';

VAR strSysPathName: STRING;

    cfConfig: TConfFile;

    rReturn: Real;

    strInputFile, strOutputFile: STRING;
    atAction: TActionType;
    rtType: TResultType;
    stType: TSegType;
    ptType: TPhraseType;

PROCEDURE Help(strApp: STRING);
BEGIN
  WriteLn('Usage: ', ExtractFileBase(strApp), ' <.ini File> s-flag r-flag <Src File> <Tgt File>');
  WriteLn;
  WriteLn('s-flag: none | mandel | ict');
  WriteLn('r-flag: ppb | pbnw');
  Halt;
END;

BEGIN
  { TODO -oUser -cConsole Main : Insert code here }
  WriteLn('Phrase-based decoder using the algrithm from (Zens 2002).');

  IF (ParamCount<>5) THEN Help(ParamStr(0));

  strSysPathName:=ExtractFilePath(GetModuleName(HInstance));

  IF NOT FileExists(strSysPathName+ParamStr(1)) THEN Help(ParamStr(0));

  rtType:=rteNone; stType:=steNone;

  IF UpperCase(ParamStr(2))='NONE' THEN stType:=steNone
  ELSE IF UpperCase(ParamStr(2))='MANDEL' THEN stType:=steMandel
  ELSE IF UpperCase(ParamStr(2))='ICT' THEN stType:=steICT
  ELSE Help(ParamStr(0));

  IF UpperCase(ParamStr(3))='PPB' THEN rtType:=rtePurePb
  ELSE IF UpperCase(ParamStr(3))='PBNW' THEN rtType:=rtePbNeonWord
  ELSE Help(ParamStr(0));

  ptType:=pteNoBlank;
  atAction:=ate863File;

  IF FileExists(ParamStr(4)) THEN strInputFile:=ParamStr(4)
  ELSE Help(ParamStr(0));
  IF CanFileBeCreated(ParamStr(5)) THEN strOutputFile:=ParamStr(5)
  ELSE Help(ParamStr(0));

  cfConfig:=TConfFile.Create(strSysPathName+ParamStr(1), strSysPathName);

  rReturn:=DPDriver.Init(cfConfig, rtType, stType, ptType);
  WriteLn(rReturn:2:2, 's was used to do initializtion.');

  CASE atAction OF
  ate863File:
    BEGIN
      WriteLn('Translating ', strInputFile, '...');
      rReturn:=DPDRIVER.Translate863File(strInputFile, strOutputFile);
      WriteLn(rReturn:2:2, 's was used.');
    END;
  END;

  //DPDRIVER.CleanUp;
  cfConfig.Free;
END.

⌨️ 快捷键说明

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