本文整理汇总了C++中ParamVector类的典型用法代码示例。如果您正苦于以下问题:C++ ParamVector类的具体用法?C++ ParamVector怎么用?C++ ParamVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParamVector类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildIntegerParams
ParamVector* buildIntegerParams(CExport* exporter, int integer)
{
exporter->extra_paramVectors.push_back(ParamVector());
ParamVector* vec = &exporter->extra_paramVectors.back();
vec->push_back(buildIntegerParam(exporter, integer));
return vec;
}
示例2: addIntegerAtStartParams
ParamVector* addIntegerAtStartParams(CExport* exporter, int integer, const ParamVector* v)
{
exporter->extra_paramVectors.push_back(ParamVector());
ParamVector* vec = &exporter->extra_paramVectors.back();
*vec = *v; // copy all contents
vec->insert(vec->begin(), buildIntegerParam(exporter, integer));
return vec;
}
示例3: isInList
bool isInList(const TCHAR *token2Find, ParamVector & params) {
int nrItems = params.size();
for (int i = 0; i < nrItems; ++i)
{
if (!lstrcmp(token2Find, params.at(i))) {
params.erase(params.begin() + i);
return true;
}
}
return false;
};
示例4: getParamVal
bool getParamVal(TCHAR c, ParamVector & params, generic_string & value) {
value = TEXT("");
int nrItems = params.size();
for (int i = 0; i < nrItems; ++i)
{
const TCHAR * token = params.at(i);
if (token[0] == '-' && lstrlen(token) >= 2 && token[1] == c) { //dash, and enough chars
value = (token+2);
params.erase(params.begin() + i);
return true;
}
}
return false;
}
示例5: func
double
PerplexityOptimizer::Optimize(ParamVector ¶ms, Optimization technique) {
_numCalls = 0;
ComputeEntropyFunc func(*this);
int numIter;
double minEntropy;
clock_t startTime = clock();
switch (technique) {
case PowellOptimization:
minEntropy = MinimizePowell(func, params, numIter);
break;
case LBFGSOptimization:
minEntropy = MinimizeLBFGS(func, params, numIter);
break;
case LBFGSBOptimization:
minEntropy = MinimizeLBFGSB(func, params, numIter);
break;
default:
throw std::runtime_error("Unsupported optimization technique.");
}
clock_t endTime = clock();
Logger::Log(1, "Iterations = %i\n", numIter);
Logger::Log(1, "Elapsed Time = %f\n",
float(endTime - startTime) / CLOCKS_PER_SEC);
Logger::Log(1, "Perplexity = %f\n", exp(minEntropy));
Logger::Log(1, "Num OOVs = %lu\n", _numOOV);
Logger::Log(1, "Num ZeroProbs = %lu\n", _numZeroProbs);
Logger::Log(1, "Func Evals = %lu\n", _numCalls);
Logger::Log(1, "OptParams = [ ");
for (size_t i = 0; i < params.length(); i++)
Logger::Log(1, "%f ", params[i]);
Logger::Log(1, "]\n");
return minEntropy;
}
示例6: exp
void
KneserNeySmoothing::_ComputeWeights(const ParamVector &featParams) {
_ngramWeights.set(0);
for (size_t f = 0; f < featParams.length(); ++f)
if (featParams[f] != 0)
_ngramWeights += _pLM->features(_order)[f] * featParams[f];
_ngramWeights = exp(_ngramWeights);
}
示例7: getParamValFromString
bool getParamValFromString(const TCHAR *str, ParamVector & params, generic_string & value)
{
value = TEXT("");
int nrItems = params.size();
for (int i = 0; i < nrItems; ++i)
{
const TCHAR * token = params.at(i);
generic_string tokenStr = token;
int pos = tokenStr.find(str);
if (pos != -1 && pos == 0)
{
value = (token + lstrlen(str));
params.erase(params.begin() + i);
return true;
}
}
return false;
}
示例8:
vd::bytesize
ParamSet::GetAllSymbols(
ParamVector& params) const
{
vd::bytesize count = 0;
MapTypes::const_iterator it;
for(it = m_Types.begin(); it != m_Types.end(); it++)
{
params.push_back(it->first);
count++;
}
return count;
}
示例9: r
bool
KneserNeySmoothing::Estimate(const ParamVector ¶ms,
const NgramLMMask *pMask,
ProbVector &probs,
ProbVector &bows) {
// Unpack discount parameters.
if (_tuneParams) {
// Check of out-of-bounds discount parameters.
for (size_t i = 0; i < _discOrder; i++)
if (params[i] < 0 || params[i] > i+1) {
Logger::Log(2, "Clipping\n");
return false;
}
_discParams[Range(1, _discParams.length())] = params[Range(_discOrder)];
}
// Check of out-of-bounds n-gram weighting parameters.
size_t numDiscParams = _tuneParams ? _discOrder : 0;
for (size_t i = numDiscParams; i < params.length(); i++)
if (fabs(params[i] > 100)) {
Logger::Log(2, "Clipping\n");
return false;
}
// Compute n-gram weights and inverse history counts, if necessary.
size_t numFeatures = _pLM->features(_order).size();
if (numFeatures > 0) {
Range r(numDiscParams, numDiscParams + numFeatures);
_ComputeWeights(ParamVector(params[r]));
_invHistCounts.set(0);
BinWeight(_pLM->hists(_order), _effCounts * _ngramWeights,
_invHistCounts);
_invHistCounts = CondExpr(_invHistCounts == 0,
0, (Param)1 / _invHistCounts);
}
// Estimate probs and bows using optimized methods.
if (numFeatures > 0) {
if (pMask != NULL)
_EstimateWeightedMasked(pMask, probs, bows);
else
_EstimateWeighted(probs, bows);
} else {
if (pMask != NULL)
_EstimateMasked(pMask, probs, bows);
else
_Estimate(probs, bows);
}
return true;
}
示例10: parseCommandLine
//commandLine should contain path to n++ executable running
void parseCommandLine(TCHAR * commandLine, ParamVector & paramVector) {
//params.erase(params.begin());
//remove the first element, since thats the path the the executable (GetCommandLine does that)
TCHAR stopChar = TEXT(' ');
if (commandLine[0] == TEXT('\"')) {
stopChar = TEXT('\"');
++commandLine;
}
//while this is not really DBCS compliant, space and quote are in the lower 127 ASCII range
while(commandLine[0] && commandLine[0] != stopChar)
{
++commandLine;
}
// For unknown reason, the following command :
// c:\NppDir>notepad++
// (without quote) will give string "notepad++\0notepad++\0"
// To avoid the unexpected behaviour we check the end of string before increasing the pointer
if (commandLine[0] != '\0')
++commandLine; //advance past stopChar
//kill remaining spaces
while(commandLine[0] == TEXT(' '))
++commandLine;
bool isFile = checkSingleFile(commandLine); //if the commandline specifies only a file, open it as such
if (isFile) {
paramVector.push_back(commandLine);
return;
}
bool isInFile = false;
bool isInWhiteSpace = true;
paramVector.clear();
size_t commandLength = lstrlen(commandLine);
for (size_t i = 0; i < commandLength; ++i)
{
switch(commandLine[i]) {
case '\"': { //quoted filename, ignore any following whitespace
if (!isInFile) { //" will always be treated as start or end of param, in case the user forgot to add an space
paramVector.push_back(commandLine+i+1); //add next param(since zero terminated generic_string original, no overflow of +1)
}
isInFile = !isInFile;
isInWhiteSpace = false;
//because we dont want to leave in any quotes in the filename, remove them now (with zero terminator)
commandLine[i] = 0;
break; }
case '\t': //also treat tab as whitespace
case ' ': {
isInWhiteSpace = true;
if (!isInFile)
commandLine[i] = 0; //zap spaces into zero terminators, unless its part of a filename
break; }
default: { //default TCHAR, if beginning of word, add it
if (!isInFile && isInWhiteSpace) {
paramVector.push_back(commandLine+i); //add next param
isInWhiteSpace = false;
}
break; }
}
}
//the commandline generic_string is now a list of zero terminated strings concatenated, and the vector contains all the substrings
}
示例11: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
LPTSTR cmdLine = ::GetCommandLine();
ParamVector params;
parseCommandLine(cmdLine, params);
MiniDumper mdump; //for debugging purposes.
bool TheFirstOne = true;
::SetLastError(NO_ERROR);
::CreateMutex(NULL, false, TEXT("nppInstance"));
if (::GetLastError() == ERROR_ALREADY_EXISTS)
TheFirstOne = false;
bool isParamePresent;
bool showHelp = isInList(FLAG_HELP, params);
bool isMultiInst = isInList(FLAG_MULTI_INSTANCE, params);
CmdLineParams cmdLineParams;
cmdLineParams._isNoTab = isInList(FLAG_NOTABBAR, params);
cmdLineParams._isNoPlugin = isInList(FLAG_NO_PLUGIN, params);
cmdLineParams._isReadOnly = isInList(FLAG_READONLY, params);
cmdLineParams._isNoSession = isInList(FLAG_NOSESSION, params);
cmdLineParams._isPreLaunch = isInList(FLAG_SYSTRAY, params);
cmdLineParams._alwaysOnTop = isInList(FLAG_ALWAYS_ON_TOP, params);
cmdLineParams._showLoadingTime = isInList(FLAG_LOADINGTIME, params);
cmdLineParams._isSessionFile = isInList(FLAG_OPENSESSIONFILE, params);
cmdLineParams._isRecursive = isInList(FLAG_RECURSIVE, params);
cmdLineParams._langType = getLangTypeFromParam(params);
cmdLineParams._localizationPath = getLocalizationPathFromParam(params);
cmdLineParams._line2go = getNumberFromParam('n', params, isParamePresent);
cmdLineParams._column2go = getNumberFromParam('c', params, isParamePresent);
cmdLineParams._point.x = getNumberFromParam('x', params, cmdLineParams._isPointXValid);
cmdLineParams._point.y = getNumberFromParam('y', params, cmdLineParams._isPointYValid);
if (showHelp)
{
::MessageBox(NULL, COMMAND_ARG_HELP, TEXT("Notepad++ Command Argument Help"), MB_OK);
}
NppParameters *pNppParameters = NppParameters::getInstance();
if (cmdLineParams._localizationPath != TEXT(""))
{
pNppParameters->setStartWithLocFileName(cmdLineParams._localizationPath);
}
pNppParameters->load();
// override the settings if notepad style is present
if (pNppParameters->asNotepadStyle())
{
isMultiInst = true;
cmdLineParams._isNoTab = true;
cmdLineParams._isNoSession = true;
}
// override the settings if multiInst is choosen by user in the preference dialog
const NppGUI & nppGUI = pNppParameters->getNppGUI();
if (nppGUI._multiInstSetting == multiInst)
{
isMultiInst = true;
// Only the first launch remembers the session
if (!TheFirstOne)
cmdLineParams._isNoSession = true;
}
generic_string quotFileName = TEXT("");
// tell the running instance the FULL path to the new files to load
size_t nrFilesToOpen = params.size();
const TCHAR * currentFile;
TCHAR fullFileName[MAX_PATH];
for(size_t i = 0; i < nrFilesToOpen; ++i)
{
currentFile = params.at(i);
if (currentFile[0])
{
//check if relative or full path. Relative paths dont have a colon for driveletter
BOOL isRelative = ::PathIsRelative(currentFile);
quotFileName += TEXT("\"");
if (isRelative)
{
::GetFullPathName(currentFile, MAX_PATH, fullFileName, NULL);
quotFileName += fullFileName;
}
else
{
if ((currentFile[0] == '\\' && currentFile[1] != '\\') || currentFile[0] == '/')
{
quotFileName += getDriveLetter();
quotFileName += ':';
}
quotFileName += currentFile;
}
quotFileName += TEXT("\" ");
}
}
//Only after loading all the file paths set the working directory
::SetCurrentDirectory(NppParameters::getInstance()->getNppPath().c_str()); //force working directory to path of module, preventing lock
//.........这里部分代码省略.........
示例12: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
LPTSTR cmdLine = ::GetCommandLine();
ParamVector params;
parseCommandLine(cmdLine, params);
MiniDumper mdump; //for debugging purposes.
bool TheFirstOne = true;
::SetLastError(NO_ERROR);
::CreateMutex(NULL, false, TEXT("nppInstance"));
if (::GetLastError() == ERROR_ALREADY_EXISTS)
TheFirstOne = false;
bool isParamePresent;
bool showHelp = isInList(FLAG_HELP, params);
bool isMultiInst = isInList(FLAG_MULTI_INSTANCE, params);
bool doFunctionListExport = isInList(FLAG_FUNCLSTEXPORT, params);
bool doPrintAndQuit = isInList(FLAG_PRINTANDQUIT, params);
CmdLineParams cmdLineParams;
cmdLineParams._isNoTab = isInList(FLAG_NOTABBAR, params);
cmdLineParams._isNoPlugin = isInList(FLAG_NO_PLUGIN, params);
cmdLineParams._isReadOnly = isInList(FLAG_READONLY, params);
cmdLineParams._isNoSession = isInList(FLAG_NOSESSION, params);
cmdLineParams._isPreLaunch = isInList(FLAG_SYSTRAY, params);
cmdLineParams._alwaysOnTop = isInList(FLAG_ALWAYS_ON_TOP, params);
cmdLineParams._showLoadingTime = isInList(FLAG_LOADINGTIME, params);
cmdLineParams._isSessionFile = isInList(FLAG_OPENSESSIONFILE, params);
cmdLineParams._isRecursive = isInList(FLAG_RECURSIVE, params);
cmdLineParams._langType = getLangTypeFromParam(params);
cmdLineParams._localizationPath = getLocalizationPathFromParam(params);
cmdLineParams._easterEggName = getEasterEggNameFromParam(params, cmdLineParams._quoteType);
cmdLineParams._ghostTypingSpeed = getGhostTypingSpeedFromParam(params);
// getNumberFromParam should be run at the end, to not consuming the other params
cmdLineParams._line2go = getNumberFromParam('n', params, isParamePresent);
cmdLineParams._column2go = getNumberFromParam('c', params, isParamePresent);
cmdLineParams._pos2go = getNumberFromParam('p', params, isParamePresent);
cmdLineParams._point.x = getNumberFromParam('x', params, cmdLineParams._isPointXValid);
cmdLineParams._point.y = getNumberFromParam('y', params, cmdLineParams._isPointYValid);
if (showHelp)
::MessageBox(NULL, COMMAND_ARG_HELP, TEXT("Notepad++ Command Argument Help"), MB_OK);
NppParameters *pNppParameters = NppParameters::getInstance();
NppGUI & nppGui = const_cast<NppGUI &>(pNppParameters->getNppGUI());
bool doUpdate = nppGui._autoUpdateOpt._doAutoUpdate;
if (doFunctionListExport || doPrintAndQuit) // export functionlist feature will serialize fuctionlist on the disk, then exit Notepad++. So it's important to not launch into existing instance, and keep it silent.
{
isMultiInst = true;
doUpdate = false;
cmdLineParams._isNoSession = true;
}
if (cmdLineParams._localizationPath != TEXT(""))
{
pNppParameters->setStartWithLocFileName(cmdLineParams._localizationPath);
}
pNppParameters->load();
pNppParameters->setFunctionListExportBoolean(doFunctionListExport);
pNppParameters->setPrintAndExitBoolean(doPrintAndQuit);
// override the settings if notepad style is present
if (pNppParameters->asNotepadStyle())
{
isMultiInst = true;
cmdLineParams._isNoTab = true;
cmdLineParams._isNoSession = true;
}
// override the settings if multiInst is choosen by user in the preference dialog
const NppGUI & nppGUI = pNppParameters->getNppGUI();
if (nppGUI._multiInstSetting == multiInst)
{
isMultiInst = true;
// Only the first launch remembers the session
if (!TheFirstOne)
cmdLineParams._isNoSession = true;
}
generic_string quotFileName = TEXT("");
// tell the running instance the FULL path to the new files to load
size_t nbFilesToOpen = params.size();
for (size_t i = 0; i < nbFilesToOpen; ++i)
{
const TCHAR * currentFile = params.at(i).c_str();
if (currentFile[0])
{
//check if relative or full path. Relative paths dont have a colon for driveletter
quotFileName += TEXT("\"");
quotFileName += relativeFilePathToFullFilePath(currentFile);
quotFileName += TEXT("\" ");
}
}
//.........这里部分代码省略.........