Debian Codegraph @

Source/Reasoner/Preprocess/CExtractRelevantConceptRolePreProcess.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 "CExtractRelevantConceptRolePreProcess.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Preprocess {
29
30
31 CExtractRelevantConceptRolePreProcess::CExtractRelevantConceptRolePreProcess() {
32 }
33
34
35 CExtractRelevantConceptRolePreProcess::~CExtractRelevantConceptRolePreProcess() {
36 }
37
38
39 CConcreteOntology* CExtractRelevantConceptRolePreProcess::preprocess(CConcreteOntology* ontology, CPreProcessContext* context) {
40 bool nonELConstructsUsed = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getBuildConstructFlags()->isNonELConstructUsed();
41
42 if (!nonELConstructsUsed) {
43 CMBox* mBox = ontology->getDataBoxes()->getMBox();
44 CTBox* tBox = ontology->getDataBoxes()->getTBox();
45 CRBox* rBox = ontology->getDataBoxes()->getRBox();
46 CABox* aBox = ontology->getDataBoxes()->getABox();
47
48 CConceptVector* conceptVec = tBox->getConceptVector();
49 cint64 conceptCount = tBox->getConceptCount();
50 CRoleVector* roleVec = rBox->getRoleVector();
51
52 cint64 markedPropagationIntoCreationDirectionConceptCount = 0;
53
54 QHash<CRole*,bool> creationRoleHash;
55 for (cint64 conIdx = 0; conIdx < conceptCount; ++conIdx) {
56 CConcept* concept = conceptVec->getData(conIdx);
57 if (concept) {
58 CConceptOperator* conOperator = concept->getConceptOperator();
59 if (conOperator->hasPartialOperatorCodeFlag(CConceptOperator::CCFS_ALL_AQALL_TYPE)) {
60 CRole* role = concept->getRole();
61 CRoleProcessData* roleData = (CRoleProcessData*)role->getRoleData();
62 if (roleData) {
63 roleData->setInferRelevantFlag(true);
64 }
65 }
66 if (conOperator->hasPartialOperatorCodeFlag(CConceptOperator::CCFS_ABSORPTION_RELEVANT_TYPE)) {
67 CConceptProcessData* conceptData = (CConceptProcessData*)concept->getConceptData();
68 if (conceptData) {
69 conceptData->setInferRelevantFlag(true);
70 }
71 for (CSortedNegLinker<CConcept*>* opLinkerIt = concept->getOperandList(); opLinkerIt; opLinkerIt = opLinkerIt->getNext()) {
72 CConcept* opConcept = opLinkerIt->getData();
73 CConceptProcessData* opConceptData = (CConceptProcessData*)opConcept->getConceptData();
74 if (opConceptData) {
75 opConceptData->setInferRelevantFlag(true);
76 }
77 }
78 }
79 }
80 }
81
82
83 for (cint64 conIdx = 0; conIdx < conceptCount; ++conIdx) {
84 CConcept* concept = conceptVec->getData(conIdx);
85 if (concept) {
86 CConceptOperator* conOperator = concept->getConceptOperator();
87 if (conOperator->hasPartialOperatorCodeFlag(CConceptOperator::CCFS_ALL_AQALL_TYPE | CConceptOperator::CCFS_POSSIBLE_ROLE_CREATION_TYPE)) {
88 CRole* role = concept->getRole();
89 if (creationRoleHash.contains(role)) {
90 CConceptProcessData* conProData = (CConceptProcessData*)concept->getConceptData();
91 if (conProData) {
92 ++markedPropagationIntoCreationDirectionConceptCount;
93 conProData->setPropagationIntoCreationDirection(true);
94 }
95 }
96 }
97 }
98 }
99
100
101 LOG(INFO,"::Konclude::Reasoner::Preprocess::PropagationIntoCreationDirectionExtractor",logTr("Marked %1 concepts with possibly propagation into creation direction.").arg(markedPropagationIntoCreationDirectionConceptCount),this);
102 }
103 return ontology;
104 }
105
106
107
108 }; // end namespace Preprocess
109
110 }; // end namespace Reasoner
111
112 }; // end namespace Konclude