Debian Codegraph @

Source/Reasoner/Classifier/COntologyClassClassificationItem.cpp

raw
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 "COntologyClassClassificationItem.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Classifier {
29
30
31 COntologyClassClassificationItem::COntologyClassClassificationItem(CConfigurationBase *configuration, CClassifierStatistics *nextClassificationStatistics) : COntologyClassificationItem(configuration,nextClassificationStatistics) {
32
33 mTaxonomyConstructed = false;
34 mTaxonomyConstructionFailed = false;
35
36 mPrecSatSubsumerExtractor = nullptr;
37
38 }
39
40
41 COntologyClassClassificationItem::~COntologyClassClassificationItem() {
42 delete mPrecSatSubsumerExtractor;
43 }
44
45
46 CPrecomputedSaturationSubsumerExtractor* COntologyClassClassificationItem::getPrecomputedSaturationSubsumerExtractor(bool create) {
47 if (!mPrecSatSubsumerExtractor && create) {
48 mPrecSatSubsumerExtractor = new CPrecomputedSaturationSubsumerExtractor(onto);
49 }
50 return mPrecSatSubsumerExtractor;
51 }
52
53
54 COntologyClassClassificationItem *COntologyClassClassificationItem::initTaxonomyConcepts(CConcreteOntology *ontology, CTaxonomy *taxonomy) {
55 onto = ontology;
56 tax = taxonomy;
57 CABox *aBox = onto->getABox();
58 CTBox *tBox = onto->getTBox();
59
60 currentCalculatingCount = 0;
61
62 mClassifyProcessingStepData = onto->getProcessingSteps()->getOntologyProcessingStepDataVector()->getProcessingStepData(COntologyProcessingStep::OPSCLASSCLASSIFY);
63 mTaxonomyConstructionFailed = !mClassifyProcessingStepData->getProcessingStep()->areAllRequirementsSatisfied(ontology);
64
65 remainingTests = true;
66
67 CConcept *topConcept = onto->getDataBoxes()->getTopConcept();
68 CConcept *bottomConcept = onto->getDataBoxes()->getBottomConcept();
69
70 cint64 satConCount = 0;
71 CBOXSET<CConcept*> *conceptHash = tBox->getActiveClassConceptSet(false);
72 if (conceptHash) {
73 for (CBOXSET<CConcept*>::const_iterator it = conceptHash->constBegin(), itEnd = conceptHash->constEnd(); it != itEnd; ++it) {
74 CConcept *concept = (*it);
75 if (concept && concept != topConcept && concept != bottomConcept) {
76 // concept which has to be inserted in the taxonomy
77 ++satConCount;
78 }
79 }
80 }
81
82 statistics->incTotalSatisfiableTestCount(satConCount);
83
84 return this;
85 }
86
87
88 CTaxonomy *COntologyClassClassificationItem::getTaxonomy() {
89 return tax;
90 }
91
92 CTBox *COntologyClassClassificationItem::getTBox() {
93 return onto->getTBox();
94 }
95
96
97 QHash<CSatisfiableCalculationJob *, CClassClassificationComputationItem *> * COntologyClassClassificationItem::getWorkItemHash()
98 {
99 return &workItemHash;
100 }
101
102
103 CClassConceptClassification* COntologyClassClassificationItem::getClassConceptClassification() {
104 return this;
105 }
106
107
108
109 bool COntologyClassClassificationItem::isTaxonomyConstructed() {
110 return mTaxonomyConstructed;
111 }
112
113 COntologyClassClassificationItem* COntologyClassClassificationItem::setTaxonomyConstructionFailed() {
114 mTaxonomyConstructionFailed = true;
115 return this;
116 }
117
118 bool COntologyClassClassificationItem::isTaxonomyConstructionFailed() {
119 return mTaxonomyConstructionFailed;
120 }
121
122 COntologyClassClassificationItem* COntologyClassClassificationItem::submitTaxonomyConstructed() {
123 mTaxonomyConstructed = true;
124 mClassifyProcessingStepData->getProcessingStatus()->setProcessingFlags(COntologyProcessingStatus::PSCOMPLETELYYPROCESSED);
125 cint64 errorFlags = COntologyProcessingStatus::PSSUCESSFULL;
126 if (mTaxonomyConstructionFailed) {
127 errorFlags = COntologyProcessingStatus::PSFAILED;
128 }
129 mClassifyProcessingStepData->getProcessingStatus()->setErrorFlags(errorFlags);
130 for (QList<COntologyProcessingRequirement*>::const_iterator it = mRequirementList.constBegin(), itEnd = mRequirementList.constEnd(); it != itEnd; ++it) {
131 COntologyProcessingRequirement* ontReq(*it);
132 ontReq->submitRequirementUpdate(COntologyProcessingStatus::PSCOMPLETELYYPROCESSED,errorFlags);
133 }
134 return this;
135 }
136
137
138 }; // end namespace Classifier
139
140 }; // end namespace Reasoner
141
142 }; // end namespace Konclude