Debian Codegraph @

Source/Reasoner/Preprocess/COntologyConfigDependedPreProcesser.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 "COntologyConfigDependedPreProcesser.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Preprocess {
29
30
31 COntologyConfigDependedPreProcesser::COntologyConfigDependedPreProcesser(CCommandRecordRouter &commandRecRouter)
32 : CLogIdentifier("::Konclude::Preprocess::Preprocessor",this) {
33
34 commandRecordRouter = new CCommandRecordRouter(commandRecRouter,this);
35 }
36
37 COntologyConfigDependedPreProcesser::COntologyConfigDependedPreProcesser()
38 : CLogIdentifier("::Konclude::Preprocess::Preprocessor",this) {
39
40 commandRecordRouter = nullptr;
41 }
42
43 COntologyConfigDependedPreProcesser::~COntologyConfigDependedPreProcesser() {
44 delete commandRecordRouter;
45 }
46
47
48 COntologyConfigDependedPreProcesser* COntologyConfigDependedPreProcesser::reportLog(const QString& string) {
49 if (commandRecordRouter) {
50 CUnspecifiedMessageInformationRecord::makeRecord(string,commandRecordRouter);
51 } else {
52 LOG(INFO,getLogDomain(),string,this);
53 }
54 return this;
55 }
56
57
58 CConcreteOntology *COntologyConfigDependedPreProcesser::preprocess(CConcreteOntology *ontology, CConfiguration *config) {
59
60 CPreProcessContextBase preprocessingContext(ontology,config);
61
62 bool writeDebugginData = CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config);
63
64 if (writeDebugginData && CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config,"Konclude.Debugging.WritePreprocessingDebuggingData.BuildedTBox",false)) {
65 COntologyTextFormater::writeOntologyToFile(ontology, CConfigDebugDataReader::readConfigDebuggingWritingFileString(config, "Konclude.Debugging.WritingPath.Preprocessing.BuildedTBox"));
66 }
67
68
69 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing",true)) {
70
71 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.NegationNormalization",true)) {
72 COntologyPreProcess *negNorm = new CNegationTransformationPreProcess();
73 reportLog("Starting negation transformation preprocessing.");
74 negNorm->preprocess(ontology,&preprocessingContext);
75 reportLog("Stopped negation transformation preprocessing.");
76 delete negNorm;
77 }
78 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.SubroleTransformation",true)) {
79 COntologyPreProcess *subRoleNorm = new CSubroleTransformationPreProcess();
80 reportLog("Starting subrole transformation preprocessing.");
81 subRoleNorm->preprocess(ontology,&preprocessingContext);
82 reportLog("Stopped subrole transformation preprocessing.");
83 delete subRoleNorm;
84 }
85 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.DatatypeNormalizer",true)) {
86 COntologyPreProcess* datatypeNorm = new CDatatypeNormalizerPreProcess();
87 reportLog("Starting datatype normalization preprocessing.");
88 datatypeNorm->preprocess(ontology,&preprocessingContext);
89 reportLog("Stopped datatype normalization preprocessing.");
90 delete datatypeNorm;
91 }
92 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.DataLiteralValueNormalizer",true)) {
93 COntologyPreProcess* dataLitNorm = new CDataLiteralNormalizerPreProcess();
94 reportLog("Starting data literal values normalization preprocessing.");
95 dataLitNorm->preprocess(ontology,&preprocessingContext);
96 reportLog("Stopped data literal values normalization preprocessing.");
97 delete dataLitNorm;
98 }
99
100 if (writeDebugginData && CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config, "Konclude.Debugging.WritePreprocessingDebuggingData.NormalizedTBox", false)) {
101 COntologyTextFormater::writeOntologyToFile(ontology, CConfigDebugDataReader::readConfigDebuggingWritingFileString(config, "Konclude.Debugging.WritingPath.Preprocessing.NormalizedTBox"));
102 }
103
104
105 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.NominalSchemaTemplateExtraction",true)) {
106 COntologyPreProcess *onPreProc = new CNominalSchemaTemplateExtractionPreProcess();
107 reportLog("Starting nominal schema template extraction preprocessing.");
108 onPreProc->preprocess(ontology,&preprocessingContext);
109 reportLog("Stopped nominal schema template extraction preprocessing.");
110 delete onPreProc;
111 }
112 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.NominalSchemaGrounding",true)) {
113 COntologyPreProcess *onPreProc = new CFullNominalSchemaGroundingPreProcess();
114 reportLog("Starting full nominal schema grounding preprocessing.");
115 onPreProc->preprocess(ontology,&preprocessingContext);
116 reportLog("Stopped full nominal schema grounding preprocessing.");
117 delete onPreProc;
118 }
119
120 if (writeDebugginData && CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config, "Konclude.Debugging.WritePreprocessingDebuggingData.GroundedTBox", false)) {
121 COntologyTextFormater::writeOntologyToFile(ontology, CConfigDebugDataReader::readConfigDebuggingWritingFileString(config, "Konclude.Debugging.WritingPath.Preprocessing.GroundedTBox"));
122 }
123
124 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.GCIAbsorption.TriggeredImplicationBinaryGCIAbsorption",true)) {
125 COntologyPreProcess *triggImplNorm = new CTriggeredImplicationBinaryAbsorberPreProcess();
126 reportLog("Starting triggered implication binary GCI absorption preprocessing.");
127 triggImplNorm->preprocess(ontology,&preprocessingContext);
128 reportLog("Stopped triggered implication binary GCI absorption preprocessing.");
129 delete triggImplNorm;
130 }
131
132 if (writeDebugginData && CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config, "Konclude.Debugging.WritePreprocessingDebuggingData.AbsorbedTBox", false)) {
133 COntologyTextFormater::writeOntologyToFile(ontology, CConfigDebugDataReader::readConfigDebuggingWritingFileString(config, "Konclude.Debugging.WritingPath.Preprocessing.AbsorbedTBox"));
134 }
135
136 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.RoleChainAutomataTransformation",true)) {
137 COntologyPreProcess *onPreProc = new CRoleChainAutomataTransformationPreProcess();
138 reportLog("Starting role chain automata transformation preprocessing.");
139 onPreProc->preprocess(ontology,&preprocessingContext);
140 reportLog("Stopped role chain automata transformation preprocessing.");
141 delete onPreProc;
142 }
143
144
145
146 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.LexicalNormalization",true)) {
147 COntologyPreProcess *legNorm = new CLexicalNormalisationPreProcess();
148 reportLog("Starting lexical normalization preprocessing.");
149 legNorm->preprocess(ontology,&preprocessingContext);
150 reportLog("Stopped lexical normalization preprocessing.");
151 delete legNorm;
152 }
153
154 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.BranchTriggerExtraction",true)) {
155 COntologyPreProcess *braTrigTran = new CBranchTriggerPreProcess();
156 reportLog("Starting branch trigger generation preprocessing.");
157 braTrigTran->preprocess(ontology,&preprocessingContext);
158 reportLog("Stopped branch trigger generation preprocessing.");
159 delete braTrigTran;
160 }
161 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.CommonDisjunctConceptExtraction",true)) {
162 COntologyPreProcess *commDisConExt = new CCommonDisjunctConceptExtractionPreProcess();
163 reportLog("Starting common disjunct concept extraction preprocessing.");
164 commDisConExt->preprocess(ontology,&preprocessingContext);
165 reportLog("Stopped common disjunct concept extraction preprocessing.");
166 delete commDisConExt;
167 }
168 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.DisjunctSorting",true)) {
169 COntologyPreProcess *sortDisjPre = new CDisjunctSortingPreProcess();
170 reportLog("Starting disjunct sorting preprocessing.");
171 sortDisjPre->preprocess(ontology,&preprocessingContext);
172 reportLog("Stopped disjunct sorting preprocessing.");
173 delete sortDisjPre;
174 }
175
176 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.OntologyAssignmentTransformation",true)) {
177 COntologyPreProcess *ontAssignNorm = new COntologyAssignmentTransformationPreProcess(ontology);
178 reportLog("Starting ontology revision assignment preprocessing.");
179 ontAssignNorm->preprocess(ontology,&preprocessingContext);
180 reportLog("Stopped ontology revision assignment preprocessing.");
181 delete ontAssignNorm;
182 }
183 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.OntologyMappingUpdate",true)) {
184 COntologyPreProcess *onPreProc = new CMappingUpdaterPreProcess();
185 reportLog("Starting ontology mapping update preprocessing.");
186 onPreProc->preprocess(ontology,&preprocessingContext);
187 reportLog("Stopped ontology mapping update preprocessing.");
188 delete onPreProc;
189 }
190 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.ProcessingDataExtender",true)) {
191 COntologyPreProcess *onPreProc = new CDataExtenderPreProcess();
192 reportLog("Starting processing data extender preprocessing.");
193 onPreProc->preprocess(ontology,&preprocessingContext);
194 reportLog("Stopped processing data extender preprocessing.");
195 delete onPreProc;
196 }
197 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.BranchingStatisticsExtender",true)) {
198 COntologyPreProcess *onPreProc = new CBranchStatisticsExtenderPreProcess();
199 reportLog("Starting processing branching statistics extender preprocessing.");
200 onPreProc->preprocess(ontology,&preprocessingContext);
201 reportLog("Stopped processing branching statistics extender preprocessing.");
202 delete onPreProc;
203 }
204
205 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.ReverseRoleAssertionGeneration",true)) {
206 COntologyPreProcess *onPreProc = new CReverseRoleAssertionGeneratorPreProcess();
207 reportLog("Starting reverse role assertion generation.");
208 onPreProc->preprocess(ontology,&preprocessingContext);
209 reportLog("Stopped reverse role assertion generation.");
210 delete onPreProc;
211 }
212
213 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.OntologyStructureInspection",true)) {
214 COntologyPreProcess *onPreProc = new COntologyStructureInspectionPreProcess();
215 reportLog("Starting ontology structure inspection preprocessing.");
216 onPreProc->preprocess(ontology,&preprocessingContext);
217 reportLog("Stopped ontology structure inspection preprocessing.");
218 delete onPreProc;
219 }
220 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.ExtractPropagationIntoCreationDirection",true)) {
221 COntologyPreProcess *onPreProc = new CExtractPropagationIntoCreationDirectionPreProcess();
222 reportLog("Starting extraction for propagations into creation direction preprocessing.");
223 onPreProc->preprocess(ontology,&preprocessingContext);
224 reportLog("Stopped extraction for propagations into creation direction preprocessing.");
225 delete onPreProc;
226 }
227 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.CoreBlockingConceptMarking",true)) {
228 COntologyPreProcess *onPreProc = new CCoreBlockingConceptMarkerPreProcess();
229 reportLog("Starting marking core blocking concept preprocessing.");
230 onPreProc->preprocess(ontology,&preprocessingContext);
231 reportLog("Stopped marking core blocking concept preprocessing.");
232 delete onPreProc;
233 }
234 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.RelevantConceptRoleMarker",false)) {
235 COntologyPreProcess *onPreProc = new CExtractRelevantConceptRolePreProcess();
236 reportLog("Starting marking relevant concepts and roles preprocessing.");
237 onPreProc->preprocess(ontology,&preprocessingContext);
238 reportLog("Stopped marking relevant concepts and roles preprocessing.");
239 delete onPreProc;
240 }
241 if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Preprocessing.CoreConceptCyclesExtraction",true)) {
242 COntologyPreProcess *onPreProc = new CCoreOntologyCyclesExtractorPreProcess();
243 reportLog("Starting extracting core concept cycles preprocessing.");
244 onPreProc->preprocess(ontology,&preprocessingContext);
245 reportLog("Stopped extracting core concept cycles preprocessing.");
246 delete onPreProc;
247 }
248
249
250
251 if (writeDebugginData && CConfigDebugDataReader::readConfigDebugWritingPreprocessingEnabled(config, "Konclude.Debugging.WritePreprocessingDebuggingData.ProcessedTBox", false)) {
252 COntologyTextFormater::writeOntologyToFile(ontology, CConfigDebugDataReader::readConfigDebuggingWritingFileString(config, "Konclude.Debugging.WritingPath.Preprocessing.ProcessedTBox"));
253 }
254
255
256
257 }
258
259
260 return ontology;
261 }
262
263
264 }; // end namespace Preprocess
265
266 }; // end namespace Reasoner
267
268 }; // end namespace Konclude