コード例 #1
0
ファイル: TuneSet.cpp プロジェクト: Libardo1/ucam-smt
TupleArcFst* TuneSet::GetVectorLattice (const Sid s,
                                        const bool use_cache) const {
  if (use_cache) {
    return cachedLattices[s];
  }
  return LoadLattice (s);
}
コード例 #2
0
ファイル: TuneSet.cpp プロジェクト: Libardo1/ucam-smt
void TuneSet::Initialize (const bool use_cache) {
  if (FLAGS_lats.empty() ) {
    cerr << "ERROR: mandatory parameter not specified: 'lats'\n";
    exit (1);
  }
  if (!FLAGS_idxlimits.empty() ) {
    InitializeFromLimits (ids, FLAGS_idxlimits.data() );
  }
  if (!FLAGS_idxscript.empty() ) {
    InitializeFromScript (ids, FLAGS_idxscript.data() );
  }
  if (ids.size() == 0) {
    cerr
        << "ERROR: must specify either 'idxlimits' or 'idxscript' parameters"
        << '\n';
    exit (1);
  }
  tracer << "idx min=" << ids.front() << '\n';
  tracer << "idx max=" << ids.back() << '\n';
  m_pattern = FLAGS_lats;
  if (use_cache) {
    cachedLattices.push_back (0);
    for (std::vector<Sid>::const_iterator sit = ids.begin(); sit != ids.end();
         ++sit) {
      cachedLattices.push_back (LoadLattice (*sit) );
    }
    tracer << ids.size() << " vector lattices loaded\n";
  }
}
コード例 #3
0
ファイル: genwrapper.cpp プロジェクト: tell/pbkz
    mat_ZZ getbasis(int n,int seed,double bit=10) {
        initialize();
        std::ostringstream fname;
        fname << getfname(n,seed,bit,0);

        mat_ZZ L;
        if (FileExists(fname)==true) {
            LoadLattice(L,fname.str());
        } else {
            gen_svpchallenge(L,n,to_ZZ(seed),bit);
#ifdef _allow_cachefiles
            SaveLattice(L,fname.str());
#endif
        }
        return L;
    }
コード例 #4
0
ファイル: genwrapper.cpp プロジェクト: tell/pbkz
    mat_ZZ getlllbasis(int n,int seed,double bit=10) {
        initialize();
        std::ostringstream fname;
        fname << getfname(n,seed,bit,1);
        mat_ZZ L;
        
        if (FileExists(fname)==true) {
            LoadLattice(L,fname.str());
        } else {
            L = getbasis(n,seed,bit);
            ::BigLLL(L,0,0.999,VL1);
#ifdef _allow_cachefiles
            SaveLattice(L,fname.str());
#endif
        }
        return L;
    }
コード例 #5
0
ファイル: genwrapper.cpp プロジェクト: tell/pbkz
    mat_ZZ getbasis(int n,int seed,vec_ZZ& phi,double bit=10) {
        initialize();
        
        std::ostringstream fname;
        fname << getfname(n,seed,bit,0);

        mat_ZZ L;
        if (FileExists(fname)==true) {
            LoadLattice(L,fname.str());
            fname << ".phi";
            LoadElement(phi,fname.str());
        } else {
            vec_ZZ phi;
            //n stands for index
            gen_idealsvpchallenge(L,n,to_ZZ(seed),phi); 
#ifdef _allow_cachefiles
            SaveLattice(L,fname.str());
            fname << ".phi";
            SaveElement(phi,fname.str());
#endif
        }
        return L;
    }
コード例 #6
0
ファイル: HBuild.c プロジェクト: BackupTheBerlios/artbody-svn
#include "HLM.h"



typedef enum {unknown, wordLoop, boBiGram, matBiGram, multiLat, wordPair} BuildType;



static int trace     = 0;           /* Trace flags */



static LabId enterId;               /* id of !ENTRY label in ngram */

static LabId exitId;                /* id of !EXIT label in ngram */

static LabId bStartId=NULL;         /* id of start bracket */

static LabId bEndId=NULL;           /* id of end bracket */



static LabId unknownId;             /* id of unknown label in ngram */

static Boolean zapUnknown = FALSE;  /* zap unknown symbols from bigram */



MemHeap buildStack;



/* ---------------- Configuration Parameters --------------------- */



static ConfParam *cParm[MAXGLOBS];

static int nParm = 0;            /* total num params */



/* ---------------- Process Command Line ------------------------- */



/* SetConfParms: set conf parms relevant to this tool */

void SetConfParms(void)

{

   int i;



   nParm = GetConfig("HBUILD", TRUE, cParm, MAXGLOBS);

   if (nParm>0){

      if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;

   }

}



void ReportUsage(void)

{

   printf("\nUSAGE: HBuild [options] wordList latFile\n\n");

   printf(" Option                                       Default\n\n");

   printf(" -b      binary lattice output                ASCII\n");

   printf(" -m s    load matrix bigram from s            off\n");

   printf(" -n s    load back-off bigram from s          off\n");

   printf(" -s s1 s2 s1/s2 are bigram start/end labels   !ENTER !EXIT\n");

   printf(" -t s1 s2 bracket word-loop/pair with s1 s2   off\n");

   printf(" -u s    set unknown symbol to s              !NULL\n");

   printf(" -w s    load word-pair grammar from s        off\n");

   printf(" -x s    load multi-level lattice from s      off\n");

   printf(" -z      ignore ngrams with unknown symbol    off\n");

   PrintStdOpts(""); 

   printf("\n\n");

}



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

{

   char *wordListFn,*latFn,*ipFn=NULL;

   LModel *bigramLm;

   BuildType bType = unknown;

   Boolean saveLatBin = FALSE;

   LatFormat format = HLAT_LMLIKE;

   Lattice *lat,*ipLat;

   Vocab voc;

   char  *s;



   Lattice *ProcessWordLoop(MemHeap *latHeap, Vocab *voc);

   Lattice *ProcessBiGram(MemHeap *latHeap, Vocab *voc, LModel *biLM);

   void SaveLattice(Lattice *lat, char *latFn, LatFormat format);

   Lattice *LoadLattice(MemHeap *latHeap, char *latFn, Vocab *voc,

                        Boolean shortArc);

   Lattice *ProcessWordPair(MemHeap *latHeap, Vocab *voc, char *fn);



   if(InitShell(argc,argv,hbuild_version,hbuild_vc_id)<SUCCESS)

      HError(3000,"HBuild: InitShell failed");

   InitMem();   InitLabel();

   InitMath();  

   InitDict();  InitNet();  

   InitLM();



   CreateHeap(&buildStack, "HBuild Stack",  MSTAK, 1, 0.0, 100000, LONG_MAX );



   if (!InfoPrinted() && NumArgs() == 0)

      ReportUsage();

   if (NumArgs() == 0) Exit(0);

   SetConfParms();