| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "CReasonerEvaluationCollector.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Test { |
| 27 |
|
| 28 |
namespace Evaluation { |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
CReasonerEvaluationCollector::CReasonerEvaluationCollector(CReasonerEvaluationExtractor* extractor, CReasonerEvaluationSummarizer* summarizer, CReasonerEvaluationFiltering* filtering) : CLogIdentifier("::Konclude::Test::Evaluation::Collector",this) { |
| 33 |
mExtractor = extractor; |
| 34 |
mSummarizer = summarizer; |
| 35 |
mFiltering = filtering; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
CReasonerEvaluationCollector::~CReasonerEvaluationCollector() { |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
bool CReasonerEvaluationCollector::collectReasonerEvaluationDataValues(CReasonerEvaluationDataValueGroupCollectionReasonerComparison *reasonerComp, const QString& reasonerName, const QString& reasonerPath) { |
| 44 |
CReasonerEvaluationDataValueGroupCollection* valueGroupCollection = collectEvaluationDataValues(reasonerPath); |
| 45 |
reasonerComp->addReasonerCollection(reasonerName,valueGroupCollection); |
| 46 |
return true; |
| 47 |
} |
| 48 |
|
| 49 |
CReasonerEvaluationDataValueGroupCollection* CReasonerEvaluationCollector::collectEvaluationDataValues(const QString& baseDirectory) { |
| 50 |
CReasonerEvaluationDataValueGroupCollection* groupCollection = new CReasonerEvaluationDataValueGroupCollection(); |
| 51 |
collectEvaluationDatas(baseDirectory,"",baseDirectory,groupCollection); |
| 52 |
return groupCollection; |
| 53 |
} |
| 54 |
|
| 55 |
bool CReasonerEvaluationCollector::collectEvaluationDatas(const QString& directory, const QString& subDirectory, const QString& baseDirectory, CReasonerEvaluationDataValueGroupCollection* groupCollection) { |
| 56 |
QDir dir(directory); |
| 57 |
CReasonerEvaluationDataValueGroup* group = new CReasonerEvaluationDataValueGroup(); |
| 58 |
QStringList dirList = dir.entryList(QDir::Dirs,QDir::Name|QDir::IgnoreCase); |
| 59 |
foreach (QString dirString, dirList) { |
| 60 |
if (dirString != "." && dirString != "..") { |
| 61 |
QStringList statisticList; |
| 62 |
if (mFiltering) { |
| 63 |
statisticList = mFiltering->loadStatistics(dirString,subDirectory); |
| 64 |
} |
| 65 |
if (!mFiltering || mFiltering->testSatisfiesFilter(dirString,baseDirectory,subDirectory,statisticList)) { |
| 66 |
LOG(INFO,getLogDomain(),logTr("Extracting data for '%1'.").arg(dirString),this); |
| 67 |
collectGroupEvaluationDatas(directory+dirString+"/",dirString,group); |
| 68 |
} else { |
| 69 |
LOG(INFO,getLogDomain(),logTr("Data extracting for '%1' filtered out.").arg(dirString),this); |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
if (!group->isEmpty()) { |
| 74 |
QString groupName = directory; |
| 75 |
groupName.remove(0,baseDirectory.length()); |
| 76 |
group->setGroupName(groupName); |
| 77 |
groupCollection->addNameGroupEvaluationData(groupName,group); |
| 78 |
} else { |
| 79 |
delete group; |
| 80 |
} |
| 81 |
foreach (QString dirString, dirList) { |
| 82 |
if (dirString != "." && dirString != "..") { |
| 83 |
collectEvaluationDatas(directory+dirString+"/",subDirectory+dirString+"/",baseDirectory,groupCollection); |
| 84 |
} |
| 85 |
} |
| 86 |
return true; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
bool CReasonerEvaluationCollector::collectGroupEvaluationDatas(const QString& directory, const QString& requestFileString, CReasonerEvaluationDataValueGroup* group) { |
| 91 |
QDir dir(directory); |
| 92 |
QStringList fileList = dir.entryList(QDir::Files,QDir::Name|QDir::IgnoreCase); |
| 93 |
CReasonerEvaluationDataValue* extractedEvalDataValue = nullptr; |
| 94 |
foreach (QString fileString, fileList) { |
| 95 |
QString totalFileString = directory+fileString; |
| 96 |
CReasonerEvaluationDataValue* tmpEvalDataValue = mExtractor->extractEvaluationData(totalFileString); |
| 97 |
if (tmpEvalDataValue) { |
| 98 |
extractedEvalDataValue = tmpEvalDataValue->append(extractedEvalDataValue); |
| 99 |
} |
| 100 |
} |
| 101 |
CReasonerEvaluationDataValue* evalDataValue = nullptr; |
| 102 |
if (extractedEvalDataValue) { |
| 103 |
evalDataValue = mSummarizer->summarizeEvaluationData(extractedEvalDataValue); |
| 104 |
} |
| 105 |
if (evalDataValue) { |
| 106 |
group->addRequestDataValue(requestFileString,evalDataValue); |
| 107 |
return true; |
| 108 |
} |
| 109 |
return false; |
| 110 |
} |
| 111 |
|
| 112 |
}; // end namespace Evaluation |
| 113 |
|
| 114 |
}; // end namespace Test |
| 115 |
|
| 116 |
}; // end namespace Konclude |