| 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 |
#ifndef KONCLUDE_REASONER_GENERATOR_CCONCRETEONTOLOGYUPDATEBUILDER_H |
| 22 |
#define KONCLUDE_REASONER_GENERATOR_CCONCRETEONTOLOGYUPDATEBUILDER_H |
| 23 |
|
| 24 |
|
| 25 |
// Libraries includes |
| 26 |
#include <QListIterator> |
| 27 |
#include <QHash> |
| 28 |
#include <QString> |
| 29 |
#include <QObject> |
| 30 |
|
| 31 |
// Namespace includes |
| 32 |
#include "CConcreteOntologyBuildDataUpdater.h" |
| 33 |
#include "CExpressionSplitter.h" |
| 34 |
#include "CExpressionHasher.h" |
| 35 |
|
| 36 |
|
| 37 |
// Other includes |
| 38 |
#include "Reasoner/Ontology/CConcreteOntology.h" |
| 39 |
#include "Reasoner/Ontology/CConcept.h" |
| 40 |
#include "Reasoner/Ontology/CTBox.h" |
| 41 |
#include "Reasoner/Ontology/CABox.h" |
| 42 |
#include "Reasoner/Ontology/CRBox.h" |
| 43 |
#include "Reasoner/Ontology/CAbbreviatedIRIName.h" |
| 44 |
#include "Reasoner/Ontology/CIRIName.h" |
| 45 |
|
| 46 |
|
| 47 |
#include "Utilities/CTrible.hpp" |
| 48 |
#include "Utilities/CNegLinker.hpp" |
| 49 |
#include "Utilities/CHashableIntConvertedNTuble.hpp" |
| 50 |
#include "Utilities/CMemoryManager.hpp" |
| 51 |
#include "Utilities/CDynamicExpandingMemoryManager.hpp" |
| 52 |
#include "Utilities/Memory/CObjectAllocator.h" |
| 53 |
|
| 54 |
#include "Parser/COntologyBuilder.h" |
| 55 |
|
| 56 |
// Logger includes |
| 57 |
#include "Logger/CLogger.h" |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
namespace Konclude { |
| 64 |
|
| 65 |
using namespace Utilities; |
| 66 |
using namespace Utilities::Memory; |
| 67 |
using namespace Parser; |
| 68 |
|
| 69 |
namespace Reasoner { |
| 70 |
|
| 71 |
using namespace Ontology; |
| 72 |
|
| 73 |
namespace Generator { |
| 74 |
|
| 75 |
/*! |
| 76 |
* |
| 77 |
* \class CConcreteOntologyUpdateBuilder |
| 78 |
* \author Andreas Steigmiller |
| 79 |
* \version 0.1 |
| 80 |
* \brief TODO |
| 81 |
* |
| 82 |
*/ |
| 83 |
class CConcreteOntologyUpdateBuilder : public CConcreteOntologyBuildDataUpdater { |
| 84 |
// public methods |
| 85 |
public: |
| 86 |
CConcreteOntologyUpdateBuilder(CConcreteOntology* updateConcreteOntology); |
| 87 |
virtual ~CConcreteOntologyUpdateBuilder(); |
| 88 |
|
| 89 |
virtual bool initializeBuilding(); |
| 90 |
virtual bool completeBuilding(); |
| 91 |
|
| 92 |
virtual bool tellOntologyAxiom(CAxiomExpression* axiom); |
| 93 |
virtual bool retractOntologyAxiom(CAxiomExpression* axiom); |
| 94 |
|
| 95 |
|
| 96 |
// protected functions |
| 97 |
protected: |
| 98 |
bool setConceptOperands(CConcept* concept, CConcept* operandConcept, bool negate = false); |
| 99 |
bool setConceptOperandsFromClassTerms(CConcept* concept, CEXPRESSIONLIST<CClassTermExpression*>* classTermList, bool negate = false); |
| 100 |
bool setConceptOperandsFromClassTerms(CConcept* concept, CClassTermExpression* classTermExp, bool negate = false); |
| 101 |
bool setConceptOperandsFromDataRangeTerms(CConcept* concept, CDataRangeTermExpression* dataRangeTermExp, bool negate = false); |
| 102 |
bool setConceptOperandsFromDataRangeTerms(CConcept* concept, CEXPRESSIONLIST<CDataRangeTermExpression*>* dataRangeTermExpList, bool negate = false); |
| 103 |
bool setConceptRoleFromObjectPropertyTerm(CConcept* concept, CObjectPropertyTermExpression* objectPropertyTermExp); |
| 104 |
bool setConceptRoleFromDataPropertyTerm(CConcept* concept, CDataPropertyTermExpression* dataPropertyTermExp); |
| 105 |
bool setConceptIndividualFromIndividualTerm(CConcept* concept, CIndividualTermExpression* indiTermExp); |
| 106 |
bool setConceptNominalIndividualFromIndividualTerm(CConcept* concept, CIndividualTermExpression* indiTermExp); |
| 107 |
bool setIndividualAssertionConceptFromClassTerm(CIndividual* individual, CClassTermExpression* classTermExp, bool negate = false); |
| 108 |
bool setIndividualAssertionNominalFromClassTerm(CIndividual* individual, CClassTermExpression* classTermExp, bool negate = false); |
| 109 |
bool setIndividualAssertionRoleFromObjectPropertyTerm(CIndividual* individual, CObjectPropertyTermExpression* objPropTermExp, CIndividualTermExpression* destIndiTermExp); |
| 110 |
bool setIndividualAssertionDataFromDataLiteralTerm(CIndividual* individual, CDataPropertyTermExpression* dataPropTermExp, CDataLiteralExpression* dataLitExp); |
| 111 |
|
| 112 |
bool buildClassConcept(CClassTermExpression* classTermExp); |
| 113 |
bool buildConceptSubClassInclusion(CClassTermExpression* subClassExp, CClassTermExpression* inclusionClassExp, bool negate = false); |
| 114 |
bool buildConceptEquivalentClass(CClassTermExpression* classExp1, CClassTermExpression* classExp2); |
| 115 |
bool buildPermutableConceptEquivalentClass(CClassTermExpression* classExp1, CClassTermExpression* classExp2); |
| 116 |
bool buildPermutableConceptEquivalentClass(CClassTermExpression* eqCallClassExp, const CEXPRESSIONLIST<CClassTermExpression*>& eqClassExpList); |
| 117 |
bool buildPermutableConceptDisjointClass(CClassTermExpression* disCallClassExp, const CEXPRESSIONLIST<CClassTermExpression*>& disClassExpList); |
| 118 |
bool buildDisjointUnionConceptClass(CClassTermExpression* disCallClassExp, const CEXPRESSIONLIST<CClassTermExpression*>& disClassExpList); |
| 119 |
bool buildGeneralConceptInclusionClassExpression(CClassTermExpression* gciClassTermExp); |
| 120 |
|
| 121 |
bool buildObjectPropertyRole(CObjectPropertyTermExpression* objPropTermExp); |
| 122 |
|
| 123 |
bool buildDataPropertyRole(CDataPropertyTermExpression* dataPropTermExp); |
| 124 |
bool buildDatatype(CDatatypeExpression* datatypeExp); |
| 125 |
|
| 126 |
|
| 127 |
bool buildIndividualIndi(CIndividualTermExpression* indiTermExp); |
| 128 |
|
| 129 |
CRoleChain* buildRoleChainForSubObjectPropertyOfExpression(CSubObjectPropertyOfExpression* subObPropExp); |
| 130 |
CRoleChain* buildRoleChainForTransetiveObjectPropertyExpression(CTransetiveObjectPropertyExpression* objPropAxiomExp); |
| 131 |
|
| 132 |
CConcept* getConceptForClassTerm(CClassTermExpression* classTermExp, bool forceLocalisation = false); |
| 133 |
CRole* getRoleForObjectPropertyTerm(CObjectPropertyTermExpression* objPropTermExp, bool forceLocalisation = false); |
| 134 |
CRole* getRoleForDataPropertyTerm(CDataPropertyTermExpression* dataPropTermExp, bool forceLocalisation = false); |
| 135 |
CIndividual* getIndividualForIndividualTerm(CIndividualTermExpression* indiTermExp, bool forceLocalisation = false); |
| 136 |
|
| 137 |
CConcept* getConceptForDataRangeTerm(CDataRangeTermExpression* dataRangeExp, bool forceLocalisation = false); |
| 138 |
CDatatype* getDatatypeForDatatypeExpression(CDatatypeExpression* datatypeExp, bool forceLocalisation = false); |
| 139 |
CDataLiteral* getDataLiteralForLiteralExpression(CDataLiteralExpression* dataLiteralExp, bool forceLocalisation = false); |
| 140 |
|
| 141 |
bool updateName(CNamedItem* item, const QString& name); |
| 142 |
|
| 143 |
bool resortAndInstallConceptsAndRolesAndIndividuals(); |
| 144 |
CSortedNegLinker<CConcept*>* resortConceptLinkersByTagging(CSortedNegLinker<CConcept*>* conceptLinkers, cint64 linkerCount = -1); |
| 145 |
CSortedNegLinker<CRole*>* resortRoleLinkersByTagging(CSortedNegLinker<CRole*>* roleLinkers); |
| 146 |
|
| 147 |
bool buildConceptTags(); |
| 148 |
bool buildRoleTags(); |
| 149 |
bool buildRoleChainTags(); |
| 150 |
bool buildIndividualIDs(); |
| 151 |
|
| 152 |
cint64 getIndividualVariableID(CConcept* concept, CObjectIndividualVariableExpression* objectIndVarExp); |
| 153 |
|
| 154 |
// protected variables |
| 155 |
protected: |
| 156 |
COntologyDataBoxes* mOntoData; |
| 157 |
|
| 158 |
COntologyBuildConstructFlags* mConstructFlags; |
| 159 |
|
| 160 |
CTBox* tBox; |
| 161 |
CABox* aBox; |
| 162 |
CRBox* rBox; |
| 163 |
|
| 164 |
bool mInitialBuild; |
| 165 |
|
| 166 |
// contains also previous ontology data |
| 167 |
CONTOLOGYAXIOMSET<CAxiomExpression*>* mTellAxiomSet; |
| 168 |
CONTOLOGYAXIOMSET<CAxiomExpression*>* mRetractAxiomSet; |
| 169 |
|
| 170 |
CONTOLOGYAXIOMLIST< QPair<CAxiomExpression*,bool> >* mChangeAxiomList; |
| 171 |
|
| 172 |
// contains only updated data |
| 173 |
CONTOLOGYAXIOMSET<CAxiomExpression*>* mTellUpdatedAxiomSet; |
| 174 |
CONTOLOGYAXIOMSET<CAxiomExpression*>* mRetractUpdatedAxiomSet; |
| 175 |
|
| 176 |
CONTOLOGYAXIOMLIST< QPair<CAxiomExpression*,bool> >* mChangeUpdatedAxiomList; |
| 177 |
|
| 178 |
CBUILDHASH<CClassAxiomExpression*,bool>* mUpdateClassAxiomHash; |
| 179 |
CBUILDHASH<CObjectPropertyAxiomExpression*,bool>* mUpdateObjectPropertyAxiomHash; |
| 180 |
CBUILDHASH<CDataPropertyAxiomExpression*,bool>* mUpdateDataPropertyAxiomHash; |
| 181 |
CBUILDHASH<CAssertionAxiomExpression*,bool>* mUpdateAssertionAxiomHash; |
| 182 |
|
| 183 |
|
| 184 |
// contains also previous ontology data |
| 185 |
CBUILDSET< QPair<CClassTermExpression*,CClassAxiomExpression*> >* mClassTermClassAxiomSet; |
| 186 |
CBUILDHASH<CClassTermExpression*,CClassAxiomExpression*>* mClassTermClassAxiomHash; |
| 187 |
|
| 188 |
|
| 189 |
CBUILDHASH<CDatatypeExpression*,CDatatype*>* mDatatypeExpDatatypeHash; |
| 190 |
CBUILDHASH<CDatatype*,CDatatypeExpression*>* mDatatypeDatatypeExpHash; |
| 191 |
|
| 192 |
|
| 193 |
CBUILDHASH<QPair<CDataLexicalValueExpression*, CDatatype*>, CDataLiteral*>* mLexicalDataExpDatatypePairDataLiteralHash; |
| 194 |
|
| 195 |
|
| 196 |
CBUILDSET< QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*> >* mObjPropTermObjPropAxiomSet; |
| 197 |
CBUILDHASH<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>* mObjPropTermObjPropAxiomHash; |
| 198 |
|
| 199 |
|
| 200 |
CBUILDSET< QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*> >* mDataPropTermDataPropAxiomSet; |
| 201 |
CBUILDHASH<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>* mDataPropTermDataPropAxiomHash; |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
CBUILDSET<CClassTermExpression*>* mTopRebuildClassTermExpressionsSet; |
| 206 |
CBUILDSET<CObjectPropertyTermExpression*>* mTopRebuildObjectPropertyTermExpressionsSet; |
| 207 |
|
| 208 |
CBUILDSET< QPair<CIndividualTermExpression*,CAssertionAxiomExpression*> >* mIndiTermAssertionAxiomSet; |
| 209 |
CBUILDHASH<CIndividualTermExpression*,CAssertionAxiomExpression*>* mIndiTermAssertionAxiomHash; |
| 210 |
|
| 211 |
CBUILDHASH<CClassTermExpression*,CConcept*>* mClassTermConceptHash; |
| 212 |
CBUILDHASH<CConcept*,CClassTermExpression*>* mConceptClassTermHash; |
| 213 |
|
| 214 |
CBUILDHASH<CDataRangeTermExpression*,CConcept*>* mDataRangeTermConceptHash; |
| 215 |
CBUILDHASH<CConcept*,CDataRangeTermExpression*>* mConceptDataRangeTermHash; |
| 216 |
|
| 217 |
CBUILDHASH<CObjectPropertyTermExpression*,CRole*>* mObjPropTermRoleHash; |
| 218 |
CBUILDHASH<CRole*,CObjectPropertyTermExpression*>* mRoleObjPropTermHash; |
| 219 |
CBUILDHASH<CDataPropertyTermExpression*,CRole*>* mDataPropTermRoleHash; |
| 220 |
CBUILDHASH<CRole*,CDataPropertyTermExpression*>* mRoleDataPropTermHash; |
| 221 |
|
| 222 |
|
| 223 |
CBUILDHASH<CObjectPropertyAxiomExpression*,CRoleChain*>* mObjPropTermRoleChainHash; |
| 224 |
CBUILDHASH<CRoleChain*,CObjectPropertyAxiomExpression*>* mRoleChainObjPropTermHash; |
| 225 |
|
| 226 |
CBUILDHASH<CIndividualTermExpression*,CIndividual*>* mIndividulTermIndiHash; |
| 227 |
CBUILDHASH<CIndividual*,CIndividualTermExpression*>* mIndiIndividulTermHash; |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
cint64 mLastProcessedChangedAxiom; |
| 232 |
cint64 mLastProcessedBuildIndividual; |
| 233 |
cint64 mLastProcessedBuildConcept; |
| 234 |
cint64 mLastProcessedBuildObjectRole; |
| 235 |
cint64 mLastProcessedBuildDataRole; |
| 236 |
cint64 mLastProcessedBuildDataRange; |
| 237 |
cint64 mLastProcessedBuildDatatype; |
| 238 |
|
| 239 |
cint64 mLastProcessedInverseProperty; |
| 240 |
cint64 mLastProcessedExpression; |
| 241 |
|
| 242 |
cint64 mLastBuildedIndividual; |
| 243 |
cint64 mLastBuildedConcept; |
| 244 |
cint64 mLastBuildedObjectRole; |
| 245 |
cint64 mLastBuildedDataRole; |
| 246 |
cint64 mLastBuildedDataRange; |
| 247 |
cint64 mLastBuildedDatatype; |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
CBUILDHASH<CObjectPropertyTermExpression*,CObjectPropertyTermExpression*>* mLocInverseObjectPropertyHash; |
| 253 |
CBUILDHASH<CExpressionHasher,CBuildExpression*>* mLocExpressionBuildHash; |
| 254 |
CBUILDLIST<CBuildExpression*>* mLocExpressionBuildContainerList; |
| 255 |
|
| 256 |
|
| 257 |
CBUILDSET<CClassTermExpression*>* mInitialBuildConceptSet; |
| 258 |
|
| 259 |
CBUILDSET<CClassTermExpression*>* mLocBuildConceptSet; |
| 260 |
CBUILDSET<CObjectPropertyTermExpression*>* mLocBuildObjectRoleSet; |
| 261 |
CBUILDSET<CDataPropertyTermExpression*>* mLocBuildDataRoleSet; |
| 262 |
CBUILDSET<CDataRangeTermExpression*>* mLocBuildDataRangeSet; |
| 263 |
CBUILDSET<CDatatypeExpression*>* mLocBuildDatatypeSet; |
| 264 |
CBUILDSET<CIndividualTermExpression*>* mLocBuildIndividualSet; |
| 265 |
|
| 266 |
CBUILDLIST<CIndividualTermExpression*>* mLocBuildIndividualList; |
| 267 |
CBUILDLIST<CObjectPropertyTermExpression*>* mLocBuildObjectRoleList; |
| 268 |
CBUILDLIST<CDataPropertyTermExpression*>* mLocBuildDataRoleList; |
| 269 |
CBUILDLIST<CDataRangeTermExpression*>* mLocBuildDataRangeList; |
| 270 |
CBUILDLIST<CDatatypeExpression*>* mLocBuildDatatypeList; |
| 271 |
CBUILDLIST<CClassTermExpression*>* mLocBuildConceptList; |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
// only local builder data |
| 277 |
CBUILDSET<CClassTermExpression*> mClassGCIExpressionSet; |
| 278 |
bool mRebuildTopConcept; |
| 279 |
CBUILDSET<CBuildExpression*> mLocalisationSet; |
| 280 |
|
| 281 |
CBUILDSET<CClassTermExpression*> mBuildingConceptSet; |
| 282 |
CBUILDSET<CObjectPropertyTermExpression*> mBuildingObjectRoleSet; |
| 283 |
CBUILDSET<CDataPropertyTermExpression*> mBuildingDataRoleSet; |
| 284 |
CBUILDSET<CDataRangeTermExpression*> mBuildingDataRangeSet; |
| 285 |
CBUILDSET<CDatatypeExpression*> mBuildingDatatypeSet; |
| 286 |
CBUILDSET<CIndividualTermExpression*> mBuildingIndividualSet; |
| 287 |
|
| 288 |
CBUILDSET<CClassTermExpression*> mNewBuildedConceptSet; |
| 289 |
CBUILDSET<CObjectPropertyTermExpression*> mNewBuildedObjectRoleSet; |
| 290 |
CBUILDSET<CDataPropertyTermExpression*> mNewBuildedDataRoleSet; |
| 291 |
CBUILDSET<CDataRangeTermExpression*> mNewBuildedDataRangeSet; |
| 292 |
CBUILDSET<CDatatypeExpression*> mNewBuildedDatatypeSet; |
| 293 |
CBUILDSET<CIndividualTermExpression*> mNewBuildedIndividualSet; |
| 294 |
|
| 295 |
|
| 296 |
CBUILDLIST<CConcept*> mTaggingConceptList; |
| 297 |
CBUILDLIST<CConcept*> mInstallConceptList; |
| 298 |
|
| 299 |
CBUILDSET<CRole*> mTaggingRoleSet; |
| 300 |
CBUILDLIST<CRole*> mInstallRoleList; |
| 301 |
|
| 302 |
CBUILDLIST<CIndividual*> mTaggingIndividualSet; |
| 303 |
CBUILDLIST<CIndividual*> mInstallIndividualList; |
| 304 |
|
| 305 |
CBUILDSET<CRoleChain*> mTaggingRoleChainSet; |
| 306 |
CBUILDLIST<CRoleChain*> mInstallRoleChainList; |
| 307 |
|
| 308 |
CBUILDSET<CClassTermExpression*> mNewBuildConceptSet; |
| 309 |
CBUILDSET<CObjectPropertyTermExpression*> mNewBuildObjectRoleSet; |
| 310 |
CBUILDSET<CDataPropertyTermExpression*> mNewBuildDataRoleSet; |
| 311 |
CBUILDSET<CDataRangeTermExpression*> mNewBuildDataRangeSet; |
| 312 |
CBUILDSET<CDatatypeExpression*> mNewBuildDatatypeSet; |
| 313 |
CBUILDSET<CIndividualTermExpression*> mNewBuildIndividualSet; |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
CBUILDSET<CBuildExpression*> mELExceptionExpressionSet; |
| 318 |
|
| 319 |
QList<CIndividualTermExpression*> mLateIndiNominalConceptCreationList; |
| 320 |
bool mNominalConceptCreationRequired; |
| 321 |
|
| 322 |
|
| 323 |
COntologyTriplesAssertionsAccessor* mIndexedTriplesAssertionAccessor; |
| 324 |
CMAPPINGHASH<CStringRefStringHasher, CIndividual*>* mIndividualNameIndividualMapHash; |
| 325 |
|
| 326 |
|
| 327 |
}; |
| 328 |
|
| 329 |
}; // end namespace Generator |
| 330 |
|
| 331 |
}; // end namespace Reasoner |
| 332 |
|
| 333 |
}; // end namespace Konclude |
| 334 |
|
| 335 |
#endif // end KONCLUDE_REASONER_GENERATOR_CCONCRETEONTOLOGYUPDATEBUILDER_H |