本文整理汇总了C++中KKStr::TrimLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ KKStr::TrimLeft方法的具体用法?C++ KKStr::TrimLeft怎么用?C++ KKStr::TrimLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KKStr
的用法示例。
在下文中一共展示了KKStr::TrimLeft方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmdLine
CmdLineExpander::CmdLineExpander (const KKStr& _applicationName,
RunLog& _log,
const KKStr& _cmdLine
):
applicationName (_applicationName),
log (_log)
{
VectorKKStr initialParameters;
KKStr cmdLine (_cmdLine);
cmdLine.TrimLeft ();
while (!cmdLine.Empty ())
{
KKStr nextField = cmdLine.ExtractQuotedStr ("\n\r\t ", false); // false = Do not decode escape characters
nextField.TrimRight ();
if (!nextField.Empty ())
initialParameters.push_back (nextField);
cmdLine.TrimLeft ();
}
BuildCmdLineParameters (initialParameters);
BuildExpandedParameterPairs ();
}
示例2: FromDelStr
PointListPtr PointList::FromDelStr (const KKStr& _s)
{
PointListPtr result = new PointList (true);
KKStr s (_s);
s.TrimLeft ();
while (s.Len () > 0)
{
char nextCh = s.FirstChar ();
char endPairChar = 0;
if (nextCh == '[')
endPairChar = ']';
else if (nextCh == '(')
endPairChar = ')';
else
{
// Not Bracketed.
endPairChar = 0;
kkint16 row = (kkint16)s.ExtractTokenInt (",\t\n\t");
kkint16 col = (kkint16)s.ExtractTokenInt (",\t\n\t");
result->PushOnBack (new Point (row, col));
}
if (endPairChar != 0)
{
KKStr pairStr = "";
auto idx = s.Find (endPairChar);
if (idx)
{
pairStr = s.SubStrSeg (0, idx);
s = s.SubStrPart (idx + 1);
}
else
{
pairStr = s;
s = "";
}
kkint16 row = (kkint16)pairStr.ExtractTokenInt (",");
kkint16 col = (kkint16)pairStr.ExtractTokenInt (",");
result->PushOnBack (new Point (row, col));
nextCh = s.FirstChar ();
if ((nextCh == ',') || (nextCh == '\n') || (nextCh == '\r') || (nextCh == '\t'))
s.ChopFirstChar ();
}
s.TrimLeft ();
}
return result;
} /* FromDelStr */
示例3: StatusFileProcessLineJobStatusChange
void KKJobManager::StatusFileProcessLineJobStatusChange (KKStr& statusLineStr)
{
kkint32 expandedJobId = statusLineStr.ExtractTokenInt ("\t");
KKJobPtr j = jobs->LookUpByJobId (expandedJobId);
if (!j)
{
log.Level (-1) << endl << endl << endl
<< "ProcessStatusLineJobStatusChange ***Error*** Could not locate Expanded" << endl
<< endl
<< " JobId[" << expandedJobId << "]" << endl
<< endl;
EndBlock ();
osWaitForEnter ();
exit (-1);
}
KKStr statusStr = statusLineStr.ExtractToken2 ("\t");
statusStr.TrimLeft ();
statusStr.TrimRight ();
KKJob::JobStatus status = KKJob::JobStatusFromStr (statusStr);
if (status == jsNULL)
{
log.Level (-1) << endl << endl << endl
<< "ProcessStatusLineJobStatusChange ***Error*** Invalid Status Specified" << endl
<< endl
<< " JobId[" << expandedJobId << "]" << endl
<< " Status[" << statusStr << "]" << endl
<< endl;
EndBlock ();
osWaitForEnter ();
exit (-1);
}
j->Status (status);
} /* ProcessStatusLineJobStatusChange */
示例4: ProcessStatusStr
void KKJob::ProcessStatusStr (const KKStr& statusStr)
{
log.Level (30) << "KKJob::ProcessStatusStr[" << statusStr << "]" << endl;
KKStr fieldName;
KKStr fieldValue;
VectorKKStr fields = statusStr.Split ('\t');
kkuint32 fieldNum = 0;
while (fieldNum < fields.size ())
{
fieldName = fields[fieldNum];
fieldNum++;
if (fieldNum < fields.size ())
{
fieldValue = fields[fieldNum];
fieldNum++;
}
else
{
fieldValue = "";
}
fieldName.Upper ();
fieldValue.TrimLeft ("\n\r\t ");
fieldValue.TrimRight ("\n\r\t ");
if (fieldName.CompareIgnoreCase ("JOBID") == 0)
jobId = atoi (fieldValue.Str ());
else if (fieldName.CompareIgnoreCase ("PARENTID") == 0)
parentId = atoi (fieldValue.Str ());
else if (fieldName.CompareIgnoreCase ("STATUS") == 0)
status = JobStatusFromStr (fieldValue);
else if (fieldName.CompareIgnoreCase ("NumProcessors") == 0)
numProcessors = fieldValue.ToInt ();
else if (fieldName.CompareIgnoreCase ("NumPorcessesAllowed") == 0)
numPorcessesAllowed = fieldValue.ToInt ();
else if (fieldName.CompareIgnoreCase ("Prerequisites") == 0)
PrerequisitesFromStr (fieldValue);
else
{
ProcessStatusField (fieldName, fieldValue);
}
}
} /* ProcessStatusStr */
示例5: ProcessStatusStr
// Will scan for fields that are specific to 'JobValidation'
void JobValidation::ProcessStatusStr (KKStrParser& statusStr)
{
log.Level (30) << "JobValidation::ProcessStatusStr[" << statusStr.Str () << "]" << endl;
KKStr fieldName;
KKStr fieldValue;
while (statusStr.MoreTokens ())
{
fieldName = statusStr.GetNextToken ("\t\n\r");
fieldName.Upper ();
fieldValue = statusStr.GetNextToken ("\t");
fieldValue.TrimLeft ("\n\r\t ");
fieldValue.TrimRight ("\n\r\t ");
ProcessStatusField (fieldName, fieldValue);
}
} /* ProcessStatusStr */
示例6: cancelFlag
ParameterJob::ParameterJob (RunLog& _log,
KKStr _desc
):
cancelFlag (false),
log (_log)
{
accuracy = 0;
startTime = 0;
_desc.TrimLeft ();
curStatus = _desc.ExtractChar ();
if ((curStatus == '0') ||
(curStatus == '1') ||
(curStatus == '2') ||
(curStatus == '3')
)
{
// We Are Ok
}
else
{
log.Level (-1) << endl
<< "ParameterJob: We have an invalid Cur Status."
<< endl;
osWaitForEnter ();
}
{
processNum = _desc.ExtractTokenInt (" ,\t");
jobId = _desc.ExtractTokenInt (" ,\t");
cParm = _desc.ExtractTokenInt (" ,\t");
gammaParm = _desc.ExtractTokenDouble (" ,\t");
aParm = _desc.ExtractTokenDouble (" ,\t");
accuracy = _desc.ExtractTokenDouble (" ,\t");
trainTime = (float)_desc.ExtractTokenDouble (" ,\t");
classTime = (float)_desc.ExtractTokenDouble (" ,\t");
numSVs = (float)_desc.ExtractTokenDouble (" ,\t");
}
}
示例7: ProcessCmdLineParameter
//.........这里部分代码省略.........
{
if ((parmValue == "NO") ||
(parmValue == "OFF") ||
(parmValue == "N")
)
encodeFeatureData = false;
else
{
encodingMethod = ModelParam::BinaryEncoding;
encodeFeatureData = true;
}
}
}
else if ((parmSwitch == "-ENUMERATECLASSES") ||
(parmSwitch == "-ENUMERATECLASS") ||
(parmSwitch == "-EC")
)
{
if ((parmValue == "NO") ||
(parmValue == "OFF") ||
(parmValue == "N")
)
enumerateClasses = false;
else
enumerateClasses = true;
}
else if (parmSwitch == "-FEATURES")
{
featureStr = parmValue;
}
else if ((parmSwitch == "-IF") ||
(parmSwitch == "-INPUTFORMAT") ||
(parmSwitch == "-IFF") ||
(parmSwitch == "-INFILEFORMAT") ||
(parmSwitch == "-SFF") ||
(parmSwitch == "-SrcFileFormat")
)
{
srcFileFormat = FeatureFileIO::FileFormatFromStr (parmValue,
true, // Valid Read Format
false // Don't care if valid write format
);
if (srcFileFormat == NULL)
{
log.Level (-1) << endl
<< endl
<< "Invalid Source File Format Specified[" << parmValue << endl
<< endl
<< "Valid Formats are <" << FeatureFileIO::FileFormatsReadOptionsStr () << ">" << endl
<< endl;
Abort (true);
}
}
else if ((parmSwitch == "-NORM") || (parmSwitch == "-NORMALIZE"))
{
normalizeData = true;
parmValue.TrimLeft ();
parmValue.TrimRight ();
if (!parmValue.Empty ())
nornParmsFileName = parmValue;
}
else if ((parmSwitch == "-R") || (parmSwitch == "-REPORT"))
reportFileName = parmValue;
else if ((parmSwitch == "-S") ||
(parmSwitch == "-SRC") ||
(parmSwitch == "-SF") ||
(parmSwitch == "-SOURCFILE") ||
(parmSwitch == "-SFN") ||
(parmSwitch == "-SRCFILENAME") ||
(parmSwitch == "-SOURCFILENAME")
)
srcFileName = parmValue;
else if ((parmSwitch == "-STAT") ||
(parmSwitch == "-STATS") ||
(parmSwitch == "-STATISTICS")
)
statistics = true;
else
{
log.Level (-1) << endl
<< "ProcessCmdLineParameter Invalid Parameter[" << parmSwitch << "]" << endl
<< endl;
Abort (true);
}
return !Abort ();
} /* ProcessCmdLineParameter */
示例8: ProcessStatusStr
void BinaryClass::ProcessStatusStr (KKStr statusStr,
MLClassListPtr mlClasses
)
{
KKStr fieldName;
class1 = NULL;
class2 = NULL;
fieldName = statusStr.ExtractToken2 ("\t");
while (!fieldName.Empty ())
{
fieldName.TrimLeft ("\n\r\t ");
fieldName.TrimRight ("\n\r\t ");
fieldName.Upper ();
if (fieldName == "ALLCLASSES")
{
class1 = NULL;
class2 = NULL;
}
else if (fieldName == "BINARYCLASSES")
{
class1 = mlClasses->GetMLClassPtr (statusStr.ExtractToken2 ("\t"));
class2 = mlClasses->GetMLClassPtr (statusStr.ExtractToken2 ("\t"));
if ((class1 == NULL) || (class2== NULL))
{
cout << "Class1 or Class2 == NULL" << endl;
}
else
{
if ((class1->Name ().Empty ()) || (class1->Name ().Empty ()))
{
cout << "Class1Name or Class2Name are empty" << endl;
}
}
}
else if (fieldName == "STATUS")
status = BinaryClassStatusFromStr (statusStr.ExtractToken2 ("\t"));
else if (fieldName == "NUMPROCESSORS")
numProcessors = statusStr.ExtractTokenInt ("\t");
else if (fieldName.CompareIgnoreCase ("FinalResultType") == 0)
resultType = FinalResultTypeFromStr (statusStr.ExtractToken2 ("\t"));
else if (fieldName.CompareIgnoreCase ("ResultsFileName") == 0)
finalResultsFileName = statusStr.ExtractToken2 ("\t");
else if (fieldName.CompareIgnoreCase ("SelectionMethod") == 0)
selectionMethod = SelectionMethodFromStr (statusStr.ExtractToken2 ("\t"));
else if (fieldName.CompareIgnoreCase ("configFileName") == 0)
configFileName = statusStr.ExtractToken2 ("\t");
fieldName = statusStr.ExtractToken2 ("\t");
}
} /* ProcessStatusStr */
示例9: ImportGPSDataGPGGA
void ImportGPSDataGPGGA (const KKStr& fileName)
{
RunLog log;
DataBasePtr dbConn = new DataBase (log);
ifstream i (fileName.Str ());
if (!i.is_open ())
{
log.Level (-1) << endl << endl
<< "ImpotrtGPSData Could not open file[" << fileName << "]" << endl
<< endl;
return;
}
log.Level (10) << endl << endl << endl << endl << endl
<< "ImpotrtGPSData FileName[" << fileName << "]" << endl << endl
<< endl;
char buff[20480];
bool firstPass = true;
int lastMinute = 0;
int linesRead = 0;
KKStr ln (256);
DateTime lastDateTime;
while (i.getline (buff, sizeof (buff)))
{
linesRead++;
ln = buff;
ln.TrimLeft ();
if (!ln.LocateStr ("GPGGA"))
continue;
VectorKKStr fields = ln.Parse (",");
if (fields.size () < 8)
continue;
if (!fields[2].EqualIgnoreCase ("$GPGGA"))
continue;
/*
0 1 2 3 4 5 6 7 8
06/01/2010, 23:59:59.818, $GPGGA, 235958, 2840.927, N, 08828.458, W, 2, 09,22.10,0,M,,,14,0000*12
06/02/2010, 00:00:10.818, $GPGGA, 000009, 2840.931, N, 08828.482, W, 1, 09,0.89,0,M,,,,*2D
06/02/2010, 00:00:21.802, $GPGGA, 000020, 2840.929, N, 08828.505, W, 1, 09,0.89,0,M,,,,*21
06/02/2010, 00:00:31.818, $GPGGA, 000030, 2840.924, N, 08828.526, W, 1, 09,0.89,0,M,,,,*2C
06/02/2010, 00:00:42.818, $GPGGA, 000041, 2840.917, N, 08828.547, W, 1, 09,0.89,0,M,,,,*2D
06/02/2010, 00:00:53.802, $GPGGA, 000052, 2840.906, N, 08828.568, W, 1, 09,1.00,0,M,,,,*22
06/02/2010, 00:01:03.802, $GPGGA, 000102, 2840.895, N, 08828.585, W, 1, 09,0.89,0,M,,,,*2E
06/02/2010, 00:01:13.818, $GPGGA, 000112, 2840.883, N, 08828.600, W, 1, 09,0.89,0,M,,,,*26
*/
KKStr dateStr = fields[0];
KKStr timeStr = fields[1];
KKStr latStr = fields[4];
KKStr logStr = fields[6];
auto x = latStr.LocateCharacter ('.');
if (!x)
continue;
KKStr latMinStr = latStr.SubStrPart (x - 2);
KKStr latDegStr = latStr.SubStrSeg (0, x - 2);
double latitude = latDegStr.ToDouble () + latMinStr.ToDouble () / 60.0;
if (fields[5].EqualIgnoreCase ("S"))
latitude = 0.0 - latitude;
x = logStr.LocateCharacter ('.');
if (!x)
continue;
KKStr logMinStr = logStr.SubStrPart (x - 2);
KKStr logDegStr = logStr.SubStrSeg (0, x - 2);
double longitude = logDegStr.ToDouble () + logMinStr.ToDouble () / 60.0;
if (fields[7].EqualIgnoreCase ("W"))
longitude = 0.0 - longitude;
DateType gmtDate (dateStr);
TimeType gmtTime (timeStr);
DateTime gmtDateTime (gmtDate, gmtTime);
DateTime localTime = gmtDateTime;
localTime.HoursAdd (-4);
DateTime startDT = localTime;
DateTime endDT = localTime;
if (firstPass)
{
firstPass = false;
startDT.SecondsAdd (-180);
}
//.........这里部分代码省略.........
示例10: ImpotrtGPSData
void ImpotrtGPSData (const KKStr& fileName)
{
RunLog log;
DataBasePtr dbConn = new DataBase (log);
ifstream i (fileName.Str ());
if (!i.is_open ())
{
log.Level (-1) << endl << endl
<< "ImpotrtGPSData Could not open file[" << fileName << "]" << endl
<< endl;
return;
}
log.Level (10) << endl << endl << endl << endl << endl
<< "ImpotrtGPSData FileName[" << fileName << "]" << endl << endl
<< endl;
char buff[20480];
bool firstPass = true;
int lastHour = 0;
DateTime lastDateTime;
while (i.getline (buff, sizeof (buff)))
{
KKStr ln = buff;
ln.TrimLeft ();
char ch = ln[0];
if ((ch < '0') || (ch > '9'))
continue;
KKStr dateStr = ln.ExtractToken2 (",");
KKStr timeStr = ln.ExtractToken2 (",");
KKStr WXTP_TaStr = ln.ExtractToken2 (",");
KKStr WXTS_TaStr = ln.ExtractToken2 (",");
KKStr WXTS_PaStr = ln.ExtractToken2 (",");
KKStr WXTP_PaStr = ln.ExtractToken2 (",");
KKStr dec_latStr = ln.ExtractToken2 (",");
KKStr dec_lonStr = ln.ExtractToken2 (",");
KKStr cogStr = ln.ExtractToken2 (",");
KKStr sogStr = ln.ExtractToken2 (",");
DateType gmtDate (dateStr);
TimeType gmtTime (timeStr);
DateTime gmtDateTime (gmtDate, gmtTime);
DateTime localTime = gmtDateTime;
localTime.HoursAdd (-4);
DateTime startDT = localTime;
DateTime endDT = localTime;
if (firstPass)
{
firstPass = false;
startDT.SecondsAdd (-180);
}
else
{
DateTime deltaDT = localTime - lastDateTime;
long deltaSecs = (long)deltaDT.Seconds ();
startDT.SecondsAdd (-(deltaSecs / 2));
}
endDT.SecondsAdd (120);
dbConn->InstrumentDataUpdateLatitudeAndLongitude (startDT, endDT, dec_latStr.ToDouble (), dec_lonStr.ToDouble ());
lastDateTime = localTime;
if (gmtTime.Minute () != lastHour)
{
lastHour = gmtTime.Hour ();
log.Level (10) << "File[" << osGetRootName (fileName) << "] GMT Time[" << gmtDate.MMM_DD_YYYY () << " - " << gmtTime.HH_MM_SS () << "]" << endl;
}
}
i.close ();
delete dbConn;
dbConn = NULL;
} /* ImpotrtGPSData */
示例11: LoadFile
void Configuration::LoadFile (RunLog& log)
{
log.Level (10) << "Configuration::LoadFile: " << fileName << endl;
kkint32 lastLineNum = 0;
if (fileName == "")
{
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** File-Name is blank" << endl
<< endl;
FormatGood (false);
return;
}
FILE* inFile = osFOPEN (fileName.Str (), "r");
if (!inFile)
{
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** Opening File: " << fileName << endl
<< endl;
FormatGood (false);
return;
}
char buff[10240];
kkint32 lineCount = 0;
curSectionName = "";
ConfSectionPtr curSection = NULL;
while (fgets (buff, sizeof (buff), inFile))
{
lastLineNum++;
KKStr line (buff);
line.TrimRight ();
line.TrimLeft ();
StripOutAnyComments (line);
log.Level (70) << line << endl;
StripOutAnyComments (line);
if (line.Empty ())
{
// If we have a blank line, we do nothing.
}
else if (line.FirstChar () == '[')
{
// Looks like definition of new section.
if (line.LastChar () == ']')
{
curSectionName = line.SubStrPart (1, line.Len () - 2);
curSectionName.TrimLeft ();
curSectionName.TrimRight ();
curSectionName.Upper ();
curSection = new ConfSection (curSectionName, lastLineNum);
sections->AddConfSection (curSection);
log.Level (30) << "LoadFile SectionName[" << curSectionName << "]." << endl;
}
else
{
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** LineNumber[" << lastLineNum << "] Improper Section Name[" << line << "]." << endl
<< endl;
formatGood = false;
}
}
else
{
if (!curSection)
{
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** Format Error LineNumber[" << lastLineNum << "]" << endl
<< " No Section Defined." << endl
<< endl;
formatGood = false;
curSectionName = "GLOBAL";
curSection = new ConfSection (curSectionName, lastLineNum);
sections->AddConfSection (curSection);
}
kkint32 equalIdx = line.LocateCharacter ('=');
if (equalIdx < 0)
{
// We have a improperly formated line.
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** LineNumber[" << lastLineNum << "] Improperly Formated Line[" << line << "]."
<< endl;
formatGood = false;
//.........这里部分代码省略.........
示例12: if
void KKJobManager::ProcessJobXmlBlockOfText (const KKStr& startStr,
istream& i
)
{
if ((startStr.SubStrPart (0, 4) != "<KKJob ") || (startStr.LastChar () != '>'))
{
log.Level (-1) << endl
<< "KKJobManager::ProcessJobXmlBlockOfText ***ERROR*** StartStr[" << startStr << "] is not a KKJob String." << endl
<< endl;
return;
}
KKStr s = startStr.SubStrPart (5);
s.TrimLeft ();
s.ChopLastChar ();
KKStr jobTypeStr = "";
kkint32 jobId = -1;
VectorKKStr parameters = s.Split (',');
for (kkuint32 x = 0; x < parameters.size (); ++x)
{
KKStr parameterStr = parameters[x];
parameterStr.TrimLeft ();
parameterStr.TrimRight ();
KKStr fieldName = parameterStr.ExtractToken2 ("=");
fieldName.TrimLeft (); fieldName.TrimRight ();
KKStr fieldValue = parameterStr.ExtractToken2 ("=");
fieldValue.TrimLeft (); fieldValue.TrimRight ();
if (fieldName.CompareIgnoreCase ("JobType") == 0)
jobTypeStr = fieldValue;
else if (fieldName.CompareIgnoreCase ("JobId") == 0)
jobId = fieldValue.ToInt ();
}
if (jobTypeStr.Empty () || (jobId < 0))
{
log.Level (-1) << endl
<< "KKJobManager::ProcessJobXmlBlockOfText ***ERROR*** StartStr[" << startStr << "]." << endl
<< " JobType and/or JobId were not provided." << endl
<< endl;
return;
}
KKJobPtr j = jobs->LookUpByJobId (jobId);
if (j == NULL)
{
// We do not have this job in memory yet. We will have to create it now.
KKStr emptyStatusStr = "JobId\t" + StrFormatInt (jobId, "ZZZZ0");
j = KKJob::CallAppropriateConstructor (this, jobTypeStr, emptyStatusStr);
}
j->CompletedJobDataRead (i);
} /* ProcessJobXmlBlockOfText */
示例13: StatusFileProcessLine
void KKJobManager::StatusFileProcessLine (const KKStr& ln,
istream& statusFile
)
{
if (ln.SubStrPart (0, 1) == "//")
{
// A coment line; we can ignore it.
return;
}
KKStr statusStr (ln);
KKStr fieldName = statusStr.ExtractToken2 ("\t");
if (fieldName.Empty ())
{
// A empty line we will ignore it.
return;
}
statusStr.TrimLeft ("\n\r\t ");
statusStr.TrimRight ("\n\r\t ");
if (fieldName.CompareIgnoreCase ("JOB") == 0)
{
// We have a KKJob entr line; the next field determines JobType fllowed by parameters for that JobType constructor.
KKStr jobTypeName = fieldName = statusStr.ExtractToken2 ("\t");
KKJobPtr j = KKJob::CallAppropriateConstructor (this, jobTypeName, statusStr);
KKJobPtr existingJob = jobs->LookUpByJobId (j->JobId ());
if (existingJob)
{
existingJob->ReFresh (*j);
delete j; j = NULL;
}
else
{
jobs->PushOnBack (j);
}
}
else if (fieldName.EqualIgnoreCase ("CPUTIMEUSED"))
{
double cpuTimeUsed = statusStr.ExtractTokenDouble ("\t");
cpuTimeTotalUsed += cpuTimeUsed;
}
else if (fieldName.EqualIgnoreCase ("CURRENTDATETIME"))
{
KKB::DateTime dateTime = KKB::DateTime (statusStr);
if (!dateTimeFirstOneFound)
{
dateTimeFirstOneFound = true;
dateTimeStarted = dateTime;
}
dateTimeEnded = dateTime;
}
else if (fieldName.EqualIgnoreCase ("ExpansionCount"))
expansionCount = statusStr.ToInt ();
else if (fieldName.EqualIgnoreCase ("ExpansionFirstJobId"))
expansionFirstJobId = statusStr.ToInt ();
else if (fieldName.EqualIgnoreCase ("JobStatusChange"))
StatusFileProcessLineJobStatusChange (statusStr);
else if (fieldName.EqualIgnoreCase ("NextJobId"))
nextJobId = statusStr.ExtractTokenInt ("\t");
else if (fieldName.EqualIgnoreCase ("QuitRunning"))
quitRunning = true;
else if (fieldName.EqualIgnoreCase ("Restart"))
restart = false;
else if (fieldName.EqualIgnoreCase ("Status"))
status = KKJob::JobStatusFromStr (statusStr);
else
{
log.Level (-1) << "KKJobManager::StatusFileProcessLine Invalid Field Name[" << fieldName << "]." << endl;
}
} /* StatusFileProcessLine */
示例14: ProcessStatusStr
void RandomSampleJob::ProcessStatusStr (KKStr statusStr)
{
log.Level (30) << "RandomSampleJob::ProcessStatusStr[" << statusStr << "]" << endl;
KKStr fieldName;
KKStr fieldValue;
compMethod = BRNull;
fieldName = statusStr.ExtractToken ("\t\n\r");
while (!fieldName.Empty ())
{
fieldName.Upper ();
fieldValue = statusStr.ExtractToken ("\t\n\r");
fieldValue.TrimLeft ("\n\r\t ");
fieldValue.TrimRight ("\n\r\t ");
if (fieldName == "JOBID")
jobId = atoi (fieldValue.Str ());
else if (fieldName == "STATUS")
status = JobStatusFromStr (fieldValue);
else if (fieldName == "KERNEL")
kernelType = KernalTypeFromStr (fieldValue);
else if (fieldName == "ENCODING")
encodingMethod = EncodingMethodFromStr (fieldValue);
else if (fieldName == "COMPMETHOD")
compMethod = CompressionMethodFromStr (fieldValue);
else if (fieldName == "C_PARAM")
c = atoi (fieldValue.Str ());
else if (fieldName == "GAMMA")
gamma = atof (fieldValue.Str ());
else if (fieldName == "ORDERINGNUM")
orderingNum = atoi (fieldValue.Str ());
else if (fieldName == "EXAMPLESTOKEEP")
numExamplesToKeep = atoi (fieldValue.Str ());
else if (fieldName == "ACCURACY")
accuracy = (float)atof (fieldValue.Str ());
else if (fieldName == "TRAINTIME")
{
trainTime = atof (fieldValue.Str ());
}
else if (fieldName == "PREDTIME")
testTime = (float)atof (fieldValue.Str ());
else if (fieldName == "SUPPORTVECTORS")
supportVectors = (float)atof (fieldValue.Str ());
else
{
log.Level (-1) << "RandomSampleJob::ProcessStatusStr Invalid Field Name[" << fieldName << "]." << endl;
}
fieldName = statusStr.ExtractToken ("\t\n\r");
}
} /* ProcessStatusStr */
示例15: ReadSimpleConfusionMatrix
void ClassificationBiasMatrix::ReadSimpleConfusionMatrix (istream& sr,
MLClassListPtr fileClasses
)
{
// 'classes' - The class order that the owner of this object is expecting.
// 'fileClasses' - The order that the classes are stored in the text file.
if ((classes == NULL) || (fileClasses == NULL))
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** The 'Classes' line was never provided.";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
kkint32 classesColIdx = 0;
char buff[10240];
KKStr l;
while (!sr.eof ())
{
sr.getline (buff, sizeof (buff));
l = buff;
l.TrimLeft ();
l.TrimRight ();
if (l.CompareIgnoreCase ("</SimpleConfusionMatrix>") == 0)
break;
KKStr lineName = l.ExtractToken2 ("\t");
if (lineName.CompareIgnoreCase ("DataRow") == 0)
{
if (fileClasses == NULL)
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** 'Classes' was not provided before 'DataRow'.";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
KKStr className = l.ExtractToken2 ("\t");
KKStr data = l.ExtractToken2 ("\t");
MLClassPtr pc = MLClass::CreateNewMLClass (className);
kkint32 classesIdx = classes->PtrToIdx (pc);
kkint32 fileClassesIdx = fileClasses->PtrToIdx (pc);
if (classesIdx < 0)
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** DataRow specifies class[" + className + "] which is not defined by caller";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
if (fileClassesIdx < 0)
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** DataRow specifies class[" + className + "] was not defined in 'Classes' line.";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
kkint32 classesRowIdx = classesIdx;
VectorKKStr dataFields = data.Split (',');
if (dataFields.size () != (kkuint32)numClasses)
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** DataRow Class[" + className + "] number[" + StrFormatInt ((kkint32)dataFields.size (), "ZZZ0") + "] of values provided does not match number of Classes.";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
for (kkint32 c = 0; c < numClasses; c++)
{
pc = fileClasses->IdxToPtr (c);
classesColIdx = classes->PtrToIdx (pc);
VectorKKStr parts = dataFields[c].Split (':');
if (parts.size () > 1)
{
(*counts) [classesRowIdx][classesColIdx] = parts[0].ToDouble ();
(*probabilities)[classesRowIdx][classesColIdx] = parts[1].ToDouble ();
}
}
}
}
} /* ReadSimpleConfusionMatrix */