| 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 "CCoreBlockingConceptMarkerPreProcess.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Preprocess { |
| 29 |
|
| 30 |
|
| 31 |
CCoreBlockingConceptMarkerPreProcess::CCoreBlockingConceptMarkerPreProcess() { |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
CCoreBlockingConceptMarkerPreProcess::~CCoreBlockingConceptMarkerPreProcess() { |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
CConcreteOntology* CCoreBlockingConceptMarkerPreProcess::preprocess(CConcreteOntology* ontology, CPreProcessContext* context) { |
| 41 |
bool skipForELOntologies = CConfigDataReader::readConfigBoolean(context->getConfiguration(),"Konclude.Calculation.Preprocessing.CoreBlockingConceptMarking.SkipForELFragment",true); |
| 42 |
bool nonELConstructsUsed = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getBuildConstructFlags()->isNonELConstructUsed(); |
| 43 |
|
| 44 |
if (nonELConstructsUsed || !skipForELOntologies) { |
| 45 |
|
| 46 |
CTBox* tbox = ontology->getDataBoxes()->getTBox(); |
| 47 |
CABox* abox = ontology->getDataBoxes()->getABox(); |
| 48 |
CRBox* rbox = ontology->getDataBoxes()->getRBox(); |
| 49 |
|
| 50 |
CConceptVector* conVec = tbox->getConceptVector(); |
| 51 |
qint64 itemConCounts = conVec->getItemCount(); |
| 52 |
|
| 53 |
QSet<TConceptNegPair> visitedConceptSet; |
| 54 |
COntologyContext* ontoContext = ontology->getOntologyContext(); |
| 55 |
CMemoryAllocationManager* mMemMan = ontoContext->getMemoryAllocationManager(); |
| 56 |
COntologyCoreConceptCyclesData* coreConCyclesData = ontology->getCoreConceptCyclesData(); |
| 57 |
|
| 58 |
cint64 statMarkedCoreBlockingConceptsCount = 0; |
| 59 |
|
| 60 |
cint64 nextCycleID = 0; |
| 61 |
|
| 62 |
for (qint64 i = 0; i < itemConCounts; ++i) { |
| 63 |
CConcept* concept = conVec->getLocalData(i); |
| 64 |
if (concept) { |
| 65 |
cint64 opCode = concept->getOperatorCode(); |
| 66 |
if (opCode == CCSOME || opCode == CCALL || opCode == CCATLEAST || opCode == CCAQSOME || opCode == CCATMOST) { |
| 67 |
bool opNegated = opCode == CCALL; |
| 68 |
|
| 69 |
CSortedNegLinker<CConcept*>* opLinkerIt = concept->getOperandList(); |
| 70 |
while (opLinkerIt) { |
| 71 |
|
| 72 |
CConcept* opConcept = concept; |
| 73 |
bool opNegate = opNegated^opLinkerIt->isNegated(); |
| 74 |
CConceptProcessData* conProDes = (CConceptProcessData*)opConcept->getConceptData(); |
| 75 |
|
| 76 |
if (conProDes) { |
| 77 |
bool negated = opNegated^opNegate; |
| 78 |
if (!conProDes->isCoreBlockingConcept(negated)) { |
| 79 |
++statMarkedCoreBlockingConceptsCount; |
| 80 |
conProDes->setCoreBlockingConcept(negated); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
opLinkerIt = opLinkerIt->getNext(); |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
LOG(INFO,"::Konclude::Reasoner::Preprocess::CoreBlockingConceptMarker",logTr("Marked %1 concept as core blocking concepts.").arg(statMarkedCoreBlockingConceptsCount),this); |
| 91 |
} |
| 92 |
return ontology; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
}; // end namespace Preprocess |
| 97 |
|
| 98 |
}; // end namespace Reasoner |
| 99 |
|
| 100 |
}; // end namespace Konclude |