/*
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
*
* This file is part of the reasoning system Konclude.
* For details and support, see .
*
* Konclude is free software: you can redistribute it and/or modify
* it under the terms of version 3 of the GNU Lesser General Public
* License (LGPLv3) as published by the Free Software Foundation.
*
* Konclude is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU (Lesser) General Public License for more details.
*
* You should have received a copy of the GNU (Lesser) General Public
* License along with Konclude. If not, see .
*
*/
#ifndef KONCLUDE_REASONER_GENERATOR_CCONCRETEONTOLOGYUPDATEBUILDER_H
#define KONCLUDE_REASONER_GENERATOR_CCONCRETEONTOLOGYUPDATEBUILDER_H
// Libraries includes
#include
#include
#include
#include
// Namespace includes
#include "CConcreteOntologyBuildDataUpdater.h"
#include "CExpressionSplitter.h"
#include "CExpressionHasher.h"
// Other includes
#include "Reasoner/Ontology/CConcreteOntology.h"
#include "Reasoner/Ontology/CConcept.h"
#include "Reasoner/Ontology/CTBox.h"
#include "Reasoner/Ontology/CABox.h"
#include "Reasoner/Ontology/CRBox.h"
#include "Reasoner/Ontology/CAbbreviatedIRIName.h"
#include "Reasoner/Ontology/CIRIName.h"
#include "Utilities/CTrible.hpp"
#include "Utilities/CNegLinker.hpp"
#include "Utilities/CHashableIntConvertedNTuble.hpp"
#include "Utilities/CMemoryManager.hpp"
#include "Utilities/CDynamicExpandingMemoryManager.hpp"
#include "Utilities/Memory/CObjectAllocator.h"
#include "Parser/COntologyBuilder.h"
// Logger includes
#include "Logger/CLogger.h"
namespace Konclude {
using namespace Utilities;
using namespace Utilities::Memory;
using namespace Parser;
namespace Reasoner {
using namespace Ontology;
namespace Generator {
/*!
*
* \class CConcreteOntologyUpdateBuilder
* \author Andreas Steigmiller
* \version 0.1
* \brief TODO
*
*/
class CConcreteOntologyUpdateBuilder : public CConcreteOntologyBuildDataUpdater {
// public methods
public:
CConcreteOntologyUpdateBuilder(CConcreteOntology* updateConcreteOntology);
virtual ~CConcreteOntologyUpdateBuilder();
virtual bool initializeBuilding();
virtual bool completeBuilding();
virtual bool tellOntologyAxiom(CAxiomExpression* axiom);
virtual bool retractOntologyAxiom(CAxiomExpression* axiom);
// protected functions
protected:
bool setConceptOperands(CConcept* concept, CConcept* operandConcept, bool negate = false);
bool setConceptOperandsFromClassTerms(CConcept* concept, CEXPRESSIONLIST* classTermList, bool negate = false);
bool setConceptOperandsFromClassTerms(CConcept* concept, CClassTermExpression* classTermExp, bool negate = false);
bool setConceptOperandsFromDataRangeTerms(CConcept* concept, CDataRangeTermExpression* dataRangeTermExp, bool negate = false);
bool setConceptOperandsFromDataRangeTerms(CConcept* concept, CEXPRESSIONLIST* dataRangeTermExpList, bool negate = false);
bool setConceptRoleFromObjectPropertyTerm(CConcept* concept, CObjectPropertyTermExpression* objectPropertyTermExp);
bool setConceptRoleFromDataPropertyTerm(CConcept* concept, CDataPropertyTermExpression* dataPropertyTermExp);
bool setConceptIndividualFromIndividualTerm(CConcept* concept, CIndividualTermExpression* indiTermExp);
bool setConceptNominalIndividualFromIndividualTerm(CConcept* concept, CIndividualTermExpression* indiTermExp);
bool setIndividualAssertionConceptFromClassTerm(CIndividual* individual, CClassTermExpression* classTermExp, bool negate = false);
bool setIndividualAssertionNominalFromClassTerm(CIndividual* individual, CClassTermExpression* classTermExp, bool negate = false);
bool setIndividualAssertionRoleFromObjectPropertyTerm(CIndividual* individual, CObjectPropertyTermExpression* objPropTermExp, CIndividualTermExpression* destIndiTermExp);
bool setIndividualAssertionDataFromDataLiteralTerm(CIndividual* individual, CDataPropertyTermExpression* dataPropTermExp, CDataLiteralExpression* dataLitExp);
bool buildClassConcept(CClassTermExpression* classTermExp);
bool buildConceptSubClassInclusion(CClassTermExpression* subClassExp, CClassTermExpression* inclusionClassExp, bool negate = false);
bool buildConceptEquivalentClass(CClassTermExpression* classExp1, CClassTermExpression* classExp2);
bool buildPermutableConceptEquivalentClass(CClassTermExpression* classExp1, CClassTermExpression* classExp2);
bool buildPermutableConceptEquivalentClass(CClassTermExpression* eqCallClassExp, const CEXPRESSIONLIST& eqClassExpList);
bool buildPermutableConceptDisjointClass(CClassTermExpression* disCallClassExp, const CEXPRESSIONLIST& disClassExpList);
bool buildDisjointUnionConceptClass(CClassTermExpression* disCallClassExp, const CEXPRESSIONLIST& disClassExpList);
bool buildGeneralConceptInclusionClassExpression(CClassTermExpression* gciClassTermExp);
bool buildObjectPropertyRole(CObjectPropertyTermExpression* objPropTermExp);
bool buildDataPropertyRole(CDataPropertyTermExpression* dataPropTermExp);
bool buildDatatype(CDatatypeExpression* datatypeExp);
bool buildIndividualIndi(CIndividualTermExpression* indiTermExp);
CRoleChain* buildRoleChainForSubObjectPropertyOfExpression(CSubObjectPropertyOfExpression* subObPropExp);
CRoleChain* buildRoleChainForTransetiveObjectPropertyExpression(CTransetiveObjectPropertyExpression* objPropAxiomExp);
CConcept* getConceptForClassTerm(CClassTermExpression* classTermExp, bool forceLocalisation = false);
CRole* getRoleForObjectPropertyTerm(CObjectPropertyTermExpression* objPropTermExp, bool forceLocalisation = false);
CRole* getRoleForDataPropertyTerm(CDataPropertyTermExpression* dataPropTermExp, bool forceLocalisation = false);
CIndividual* getIndividualForIndividualTerm(CIndividualTermExpression* indiTermExp, bool forceLocalisation = false);
CConcept* getConceptForDataRangeTerm(CDataRangeTermExpression* dataRangeExp, bool forceLocalisation = false);
CDatatype* getDatatypeForDatatypeExpression(CDatatypeExpression* datatypeExp, bool forceLocalisation = false);
CDataLiteral* getDataLiteralForLiteralExpression(CDataLiteralExpression* dataLiteralExp, bool forceLocalisation = false);
bool updateName(CNamedItem* item, const QString& name);
bool resortAndInstallConceptsAndRolesAndIndividuals();
CSortedNegLinker* resortConceptLinkersByTagging(CSortedNegLinker* conceptLinkers, cint64 linkerCount = -1);
CSortedNegLinker* resortRoleLinkersByTagging(CSortedNegLinker* roleLinkers);
bool buildConceptTags();
bool buildRoleTags();
bool buildRoleChainTags();
bool buildIndividualIDs();
cint64 getIndividualVariableID(CConcept* concept, CObjectIndividualVariableExpression* objectIndVarExp);
// protected variables
protected:
COntologyDataBoxes* mOntoData;
COntologyBuildConstructFlags* mConstructFlags;
CTBox* tBox;
CABox* aBox;
CRBox* rBox;
bool mInitialBuild;
// contains also previous ontology data
CONTOLOGYAXIOMSET* mTellAxiomSet;
CONTOLOGYAXIOMSET* mRetractAxiomSet;
CONTOLOGYAXIOMLIST< QPair >* mChangeAxiomList;
// contains only updated data
CONTOLOGYAXIOMSET* mTellUpdatedAxiomSet;
CONTOLOGYAXIOMSET* mRetractUpdatedAxiomSet;
CONTOLOGYAXIOMLIST< QPair >* mChangeUpdatedAxiomList;
CBUILDHASH* mUpdateClassAxiomHash;
CBUILDHASH* mUpdateObjectPropertyAxiomHash;
CBUILDHASH* mUpdateDataPropertyAxiomHash;
CBUILDHASH* mUpdateAssertionAxiomHash;
// contains also previous ontology data
CBUILDSET< QPair >* mClassTermClassAxiomSet;
CBUILDHASH* mClassTermClassAxiomHash;
CBUILDHASH* mDatatypeExpDatatypeHash;
CBUILDHASH* mDatatypeDatatypeExpHash;
CBUILDHASH, CDataLiteral*>* mLexicalDataExpDatatypePairDataLiteralHash;
CBUILDSET< QPair >* mObjPropTermObjPropAxiomSet;
CBUILDHASH* mObjPropTermObjPropAxiomHash;
CBUILDSET< QPair >* mDataPropTermDataPropAxiomSet;
CBUILDHASH* mDataPropTermDataPropAxiomHash;
CBUILDSET* mTopRebuildClassTermExpressionsSet;
CBUILDSET* mTopRebuildObjectPropertyTermExpressionsSet;
CBUILDSET< QPair >* mIndiTermAssertionAxiomSet;
CBUILDHASH* mIndiTermAssertionAxiomHash;
CBUILDHASH* mClassTermConceptHash;
CBUILDHASH* mConceptClassTermHash;
CBUILDHASH* mDataRangeTermConceptHash;
CBUILDHASH* mConceptDataRangeTermHash;
CBUILDHASH* mObjPropTermRoleHash;
CBUILDHASH* mRoleObjPropTermHash;
CBUILDHASH* mDataPropTermRoleHash;
CBUILDHASH* mRoleDataPropTermHash;
CBUILDHASH* mObjPropTermRoleChainHash;
CBUILDHASH* mRoleChainObjPropTermHash;
CBUILDHASH* mIndividulTermIndiHash;
CBUILDHASH* mIndiIndividulTermHash;
cint64 mLastProcessedChangedAxiom;
cint64 mLastProcessedBuildIndividual;
cint64 mLastProcessedBuildConcept;
cint64 mLastProcessedBuildObjectRole;
cint64 mLastProcessedBuildDataRole;
cint64 mLastProcessedBuildDataRange;
cint64 mLastProcessedBuildDatatype;
cint64 mLastProcessedInverseProperty;
cint64 mLastProcessedExpression;
cint64 mLastBuildedIndividual;
cint64 mLastBuildedConcept;
cint64 mLastBuildedObjectRole;
cint64 mLastBuildedDataRole;
cint64 mLastBuildedDataRange;
cint64 mLastBuildedDatatype;
CBUILDHASH* mLocInverseObjectPropertyHash;
CBUILDHASH* mLocExpressionBuildHash;
CBUILDLIST* mLocExpressionBuildContainerList;
CBUILDSET* mInitialBuildConceptSet;
CBUILDSET* mLocBuildConceptSet;
CBUILDSET* mLocBuildObjectRoleSet;
CBUILDSET* mLocBuildDataRoleSet;
CBUILDSET* mLocBuildDataRangeSet;
CBUILDSET* mLocBuildDatatypeSet;
CBUILDSET* mLocBuildIndividualSet;
CBUILDLIST* mLocBuildIndividualList;
CBUILDLIST* mLocBuildObjectRoleList;
CBUILDLIST* mLocBuildDataRoleList;
CBUILDLIST* mLocBuildDataRangeList;
CBUILDLIST* mLocBuildDatatypeList;
CBUILDLIST* mLocBuildConceptList;
// only local builder data
CBUILDSET mClassGCIExpressionSet;
bool mRebuildTopConcept;
CBUILDSET mLocalisationSet;
CBUILDSET mBuildingConceptSet;
CBUILDSET mBuildingObjectRoleSet;
CBUILDSET mBuildingDataRoleSet;
CBUILDSET mBuildingDataRangeSet;
CBUILDSET mBuildingDatatypeSet;
CBUILDSET mBuildingIndividualSet;
CBUILDSET mNewBuildedConceptSet;
CBUILDSET mNewBuildedObjectRoleSet;
CBUILDSET mNewBuildedDataRoleSet;
CBUILDSET mNewBuildedDataRangeSet;
CBUILDSET mNewBuildedDatatypeSet;
CBUILDSET mNewBuildedIndividualSet;
CBUILDLIST mTaggingConceptList;
CBUILDLIST mInstallConceptList;
CBUILDSET mTaggingRoleSet;
CBUILDLIST mInstallRoleList;
CBUILDLIST mTaggingIndividualSet;
CBUILDLIST mInstallIndividualList;
CBUILDSET mTaggingRoleChainSet;
CBUILDLIST mInstallRoleChainList;
CBUILDSET mNewBuildConceptSet;
CBUILDSET mNewBuildObjectRoleSet;
CBUILDSET mNewBuildDataRoleSet;
CBUILDSET mNewBuildDataRangeSet;
CBUILDSET mNewBuildDatatypeSet;
CBUILDSET mNewBuildIndividualSet;
CBUILDSET mELExceptionExpressionSet;
QList mLateIndiNominalConceptCreationList;
bool mNominalConceptCreationRequired;
COntologyTriplesAssertionsAccessor* mIndexedTriplesAssertionAccessor;
CMAPPINGHASH* mIndividualNameIndividualMapHash;
};
}; // end namespace Generator
}; // end namespace Reasoner
}; // end namespace Konclude
#endif // end KONCLUDE_REASONER_GENERATOR_CCONCRETEONTOLOGYUPDATEBUILDER_H