Example #1
0
int LibMain::Run(int argc, char **argv)
{
    Utils::banner(argv[0]);
    CmdSwitchFile internalConfig(SwitchParser);
    std::string configName = Utils::QualifiedFile(argv[0], ".cfg");
    std::fstream configTest(configName.c_str(), std::ios::in);
    if (!configTest.fail())
    {
        configTest.close();
        if (!internalConfig.Parse(configName.c_str()))
            Utils::fatal("Corrupt configuration file");
    }
    if (!SwitchParser.Parse(&argc, argv))
    {
        Utils::usage(argv[0], usageText);
    }
    if (argc < 2 && File.GetCount() < 3)
    {
        Utils::usage(argv[0], usageText);
    }

    // setup
    ObjString outputFile = argv[1];
    size_t n = outputFile.find_last_of('.');
    if (n == std::string::npos || (n != outputFile.size()-1 && outputFile[n+1] != 'l'))
    {
        outputFile += ".l";
    }

    LibManager librarian(outputFile, caseSensitiveSwitch.GetValue());
    if (librarian.IsOpen())
        if (!librarian.LoadLibrary())
        {
            std::cout << outputFile.c_str() << " is not a library" << std::endl;
            return 1;
        }
    for (int i= 2; i < argc; i++)
        AddFile(librarian, argv[i]);
    for (int i = 1; i < File.GetCount(); i++)
        AddFile(librarian, File.GetValue()[i]);
    for (CmdFiles::FileNameIterator it = addFiles.FileNameBegin(); it != addFiles.FileNameEnd(); ++it)
    {
        librarian.AddFile(*(*it));
    }
    for (CmdFiles::FileNameIterator it = replaceFiles.FileNameBegin(); it != replaceFiles.FileNameEnd(); ++it)
    {
        librarian.ReplaceFile(*(*it));
    }
    if (modified)
        if (!librarian.SaveLibrary())
        {
            std::cout << "Error writing library file" << std::endl;
            return 1;
        }
    return 0;
}
Example #2
0
int BRCMain::Run(int argc, char **argv)
{
    Utils::banner(argv[0]);
    CmdSwitchFile internalConfig(SwitchParser);
    std::string configName = Utils::QualifiedFile(argv[0], ".cfg");
    std::fstream configTest(configName.c_str(), std::ios::in);
    if (!configTest.fail())
    {
        configTest.close();
        if (!internalConfig.Parse(configName.c_str()))
            Utils::fatal("Corrupt configuration file");
    }
    if (!SwitchParser.Parse(&argc, argv))
    {
        Utils::usage(argv[0], usageText);
    }
    if (argc < 2 || (argc == 2 && File.GetCount() < 2))
    {
        Utils::usage(argv[0], usageText);
    }
        
    // setup
    ObjString outputFile = Utils::QualifiedFile(argv[1], ".obr");

    CmdFiles files(argv + 2);
    if (File.GetCount())
        files.Add(File.GetValue() + 1);
    BRCLoader loader(files);
    bool ok = loader.load();
    if (ok)
    {
        BRCWriter writer(outputFile, loader);
        ok = writer.write();
    }
    return !ok;
}
int main(int argc, char *argv[])
{
  try
  {
    ConfigChecker cc;
    cc.addIntegerParam("verboseLevel", false, true,
      "level of the verbose information 0=no verbose, 1=normal, 2=more");
    cc.addStringParam("config", OPTIONAL, ARG_REQUIRED,
      "Train config file name ");
    cc.addStringParam("configTest", OPTIONAL, ARG_REQUIRED,
      "Unsupervised adaptation config file name ");
    cc.addStringParam("targetIdList", MANDATORY, ARG_REQUIRED,
      "targets list");
    cc.addStringParam("inputWorldFilename", MANDATORY, ARG_REQUIRED,
      "world model");
    cc.addStringParam("testsIdList", MANDATORY, ARG_REQUIRED, "tests list");
    cc.addBooleanParam("NISTprotocol", MANDATORY, ARG_REQUIRED,
      "true to follow unsupervised NIST protocol, false to follow BATCH protocol");
    cc.addBooleanParam("WMAP", false, false,
      "NO MORE USED, Choice of WMAP (one Gaussian) to compute trial feature server weights, need other param : MUtarget,MUimp,SIGMAtarget and SIGMAIMP;TAR weight and IMPweight, thrMin and thrMax");
    cc.addBooleanParam("WMAPGMM", false, false,
      "Choice of WMAP GMM to compute trial feature server weights, param needed : two gmm of scores, TARScoresModel and NONScoresModel. Need also a value for Priors update, initPriorImp (10) and initPriorTar(1) ");
    cc.addBooleanParam("TNORM", false, false,
      " TNORM scores before computing WMAP, need gmm of Tnormed scores and a param : impScoreFile, score file for TNORM and testsNames, the list of trial segments ");
    cc.addBooleanParam("FAST", false, false,
      "FAST MODE : For computing LLR use top ten info files AND FOR FUSING EM MODELS WHEN UPDATING");
    cc.addBooleanParam("FromResFile", false, false,
      " Avoid to compute LLR for WMAP computing, search LLR in a score file, param needed: InputResFilename");
    cc.addBooleanParam("CrossValid", false, false,
      " compute LLR of a percentage of train data on a model learnt on a percentage of train data AverageIt times and return the best ML (one iter) model, need AverageIt, SelectedTrain.");
    cc.addBooleanParam("Oracle", false, false,
      " For Oracle (supervised) experiments, need targetTests to perform adaptation on target tests only");
    cc.addBooleanParam("REGRESS", false, false,
      "Use logistic regression for adaptation weights computing, need BETA and THETA");
    cc.addIntegerParam("MaxMixturesCount", false, true,
      "max mixtures stored in the mixture server (in memory)");
    cc.addIntegerParam("LLKthreshold", false, true,
      "thresholds the results of LLR in order to avoid problem in WMAP computing");
    cc.addStringParam("computeLLKWithTopDistribs", true, true,
      "PARTIAL/COMPLETE: will compute LLK with topdistribs. COMPLETE: add world LLK to client LLK, PARTIAL: just keeps the topDistrib LLK");
    cc.addIntegerParam("topDistribsCount ", false, true,
      "Number of distrib to approximate complete LLK");
    cc.addStringParam("InfoExtension", false, true,
      "Extension for top ten info files");
    cc.addStringParam("InfoPath", false, true, "Path for top ten info files");
    cc.addFloatParam("OptimalScore", false, true,
      "Used for updating  priors (fixedPriors == false), if LLR is superior add one for target count, else add one for impostors count ");
    cc.addBooleanParam("SegMode", MANDATORY, ARG_REQUIRED,
      "For adaptation by segments (for the moment support only 3 frame segments)");
    cc.addIntegerParam("mixtureDistribCountForGMMScores", false, true,
      "NUMBER OF GAUSSIAN IN SCORES GMM");
      cc.addBooleanParam("ScoresByTarget", MANDATORY, ARG_REQUIRED," IF SET TO TRUE TWO GMM (TAR AND NON) ARE NEEDED BY CLIENT (idcinet.tar and idclient.non)");
    cc.addStringParam("TARListFilename", false, true, "List of the TAR model id (used when ScoresByTarget is set to true)");
cc.addIntegerParam("ResetNbAdapt ", false, true,
      "Max number of tests used for adaptation");
    Config tmp;
    CmdLine cmdLine(argc, argv);
    if (cmdLine.displayHelpRequired())
      {				// --help
	cout << "************************************" << endl;
	cout << "********** SpkAdapt.exe *********" << endl;
	cout << "************************************" << endl;
	cout << endl;
	cout <<
	  "Unsupervised adaptation process, update model using test trial information following NIST protocol"
	  << endl;
	cout << "" << endl;
	cout << endl;
	cout << "Command Line example: " << endl;
	cout <<
	  "SpkAdapt.exe --config cfg/TrainTarget.cfg --configTest cfg/TrainTest.cfg --inputWorldFilename world --targetIdList ./lst/id.lst --testsIdList ./lst/tests.list --outputLLRFilename file --NISTprotocol true"
	  << endl;
	cout << cc.getParamList() << endl;
      }
    else
      {
	cmdLine.copyIntoConfig(tmp);
	Config config(tmp.getParam("config"));
	cmdLine.copyIntoConfig(config);
	Config configTest(tmp.getParam("configTest"));
	if (config.existsParam("verbose"))
	  verbose = config.getParam("verbose").toBool();
	else
	  verbose = false;
	bool segmode=false;
	if (config.existsParam("SegMode"))
	  segmode = config.getParam("SegMode").toBool();
	if (verbose)
	  verboseLevel = 1;
	else
	  verboseLevel = 0;
	if (config.existsParam("verboseLevel"))
	  verboseLevel = config.getParam("verboseLevel").toLong();
	if (verboseLevel > 0)
	  verbose = true;
	
	TrainTargetAdapt(config, configTest);	// Launch process

      }
  }
  catch(alize::Exception & e)
  {
    cout << e.toString() << endl;
  }

  return 0;
}
Example #4
0
int AsmMain::Run(int argc, char *argv[])
{
    int rv = 0;
    Utils::banner(argv[0]);
    CmdSwitchFile internalConfig(SwitchParser);
    std::string configName = Utils::QualifiedFile(argv[0], ".cfg");
    std::fstream configTest(configName.c_str(), std::ios::in);
    if (configTest != NULL)
    {
        configTest.close();
        if (!internalConfig.Parse(configName.c_str()))
            Utils::fatal("Corrupt configuration file");
    }
    if (!SwitchParser.Parse(&argc, argv) || (argc == 1 && File.GetCount() <= 1))
    {
        Utils::usage(argv[0], usageText);
    }
    CmdFiles files(argv+1);
    if (File.GetValue())
        files.Add(File.GetValue() + 1);
    if (files.GetSize() > 1 && OutputFile.GetValue().size())
        Utils::fatal("Cannot specify output file for multiple input files");
    std::string sysSrchPth;
    std::string srchPth;
    if (includePath.GetValue().size())
    {
        size_t n = includePath.GetValue().find_first_of(';');
        if (n == std::string::npos)
        {
            sysSrchPth = includePath.GetValue();
        }
        else
        {
            sysSrchPth = includePath.GetValue().substr(0, n);
            srchPth = includePath.GetValue().substr(n+1);
        }
    }
    for (CmdFiles::FileNameIterator it = files.FileNameBegin(); it != files.FileNameEnd(); ++it)
    {
        std::string inName = (*it)->c_str();
        int npos = inName.find_last_of(".");
        if (npos == std::string::npos || npos && inName[npos-1] == '.' || (npos != inName.size()-1 && inName[npos+1] == CmdFiles::DIR_SEP[0]))
        {
            inName = Utils::QualifiedFile( (*it)->c_str(), ".asm");
        }
        PreProcessor pp(inName, srchPth, sysSrchPth,
                 false, false, '%', false, false, true);
        int n = Defines.GetCount();
        for (int i=0; i < n; i++)
        {
            CmdSwitchDefine::define *v = Defines.GetValue(i);
            pp.Define(v->name, v->value, false);
        }
        std::string outName;
        if (OutputFile.GetValue().size() != 0)
            outName = OutputFile.GetValue();
        else
            outName = Utils::QualifiedFile( (*it)->c_str(), ".o");
        if (PreprocessOnly.GetValue())
        {
            std::string working = Utils::QualifiedFile((*it)->c_str(), ".i");
            std::fstream out(working.c_str(), std::ios::out);
            if (out == NULL)
            {
                Utils::fatal(std::string(std::string("Could not open ") + working.c_str() + " for write.").c_str());
            }
            else
            {
                while (pp.GetLine(working))
                {
                    CheckAssign(working, pp);
                    out << working << std::endl;
                }
            }
            out.close();
        }
        else
        {
            Listing listing;
            AsmFile asmFile(pp, CaseInsensitive.GetValue(), listing);
            if (asmFile.Read())
            {
                if (!asmFile.Write(outName, inName) || Errors::ErrorCount())
                {
                    rv = 1;
                }
                else if (CreateListFile.GetValue())
                {
                    std::string listingName = Utils::QualifiedFile( (*it)->c_str(), ".lst");
                    if (!listing.Write(listingName, inName, CreateListFile.GetValue('m')))
                    {
                        rv = 1;
                    }
                }
            }
            else
            {
                rv = 1;
            }
        if (rv)
            unlink(outName.c_str());
        }
    }
    return rv;
}