Debian Codegraph @

Source/Reasoner/Preprocess/COntologyQueryExtendedConfigDependedPreProcesser.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 "COntologyQueryExtendedConfigDependedPreProcesser.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Preprocess {
29
30
31 COntologyQueryExtendedConfigDependedPreProcesser::COntologyQueryExtendedConfigDependedPreProcesser()
32 : CLogIdentifier("::Konclude::Preprocess::QueryExtensionPreprocessor",this) {
33
34 mNegNorm = nullptr;
35 mSubRoleNorm = nullptr;
36 mDatatypeNorm = nullptr;
37 mDataLitNorm = nullptr;
38 mTriggImplNorm = nullptr;
39 mRoleChainAutomataTran = nullptr;
40 mBraTrigTran = nullptr;
41 mLegNorm = nullptr;
42 mCommDisConExt = nullptr;
43 mSortDisjPre = nullptr;
44 mDataExtender = nullptr;
45 mBranchStatExtener = nullptr;
46 }
47
48 COntologyQueryExtendedConfigDependedPreProcesser::~COntologyQueryExtendedConfigDependedPreProcesser() {
49 delete mNegNorm;
50 delete mSubRoleNorm;
51 delete mDatatypeNorm;
52 delete mDataLitNorm;
53 delete mTriggImplNorm;
54 delete mRoleChainAutomataTran;
55 delete mLegNorm;
56 delete mBraTrigTran;
57 delete mCommDisConExt;
58 delete mSortDisjPre;
59 delete mDataExtender;
60 delete mBranchStatExtener;
61 }
62
63
64 COntologyQueryExtendedConfigDependedPreProcesser* COntologyQueryExtendedConfigDependedPreProcesser::reportLog(const QString& string) {
65 LOG(INFO,getLogDomain(),string,this);
66 return this;
67 }
68
69
70 CConcreteOntology *COntologyQueryExtendedConfigDependedPreProcesser::preprocess(CConcreteOntology *ontology, CConfiguration *config) {
71
72 CPreProcessContextBase preprocessingContext(ontology,config);
73
74 bool writeDebugginData = CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config);
75
76 if (writeDebugginData && CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config,"Konclude.Debugging.WritePreprocessingDebuggingData.BuildedTBox",false)) {
77 COntologyTextFormater::writeOntologyToFile(ontology, CConfigDebugDataReader::readConfigDebuggingWritingFileString(config, "Konclude.Debugging.WritingPath.Preprocessing.BuildedTBox", "Konclude.Debugging.QueryPreprocessingBaseWritingPathExtension"));
78 }
79
80
81 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing",true)) {
82
83 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.NegationNormalization",true)) {
84 reportLog("Starting negation transformation preprocessing.");
85 if (!mNegNorm) {
86 mNegNorm = new CNegationTransformationPreProcess();
87 mNegNorm->preprocess(ontology, &preprocessingContext);
88 } else {
89 mNegNorm->continuePreprocessing();
90 }
91 reportLog("Stopped negation transformation preprocessing.");
92 }
93 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.SubroleTransformation",true)) {
94 reportLog("Starting subrole transformation preprocessing.");
95 if (!mSubRoleNorm) {
96 mSubRoleNorm = new CSubroleTransformationPreProcess();
97 mSubRoleNorm->preprocess(ontology, &preprocessingContext);
98 } else {
99 mSubRoleNorm->continuePreprocessing();
100 }
101 reportLog("Stopped subrole transformation preprocessing.");
102 }
103 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.DatatypeNormalizer",true)) {
104 reportLog("Starting datatype normalization preprocessing.");
105 if (!mDatatypeNorm) {
106 mDatatypeNorm = new CDatatypeNormalizerPreProcess();
107 mDatatypeNorm->preprocess(ontology, &preprocessingContext);
108 } else {
109 mDatatypeNorm->continuePreprocessing();
110 }
111 reportLog("Stopped datatype normalization preprocessing.");
112 }
113 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.DataLiteralValueNormalizer",true)) {
114 reportLog("Starting data literal values normalization preprocessing.");
115 if (!mDataLitNorm) {
116 mDataLitNorm = new CDataLiteralNormalizerPreProcess();
117 mDataLitNorm->preprocess(ontology, &preprocessingContext);
118 } else {
119 mDataLitNorm->continuePreprocessing();
120 }
121 reportLog("Stopped data literal values normalization preprocessing.");
122 }
123
124 if (writeDebugginData && CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config, "Konclude.Debugging.WritePreprocessingDebuggingData.NormalizedTBox", false)) {
125 COntologyTextFormater::writeOntologyToFile(ontology, CConfigDebugDataReader::readConfigDebuggingWritingFileString(config, "Konclude.Debugging.WritingPath.Preprocessing.NormalizedTBox", "Konclude.Debugging.QueryPreprocessingBaseWritingPathExtension"));
126 }
127
128
129 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.GCIAbsorption.TriggeredImplicationBinaryGCIAbsorption",true)) {
130 reportLog("Starting triggered implication binary GCI absorption preprocessing.");
131 if (!mTriggImplNorm) {
132 mTriggImplNorm = new CTriggeredImplicationBinaryAbsorberPreProcess();
133 mTriggImplNorm->preprocess(ontology, &preprocessingContext);
134 } else {
135 mTriggImplNorm->continuePreprocessing();
136 }
137 reportLog("Stopped triggered implication binary GCI absorption preprocessing.");
138 }
139
140 if (writeDebugginData && CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config, "Konclude.Debugging.WritePreprocessingDebuggingData.AbsorbedTBox", false)) {
141 COntologyTextFormater::writeOntologyToFile(ontology, CConfigDebugDataReader::readConfigDebuggingWritingFileString(config, "Konclude.Debugging.WritingPath.Preprocessing.AbsorbedTBox", "Konclude.Debugging.QueryPreprocessingBaseWritingPathExtension"));
142 }
143
144 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.RoleChainAutomataTransformation",true)) {
145 reportLog("Starting role chain automata transformation preprocessing.");
146 if (!mRoleChainAutomataTran) {
147 mRoleChainAutomataTran = new CRoleChainAutomataTransformationPreProcess();
148 mRoleChainAutomataTran->preprocess(ontology, &preprocessingContext);
149 } else {
150 mRoleChainAutomataTran->continuePreprocessing();
151 }
152 reportLog("Stopped role chain automata transformation preprocessing.");
153 }
154
155
156
157 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.LexicalNormalization",true)) {
158 reportLog("Starting lexical normalization preprocessing.");
159 if (!mLegNorm) {
160 mLegNorm = new CLexicalNormalisationPreProcess();
161 mLegNorm->preprocess(ontology, &preprocessingContext);
162 } else {
163 mLegNorm->continuePreprocessing();
164 }
165 reportLog("Stopped lexical normalization preprocessing.");
166 }
167
168 if (CConfigDataReader::readConfigBoolean(config, "Konclude.Calculation.Preprocessing.BranchTriggerExtraction", true)) {
169 reportLog("Starting branch trigger generation preprocessing.");
170 if (!mBraTrigTran) {
171 mBraTrigTran = new CBranchTriggerPreProcess();
172 mBraTrigTran->preprocess(ontology, &preprocessingContext);
173 }
174 else {
175 mBraTrigTran->continuePreprocessing();
176 }
177 reportLog("Stopped branch trigger generation preprocessing.");
178 }
179 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.CommonDisjunctConceptExtraction",true)) {
180 reportLog("Starting common disjunct concept extraction preprocessing.");
181 if (!mCommDisConExt) {
182 mCommDisConExt = new CCommonDisjunctConceptExtractionPreProcess();
183 mCommDisConExt->preprocess(ontology, &preprocessingContext);
184 } else {
185 mCommDisConExt->continuePreprocessing();
186 }
187 reportLog("Stopped common disjunct concept extraction preprocessing.");
188 }
189 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.DisjunctSorting",true)) {
190 reportLog("Starting disjunct sorting preprocessing.");
191 if (!mSortDisjPre) {
192 mSortDisjPre = new CDisjunctSortingPreProcess();
193 mSortDisjPre->preprocess(ontology, &preprocessingContext);
194 } else {
195 mSortDisjPre->continuePreprocessing();
196 }
197 reportLog("Stopped disjunct sorting preprocessing.");
198 }
199
200 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.ProcessingDataExtender",true)) {
201 reportLog("Starting processing data extender preprocessing.");
202 if (!mDataExtender) {
203 mDataExtender = new CDataExtenderPreProcess();
204 mDataExtender->preprocess(ontology, &preprocessingContext);
205 } else {
206 mDataExtender->continuePreprocessing();
207 }
208 reportLog("Stopped processing data extender preprocessing.");
209 }
210 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.BranchingStatisticsExtender",true)) {
211 reportLog("Starting processing branching statistics extender preprocessing.");
212 if (!mBranchStatExtener) {
213 mBranchStatExtener = new CBranchStatisticsExtenderPreProcess();
214 mBranchStatExtener->preprocess(ontology, &preprocessingContext);
215 } else {
216 mBranchStatExtener->continuePreprocessing();
217 }
218 reportLog("Stopped processing branching statistics extender preprocessing.");
219 }
220
221
222
223
224 if (writeDebugginData && CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config, "Konclude.Debugging.WritePreprocessingDebuggingData.ProcessedTBox", false)) {
225 COntologyTextFormater::writeOntologyToFile(ontology, CConfigDebugDataReader::readConfigDebuggingWritingFileString(config, "Konclude.Debugging.WritingPath.Preprocessing.ProcessedTBox", "Konclude.Debugging.QueryPreprocessingBaseWritingPathExtension"));
226 }
227
228
229
230 }
231
232
233 return ontology;
234 }
235
236
237 }; // end namespace Preprocess
238
239 }; // end namespace Reasoner
240
241 }; // end namespace Konclude