| 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 "CConcreteOntologyUpdateBuilder.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Generator { |
| 29 |
|
| 30 |
CConcreteOntologyUpdateBuilder::CConcreteOntologyUpdateBuilder(CConcreteOntology* updateConcreteOntology) : CConcreteOntologyBuildDataUpdater(updateConcreteOntology) { |
| 31 |
LOG(NOTICE,"::Konclude::Reasoner::Generator::ConcretOntologyUpdateBuilder",logTr("ConcretOntologyUpdateBuilder initialized."),this); |
| 32 |
} |
| 33 |
|
| 34 |
CConcreteOntologyUpdateBuilder::~CConcreteOntologyUpdateBuilder() { |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
bool CConcreteOntologyUpdateBuilder::initializeBuilding() { |
| 42 |
CConcreteOntologyBuildDataUpdater::initializeBuilding(); |
| 43 |
|
| 44 |
|
| 45 |
mNominalConceptCreationRequired = false; |
| 46 |
mLateIndiNominalConceptCreationList.clear(); |
| 47 |
|
| 48 |
mTellAxiomSet = mOntoBuild->getTellAxiomSet(); |
| 49 |
mRetractAxiomSet = mOntoBuild->getRetractAxiomSet(); |
| 50 |
|
| 51 |
mTellUpdatedAxiomSet = mOntoBuild->getUpdatedTellAxiomSet(); |
| 52 |
mRetractUpdatedAxiomSet = mOntoBuild->getUpdatedRetractAxiomSet(); |
| 53 |
|
| 54 |
mChangeAxiomList = mOntoBuild->getChangeAxiomList(); |
| 55 |
mChangeUpdatedAxiomList = mOntoBuild->getUpdatedChangeAxiomList(); |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
mOntoData = mOnto->getDataBoxes(); |
| 60 |
tBox = mOntoData->getTBox(); |
| 61 |
rBox = mOntoData->getRBox(); |
| 62 |
aBox = mOntoData->getABox(); |
| 63 |
mBoxContext = mOntoData->getBoxContext(); |
| 64 |
|
| 65 |
mIndividualNameIndividualMapHash = nullptr; |
| 66 |
mIndexedTriplesAssertionAccessor = mOnto->getOntologyTriplesData()->getTripleAssertionAccessor(); |
| 67 |
if (!mIndexedTriplesAssertionAccessor) { |
| 68 |
CConcreteOntology* prevOntology = mOnto; |
| 69 |
while (prevOntology && !mIndexedTriplesAssertionAccessor) { |
| 70 |
prevOntology = prevOntology->getIncrementalRevisionData()->getPreviousOntologyVersion(); |
| 71 |
if (prevOntology) { |
| 72 |
mIndexedTriplesAssertionAccessor = prevOntology->getOntologyTriplesData()->getTripleAssertionAccessor(); |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
if (!mIndexedTriplesAssertionAccessor) { |
| 77 |
mIndividualNameIndividualMapHash = mOnto->getStringMapping()->getIndividualNameIndividualMappingHash(false); |
| 78 |
if (!mIndividualNameIndividualMapHash || mIndividualNameIndividualMapHash->isEmpty()) { |
| 79 |
mIndividualNameIndividualMapHash = nullptr; |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
mInitialBuild = mOntoData->isInitialBuild(); |
| 85 |
|
| 86 |
mConstructFlags = mOntoData->getExpressionDataBoxMapping()->getBuildConstructFlags(); |
| 87 |
|
| 88 |
mUpdateClassAxiomHash = mOntoData->getExpressionDataBoxMapping()->getUpdatedClassAxiomTellOrRetractHash(); |
| 89 |
mUpdateObjectPropertyAxiomHash = mOntoData->getExpressionDataBoxMapping()->getUpdateObjectPropertyAxiomHash(); |
| 90 |
mUpdateDataPropertyAxiomHash = mOntoData->getExpressionDataBoxMapping()->getUpdateDataPropertyAxiomHash(); |
| 91 |
mUpdateAssertionAxiomHash = mOntoData->getExpressionDataBoxMapping()->getUpdateAssertionAxiomHash(); |
| 92 |
|
| 93 |
mClassTermClassAxiomSet = mOntoData->getExpressionDataBoxMapping()->getClassTermExpressionClassAxiomExpressionSet(); |
| 94 |
mClassTermClassAxiomHash = mOntoData->getExpressionDataBoxMapping()->getClassTermExpressionClassAxiomExpressionHash(); |
| 95 |
|
| 96 |
|
| 97 |
mDatatypeExpDatatypeHash = mOntoData->getExpressionDataBoxMapping()->getDatatypeExpressionDatatypeHash(); |
| 98 |
mDatatypeDatatypeExpHash = mOntoData->getExpressionDataBoxMapping()->getDatatypeDatatypeExpessionHash(); |
| 99 |
|
| 100 |
mLexicalDataExpDatatypePairDataLiteralHash = mOntoData->getExpressionDataBoxMapping()->getDataLexicalValueExpressionDatatypePairDataLiteralHash(); |
| 101 |
|
| 102 |
|
| 103 |
mObjPropTermObjPropAxiomSet = mOntoData->getExpressionDataBoxMapping()->getObjectPropertyTermObjectPropertyAxiomSet(); |
| 104 |
mObjPropTermObjPropAxiomHash = mOntoData->getExpressionDataBoxMapping()->getObjectPropertyTermObjectPropertyAxiomHash(); |
| 105 |
|
| 106 |
|
| 107 |
mDataPropTermDataPropAxiomSet = mOntoData->getExpressionDataBoxMapping()->getDataPropertyTermDataPropertyAxiomSet(); |
| 108 |
mDataPropTermDataPropAxiomHash = mOntoData->getExpressionDataBoxMapping()->getDataPropertyTermDataPropertyAxiomHash(); |
| 109 |
|
| 110 |
|
| 111 |
mIndiTermAssertionAxiomSet = mOntoData->getExpressionDataBoxMapping()->getIndividualTermAssertionAxiomSet(); |
| 112 |
mIndiTermAssertionAxiomHash = mOntoData->getExpressionDataBoxMapping()->getIndividualTermAssertionAxiomHash(); |
| 113 |
|
| 114 |
mTopRebuildClassTermExpressionsSet = mOntoData->getExpressionDataBoxMapping()->getTopRebuildClassTermExpressionsSet(); |
| 115 |
mTopRebuildObjectPropertyTermExpressionsSet = mOntoData->getExpressionDataBoxMapping()->getTopRebuildObjectPropertyTermExpressionsSet(); |
| 116 |
|
| 117 |
|
| 118 |
mClassTermConceptHash = mOntoData->getExpressionDataBoxMapping()->getClassTermConceptMappingHash(); |
| 119 |
mConceptClassTermHash = mOntoData->getExpressionDataBoxMapping()->getConceptClassTermMappingHash(); |
| 120 |
mDataRangeTermConceptHash = mOntoData->getExpressionDataBoxMapping()->getDataRangeTermConceptMappingHash(); |
| 121 |
mConceptDataRangeTermHash = mOntoData->getExpressionDataBoxMapping()->getConceptDataRangeTermMappingHash(); |
| 122 |
|
| 123 |
mObjPropTermRoleHash = mOntoData->getExpressionDataBoxMapping()->getObjectPropertyTermRoleMappingHash(); |
| 124 |
mRoleObjPropTermHash = mOntoData->getExpressionDataBoxMapping()->getRoleObjectPropertyTermMappingHash(); |
| 125 |
mDataPropTermRoleHash = mOntoData->getExpressionDataBoxMapping()->getDataPropertyTermRoleMappingHash(); |
| 126 |
mRoleDataPropTermHash = mOntoData->getExpressionDataBoxMapping()->getRoleDataPropertyTermMappingHash(); |
| 127 |
|
| 128 |
mIndividulTermIndiHash = mOntoData->getExpressionDataBoxMapping()->getIndividulTermIndiMappingHash(); |
| 129 |
mIndiIndividulTermHash = mOntoData->getExpressionDataBoxMapping()->getIndiIndividulTermMappingHash(); |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
mRoleChainObjPropTermHash = mOntoData->getExpressionDataBoxMapping()->getRoleChainObjectPropertyTermHash(); |
| 135 |
mObjPropTermRoleChainHash = mOntoData->getExpressionDataBoxMapping()->getObjectPropertyTermRoleChainHash(); |
| 136 |
|
| 137 |
mLastProcessedChangedAxiom = mOntoData->getExpressionDataBoxMapping()->getLastProcessedChangedAxiom(); |
| 138 |
mLastProcessedBuildIndividual = mOntoData->getExpressionDataBoxMapping()->getLastProcessedBuildIndividual(); |
| 139 |
mLastProcessedBuildConcept = mOntoData->getExpressionDataBoxMapping()->getLastProcessedBuildConcept(); |
| 140 |
mLastProcessedBuildObjectRole = mOntoData->getExpressionDataBoxMapping()->getLastProcessedBuildObjectRole(); |
| 141 |
mLastProcessedBuildDataRole = mOntoData->getExpressionDataBoxMapping()->getLastProcessedBuildDataRole(); |
| 142 |
mLastProcessedBuildDataRange = mOntoData->getExpressionDataBoxMapping()->getLastProcessedBuildDataRange(); |
| 143 |
mLastProcessedBuildDatatype = mOntoData->getExpressionDataBoxMapping()->getLastProcessedBuildDatatype(); |
| 144 |
|
| 145 |
mLastProcessedExpression = mOntoData->getExpressionDataBoxMapping()->getLastProcessedExpression(); |
| 146 |
mLastProcessedInverseProperty = mOntoData->getExpressionDataBoxMapping()->getLastProcessedInverseProperty(); |
| 147 |
|
| 148 |
mLastBuildedIndividual = mOntoData->getExpressionDataBoxMapping()->getLastBuildedIndividual(); |
| 149 |
mLastBuildedConcept = mOntoData->getExpressionDataBoxMapping()->getLastBuildedConcept(); |
| 150 |
mLastBuildedObjectRole = mOntoData->getExpressionDataBoxMapping()->getLastBuildedObjectRole(); |
| 151 |
mLastBuildedDataRole = mOntoData->getExpressionDataBoxMapping()->getLastBuildedDataRole(); |
| 152 |
mLastBuildedDataRange = mOntoData->getExpressionDataBoxMapping()->getLastBuildedDataRange(); |
| 153 |
mLastBuildedDatatype = mOntoData->getExpressionDataBoxMapping()->getLastBuildedDatatype(); |
| 154 |
|
| 155 |
mLocExpressionBuildHash = mOntoData->getExpressionDataBoxMapping()->getStructuralExpressionBuildHash(); |
| 156 |
mLocExpressionBuildContainerList = mOntoData->getExpressionDataBoxMapping()->getExpressionBuildListContainer(); |
| 157 |
mLocInverseObjectPropertyHash = mOntoData->getExpressionDataBoxMapping()->getInverseObjectPropertyHash(); |
| 158 |
|
| 159 |
mLocBuildConceptSet = mOntoData->getExpressionDataBoxMapping()->getBuildedConceptSet(); |
| 160 |
mLocBuildObjectRoleSet = mOntoData->getExpressionDataBoxMapping()->getBuildedObjectRoleSet(); |
| 161 |
mLocBuildDataRoleSet = mOntoData->getExpressionDataBoxMapping()->getBuildedDataRoleSet(); |
| 162 |
mLocBuildDataRangeSet = mOntoData->getExpressionDataBoxMapping()->getBuildedDataRangeSet(); |
| 163 |
mLocBuildDatatypeSet = mOntoData->getExpressionDataBoxMapping()->getBuildedDatatypeSet(); |
| 164 |
mLocBuildIndividualSet = mOntoData->getExpressionDataBoxMapping()->getBuildedIndividualSet(); |
| 165 |
|
| 166 |
mLocBuildConceptList = mOntoData->getExpressionDataBoxMapping()->getBuildedConceptList(); |
| 167 |
mLocBuildObjectRoleList = mOntoData->getExpressionDataBoxMapping()->getBuildedObjectRoleList(); |
| 168 |
mLocBuildDataRoleList = mOntoData->getExpressionDataBoxMapping()->getBuildedDataRoleList(); |
| 169 |
mLocBuildDataRangeList = mOntoData->getExpressionDataBoxMapping()->getBuildedDataRangeList(); |
| 170 |
mLocBuildDatatypeList = mOntoData->getExpressionDataBoxMapping()->getBuildedDatatypeList(); |
| 171 |
mLocBuildIndividualList = mOntoData->getExpressionDataBoxMapping()->getBuildedIndividualList(); |
| 172 |
|
| 173 |
mRebuildTopConcept = false; |
| 174 |
|
| 175 |
mClassGCIExpressionSet.clear(); |
| 176 |
mLocalisationSet.clear(); |
| 177 |
|
| 178 |
mBuildingConceptSet.clear(); |
| 179 |
mNewBuildedConceptSet.clear(); |
| 180 |
|
| 181 |
mNewBuildedObjectRoleSet.clear(); |
| 182 |
mNewBuildedDataRoleSet.clear(); |
| 183 |
mBuildingObjectRoleSet.clear(); |
| 184 |
mBuildingDataRangeSet.clear(); |
| 185 |
mBuildingDatatypeSet.clear(); |
| 186 |
mBuildingDataRoleSet.clear(); |
| 187 |
|
| 188 |
mNewBuildedIndividualSet.clear(); |
| 189 |
mBuildingIndividualSet.clear(); |
| 190 |
|
| 191 |
mTaggingConceptList.clear(); |
| 192 |
mInstallConceptList.clear(); |
| 193 |
mTaggingRoleSet.clear(); |
| 194 |
mInstallRoleList.clear(); |
| 195 |
mTaggingRoleChainSet.clear(); |
| 196 |
mInstallRoleChainList.clear(); |
| 197 |
mTaggingIndividualSet.clear(); |
| 198 |
mInstallIndividualList.clear(); |
| 199 |
|
| 200 |
mNewBuildConceptSet.clear(); |
| 201 |
mNewBuildObjectRoleSet.clear(); |
| 202 |
mNewBuildDataRoleSet.clear(); |
| 203 |
mNewBuildDataRangeSet.clear(); |
| 204 |
mNewBuildDatatypeSet.clear(); |
| 205 |
mNewBuildIndividualSet.clear(); |
| 206 |
|
| 207 |
return true; |
| 208 |
} |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
bool CConcreteOntologyUpdateBuilder::completeBuilding() { |
| 213 |
|
| 214 |
mOntoBuild->setNextAxiomNumber(mNextAxiomNumber+mNextMaxAxiomNumberOffset); |
| 215 |
|
| 216 |
|
| 217 |
CONTOLOGYAXIOMSET<CAxiomExpression*> newTellUpdatedAxiomSet; |
| 218 |
CONTOLOGYAXIOMSET<CAxiomExpression*> newRetractUpdatedAxiomSet; |
| 219 |
|
| 220 |
if (!mRetractUpdatedAxiomSet->isEmpty()) { |
| 221 |
mConstructFlags->setRetractionUsed(); |
| 222 |
} |
| 223 |
//FOREACHIT (CAxiomExpression* axiomExp, *mRetractUpdatedAxiomSet) { |
| 224 |
// mConstructFlags->setRetractionUsed(); |
| 225 |
// mChangeUpdatedAxiomList->append( QPair<CAxiomExpression*,bool>(axiomExp,false) ); |
| 226 |
// mChangeAxiomList->append( QPair<CAxiomExpression*,bool>(axiomExp,false) ); |
| 227 |
//} |
| 228 |
//FOREACHIT (CAxiomExpression* axiomExp, *mTellUpdatedAxiomSet) { |
| 229 |
// mChangeUpdatedAxiomList->append( QPair<CAxiomExpression*,bool>(axiomExp,true) ); |
| 230 |
// mChangeAxiomList->append( QPair<CAxiomExpression*,bool>(axiomExp,true) ); |
| 231 |
//} |
| 232 |
|
| 233 |
if (mLastProcessedChangedAxiom <= 0) { |
| 234 |
mLastProcessedChangedAxiom = mChangeAxiomList->size(); |
| 235 |
newTellUpdatedAxiomSet = *mTellAxiomSet; |
| 236 |
} else { |
| 237 |
CONTOLOGYAXIOMLIST< QPair<CAxiomExpression*,bool> > newChangeUpdatedAxiomList; |
| 238 |
|
| 239 |
cint64 changeAxiomCount = mChangeAxiomList->size(); |
| 240 |
while (mLastProcessedChangedAxiom < changeAxiomCount) { |
| 241 |
newChangeUpdatedAxiomList.append((*mChangeAxiomList)[mLastProcessedChangedAxiom++]); |
| 242 |
} |
| 243 |
|
| 244 |
for (CONTOLOGYAXIOMLIST< QPair<CAxiomExpression*,bool> >::const_iterator it = newChangeUpdatedAxiomList.constBegin(), itEnd = newChangeUpdatedAxiomList.constEnd(); it != itEnd; ++it) { |
| 245 |
QPair<CAxiomExpression*,bool> axiomAdditionPair(*it); |
| 246 |
CAxiomExpression* axiomExp = axiomAdditionPair.first; |
| 247 |
bool axiomAdded = axiomAdditionPair.second; |
| 248 |
if (axiomAdded) { |
| 249 |
if (mTellAxiomSet->contains(axiomExp)) { |
| 250 |
newTellUpdatedAxiomSet.insert(axiomExp); |
| 251 |
} |
| 252 |
} else { |
| 253 |
if (!mTellAxiomSet->contains(axiomExp)) { |
| 254 |
newRetractUpdatedAxiomSet.insert(axiomExp); |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
if (mLastProcessedInverseProperty <= 0) { |
| 262 |
*mLocInverseObjectPropertyHash = *mInverseObjectPropertyHash; |
| 263 |
mLastProcessedInverseProperty = mInverseObjectPropertyList->count(); |
| 264 |
} else { |
| 265 |
while (mLastProcessedInverseProperty < mInverseObjectPropertyList->count()) { |
| 266 |
const QPair<CObjectPropertyTermExpression*,CObjectPropertyTermExpression*> obPropPair((*mInverseObjectPropertyList)[mLastProcessedInverseProperty++]); |
| 267 |
mLocInverseObjectPropertyHash->insert(obPropPair.first,obPropPair.second); |
| 268 |
mLocInverseObjectPropertyHash->insert(obPropPair.second,obPropPair.first); |
| 269 |
} |
| 270 |
} |
| 271 |
mInverseObjectPropertyHash = mLocInverseObjectPropertyHash; |
| 272 |
|
| 273 |
if (mLastProcessedExpression <= 0) { |
| 274 |
*mLocExpressionBuildHash = *mExpressionBuildHash; |
| 275 |
mLastProcessedExpression = mExpressionBuildContainerList->count(); |
| 276 |
} else { |
| 277 |
while (mLastProcessedExpression < mExpressionBuildContainerList->count()) { |
| 278 |
CBuildExpression* buildExp((*mExpressionBuildContainerList)[mLastProcessedExpression++]); |
| 279 |
mLocExpressionBuildHash->insert(CExpressionHasher(buildExp),buildExp); |
| 280 |
} |
| 281 |
} |
| 282 |
mExpressionBuildHash = mLocExpressionBuildHash; |
| 283 |
mExpressionBuildContainerList = mLocExpressionBuildContainerList; |
| 284 |
|
| 285 |
if (mLastProcessedBuildIndividual <= 0) { |
| 286 |
*mLocBuildIndividualSet = *mBuildIndividualSet; |
| 287 |
*mLocBuildIndividualList = *mBuildIndividualList; |
| 288 |
mLastProcessedBuildIndividual = mLocBuildIndividualList->count(); |
| 289 |
} else { |
| 290 |
while (mLastProcessedBuildIndividual < mBuildIndividualList->count()) { |
| 291 |
CIndividualTermExpression* buildExp((*mBuildIndividualList)[mLastProcessedBuildIndividual++]); |
| 292 |
mLocBuildIndividualList->append(buildExp); |
| 293 |
mLocBuildIndividualSet->insert(buildExp); |
| 294 |
} |
| 295 |
} |
| 296 |
mBuildIndividualSet = mLocBuildIndividualSet; |
| 297 |
mBuildIndividualList = mLocBuildIndividualList; |
| 298 |
|
| 299 |
if (mLastProcessedBuildConcept <= 0) { |
| 300 |
*mLocBuildConceptSet = *mBuildConceptSet; |
| 301 |
*mLocBuildConceptList = *mBuildConceptList; |
| 302 |
mLastProcessedBuildConcept = mLocBuildConceptList->count(); |
| 303 |
} else { |
| 304 |
while (mLastProcessedBuildConcept < mBuildConceptList->count()) { |
| 305 |
CClassTermExpression* buildExp((*mBuildConceptList)[mLastProcessedBuildConcept++]); |
| 306 |
mLocBuildConceptList->append(buildExp); |
| 307 |
mLocBuildConceptSet->insert(buildExp); |
| 308 |
} |
| 309 |
} |
| 310 |
mInitialBuildConceptSet = mBuildConceptSet; |
| 311 |
mBuildConceptSet = mLocBuildConceptSet; |
| 312 |
mBuildConceptList = mLocBuildConceptList; |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
if (mLastProcessedBuildObjectRole <= 0) { |
| 317 |
*mLocBuildObjectRoleSet = *mBuildObjectRoleSet; |
| 318 |
*mLocBuildObjectRoleList = *mBuildObjectRoleList; |
| 319 |
mLastProcessedBuildObjectRole = mLocBuildObjectRoleList->count(); |
| 320 |
} else { |
| 321 |
while (mLastProcessedBuildObjectRole < mBuildObjectRoleList->count()) { |
| 322 |
CObjectPropertyTermExpression* buildExp((*mBuildObjectRoleList)[mLastProcessedBuildObjectRole++]); |
| 323 |
mLocBuildObjectRoleList->append(buildExp); |
| 324 |
mLocBuildObjectRoleSet->insert(buildExp); |
| 325 |
} |
| 326 |
} |
| 327 |
mBuildObjectRoleSet = mLocBuildObjectRoleSet; |
| 328 |
mBuildObjectRoleList = mLocBuildObjectRoleList; |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
if (mLastProcessedBuildDataRole <= 0) { |
| 334 |
*mLocBuildDataRoleSet = *mBuildDataRoleSet; |
| 335 |
*mLocBuildDataRoleList = *mBuildDataRoleList; |
| 336 |
mLastProcessedBuildDataRole = mLocBuildDataRoleList->count(); |
| 337 |
} else { |
| 338 |
while (mLastProcessedBuildDataRole < mBuildDataRoleList->count()) { |
| 339 |
CDataPropertyTermExpression* buildExp((*mBuildDataRoleList)[mLastProcessedBuildDataRole++]); |
| 340 |
mLocBuildDataRoleList->append(buildExp); |
| 341 |
mLocBuildDataRoleSet->insert(buildExp); |
| 342 |
} |
| 343 |
} |
| 344 |
mBuildDataRoleSet = mLocBuildDataRoleSet; |
| 345 |
mBuildDataRoleList = mLocBuildDataRoleList; |
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
if (mLastProcessedBuildDataRange <= 0) { |
| 352 |
*mLocBuildDataRangeSet = *mBuildDataRangeSet; |
| 353 |
*mLocBuildDataRangeList = *mBuildDataRangeList; |
| 354 |
mLastProcessedBuildDataRange = mLocBuildDataRangeList->count(); |
| 355 |
} else { |
| 356 |
while (mLastProcessedBuildDataRange < mBuildDataRangeList->count()) { |
| 357 |
CDataRangeTermExpression* buildExp((*mBuildDataRangeList)[mLastProcessedBuildDataRange++]); |
| 358 |
mLocBuildDataRangeList->append(buildExp); |
| 359 |
mLocBuildDataRangeSet->insert(buildExp); |
| 360 |
} |
| 361 |
} |
| 362 |
mBuildDataRangeSet = mLocBuildDataRangeSet; |
| 363 |
mBuildDataRangeList = mLocBuildDataRangeList; |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
if (mLastProcessedBuildDatatype <= 0) { |
| 370 |
*mLocBuildDatatypeSet = *mBuildDatatypeSet; |
| 371 |
*mLocBuildDatatypeList = *mBuildDatatypeList; |
| 372 |
mLastProcessedBuildDatatype = mLocBuildDatatypeList->count(); |
| 373 |
} else { |
| 374 |
while (mLastProcessedBuildDatatype < mBuildDatatypeList->count()) { |
| 375 |
CDatatypeExpression* buildExp((*mBuildDatatypeList)[mLastProcessedBuildDatatype++]); |
| 376 |
mLocBuildDatatypeList->append(buildExp); |
| 377 |
mLocBuildDatatypeSet->insert(buildExp); |
| 378 |
} |
| 379 |
} |
| 380 |
mBuildDatatypeSet = mLocBuildDatatypeSet; |
| 381 |
mBuildDatatypeList = mLocBuildDatatypeList; |
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
//mUpdateClassAxiomHash->reserve(mTellAxiomSet->size()); |
| 386 |
//mUpdateObjectPropertyAxiomHash->reserve(mTellAxiomSet->size()); |
| 387 |
//mUpdateDataPropertyAxiomHash->reserve(mTellAxiomSet->size()); |
| 388 |
//mDeclarationAxiomSet->reserve(mTellAxiomSet->size()); |
| 389 |
//mUpdateAssertionAxiomHash->reserve(mTellAxiomSet->size()); |
| 390 |
|
| 391 |
FOREACHIT (CAxiomExpression* axiomExp, newTellUpdatedAxiomSet) { |
| 392 |
CClassAxiomExpression* classAxiomExp = dynamic_cast<CClassAxiomExpression*>(axiomExp); |
| 393 |
if (classAxiomExp) { |
| 394 |
mUpdateClassAxiomHash->insert(classAxiomExp,true); |
| 395 |
} |
| 396 |
CObjectPropertyAxiomExpression* objPropAxiomExp = dynamic_cast<CObjectPropertyAxiomExpression*>(axiomExp); |
| 397 |
if (objPropAxiomExp) { |
| 398 |
mUpdateObjectPropertyAxiomHash->insert(objPropAxiomExp,true); |
| 399 |
} |
| 400 |
CDataPropertyAxiomExpression* dataPropAxiomExp = dynamic_cast<CDataPropertyAxiomExpression*>(axiomExp); |
| 401 |
if (dataPropAxiomExp) { |
| 402 |
mUpdateDataPropertyAxiomHash->insert(dataPropAxiomExp,true); |
| 403 |
} |
| 404 |
CDeclarationAxiomExpression* declAxiomExp = dynamic_cast<CDeclarationAxiomExpression*>(axiomExp); |
| 405 |
if (declAxiomExp) { |
| 406 |
mDeclarationAxiomSet->insert(declAxiomExp); |
| 407 |
} |
| 408 |
CAssertionAxiomExpression* assAxiomExp = dynamic_cast<CAssertionAxiomExpression*>(axiomExp); |
| 409 |
if (assAxiomExp) { |
| 410 |
mUpdateAssertionAxiomHash->insert(assAxiomExp,true); |
| 411 |
} |
| 412 |
} |
| 413 |
FOREACHIT (CAxiomExpression* axiomExp, newRetractUpdatedAxiomSet) { |
| 414 |
CClassAxiomExpression* classAxiomExp = dynamic_cast<CClassAxiomExpression*>(axiomExp); |
| 415 |
if (classAxiomExp) { |
| 416 |
mUpdateClassAxiomHash->insert(classAxiomExp,false); |
| 417 |
} |
| 418 |
CObjectPropertyAxiomExpression* objPropAxiomExp = dynamic_cast<CObjectPropertyAxiomExpression*>(axiomExp); |
| 419 |
if (objPropAxiomExp) { |
| 420 |
mUpdateObjectPropertyAxiomHash->insert(objPropAxiomExp,false); |
| 421 |
} |
| 422 |
CDataPropertyAxiomExpression* dataPropAxiomExp = dynamic_cast<CDataPropertyAxiomExpression*>(axiomExp); |
| 423 |
if (dataPropAxiomExp) { |
| 424 |
mUpdateDataPropertyAxiomHash->insert(dataPropAxiomExp,false); |
| 425 |
} |
| 426 |
CDeclarationAxiomExpression* declAxiomExp = dynamic_cast<CDeclarationAxiomExpression*>(axiomExp); |
| 427 |
if (declAxiomExp) { |
| 428 |
mDeclarationAxiomSet->remove(declAxiomExp); |
| 429 |
} |
| 430 |
CAssertionAxiomExpression* assAxiomExp = dynamic_cast<CAssertionAxiomExpression*>(axiomExp); |
| 431 |
if (assAxiomExp) { |
| 432 |
mUpdateAssertionAxiomHash->insert(assAxiomExp,false); |
| 433 |
} |
| 434 |
} |
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
//mIndiTermAssertionAxiomSet->reserve(mUpdateAssertionAxiomHash->size()); |
| 440 |
//mNewBuildIndividualSet.reserve(mUpdateAssertionAxiomHash->size()); |
| 441 |
//mIndiTermAssertionAxiomHash->reserve(mUpdateAssertionAxiomHash->size()); |
| 442 |
FOREACHHASHIT (CAssertionAxiomExpression* assAxiomExp, bool tellAxiom, *mUpdateAssertionAxiomHash) { |
| 443 |
CBuildExpression::ExpressionType expType = assAxiomExp->getType(); |
| 444 |
if (expType == CBuildExpression::BETCLASSASSERTION) { |
| 445 |
CClassAssertionExpression* classAssExp = (CClassAssertionExpression*)assAxiomExp; |
| 446 |
CIndividualTermExpression* indiTermExp = classAssExp->getIndividualTermExpression(); |
| 447 |
mNewBuildIndividualSet.insert(indiTermExp); |
| 448 |
if (!mIndiTermAssertionAxiomSet->contains(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp))) { |
| 449 |
mIndiTermAssertionAxiomSet->insert(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp)); |
| 450 |
if (tellAxiom) { |
| 451 |
mIndiTermAssertionAxiomHash->insertMulti(indiTermExp,assAxiomExp); |
| 452 |
} |
| 453 |
} |
| 454 |
} else if (expType == CBuildExpression::BETOBJECTPROPERTYASSERTION) { |
| 455 |
CObjectPropertyAssertionExpression* propAssExp = (CObjectPropertyAssertionExpression*)assAxiomExp; |
| 456 |
CIndividualTermExpression* indiTermExp = propAssExp->getFirstIndividualTermExpression(); |
| 457 |
mNewBuildIndividualSet.insert(indiTermExp); |
| 458 |
if (!mIndiTermAssertionAxiomSet->contains(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp))) { |
| 459 |
mIndiTermAssertionAxiomSet->insert(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp)); |
| 460 |
if (tellAxiom) { |
| 461 |
mIndiTermAssertionAxiomHash->insertMulti(indiTermExp,assAxiomExp); |
| 462 |
} |
| 463 |
} |
| 464 |
} else if (expType == CBuildExpression::BETNEGATIVEOBJECTPROPERTYASSERTION) { |
| 465 |
mConstructFlags->setNonELConstructUsed(); |
| 466 |
CNegativeObjectPropertyAssertionExpression* propAssExp = (CNegativeObjectPropertyAssertionExpression*)assAxiomExp; |
| 467 |
CIndividualTermExpression* indiTermExp = propAssExp->getFirstIndividualTermExpression(); |
| 468 |
mNewBuildIndividualSet.insert(indiTermExp); |
| 469 |
if (!mIndiTermAssertionAxiomSet->contains(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp))) { |
| 470 |
mIndiTermAssertionAxiomSet->insert(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp)); |
| 471 |
if (tellAxiom) { |
| 472 |
mIndiTermAssertionAxiomHash->insertMulti(indiTermExp,assAxiomExp); |
| 473 |
} |
| 474 |
} |
| 475 |
} else if (expType == CBuildExpression::BETDATAPROPERTYASSERTION) { |
| 476 |
CDataPropertyAssertionExpression* propAssExp = (CDataPropertyAssertionExpression*)assAxiomExp; |
| 477 |
CIndividualTermExpression* indiTermExp = propAssExp->getIndividualTermExpression(); |
| 478 |
mNewBuildIndividualSet.insert(indiTermExp); |
| 479 |
if (!mIndiTermAssertionAxiomSet->contains(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp))) { |
| 480 |
mIndiTermAssertionAxiomSet->insert(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp)); |
| 481 |
if (tellAxiom) { |
| 482 |
mIndiTermAssertionAxiomHash->insertMulti(indiTermExp,assAxiomExp); |
| 483 |
} |
| 484 |
} |
| 485 |
} else if (expType == CBuildExpression::BETNEGATIVEDATAPROPERTYASSERTION) { |
| 486 |
mConstructFlags->setNonELConstructUsed(); |
| 487 |
CNegativeDataPropertyAssertionExpression* propAssExp = (CNegativeDataPropertyAssertionExpression*)assAxiomExp; |
| 488 |
CIndividualTermExpression* indiTermExp = propAssExp->getIndividualTermExpression(); |
| 489 |
mNewBuildIndividualSet.insert(indiTermExp); |
| 490 |
if (!mIndiTermAssertionAxiomSet->contains(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp))) { |
| 491 |
mIndiTermAssertionAxiomSet->insert(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp)); |
| 492 |
if (tellAxiom) { |
| 493 |
mIndiTermAssertionAxiomHash->insertMulti(indiTermExp,assAxiomExp); |
| 494 |
} |
| 495 |
} |
| 496 |
} else if (expType == CBuildExpression::BETSAMEINDIVIDUAL) { |
| 497 |
mConstructFlags->setNonELConstructUsed(); |
| 498 |
CSameIndividualExpression* sameIndiAssExp = (CSameIndividualExpression*)assAxiomExp; |
| 499 |
FOREACHIT (CIndividualTermExpression* indiTermExp, *sameIndiAssExp->getIndividualTermExpressionList()) { |
| 500 |
mNewBuildIndividualSet.insert(indiTermExp); |
| 501 |
if (!mIndiTermAssertionAxiomSet->contains(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp))) { |
| 502 |
mIndiTermAssertionAxiomSet->insert(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp)); |
| 503 |
if (tellAxiom) { |
| 504 |
mIndiTermAssertionAxiomHash->insertMulti(indiTermExp,assAxiomExp); |
| 505 |
} |
| 506 |
} |
| 507 |
} |
| 508 |
} else if (expType == CBuildExpression::BETDIFFERENTINDIVIDUAL) { |
| 509 |
mConstructFlags->setNonELConstructUsed(); |
| 510 |
CDifferentIndividualsExpression* diffIndiAssExp = (CDifferentIndividualsExpression*)assAxiomExp; |
| 511 |
FOREACHIT (CIndividualTermExpression* indiTermExp, *diffIndiAssExp->getIndividualTermExpressionList()) { |
| 512 |
mNewBuildIndividualSet.insert(indiTermExp); |
| 513 |
if (!mIndiTermAssertionAxiomSet->contains(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp))) { |
| 514 |
mIndiTermAssertionAxiomSet->insert(QPair<CIndividualTermExpression*,CAssertionAxiomExpression*>(indiTermExp,assAxiomExp)); |
| 515 |
if (tellAxiom) { |
| 516 |
mIndiTermAssertionAxiomHash->insertMulti(indiTermExp,assAxiomExp); |
| 517 |
} |
| 518 |
} |
| 519 |
} |
| 520 |
} |
| 521 |
} |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
FOREACHHASHIT (CClassAxiomExpression* classAxiomExp, bool tellAxiom, *mUpdateClassAxiomHash) { |
| 529 |
CBuildExpression::ExpressionType expType = classAxiomExp->getType(); |
| 530 |
if (expType == CBuildExpression::BETEQUIVALENTCLASSES) { |
| 531 |
// all associated classes has to be updated |
| 532 |
CEquivalentClassesExpression* eqClassExp = (CEquivalentClassesExpression*)classAxiomExp; |
| 533 |
FOREACHIT (CClassTermExpression* classTermExp, *eqClassExp->getClassTermExpressionList()) { |
| 534 |
mNewBuildConceptSet.insert(classTermExp); |
| 535 |
if (!mClassTermClassAxiomSet->contains(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp))) { |
| 536 |
mClassTermClassAxiomSet->insert(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp)); |
| 537 |
if (tellAxiom) { |
| 538 |
mClassTermClassAxiomHash->insertMulti(classTermExp,classAxiomExp); |
| 539 |
} |
| 540 |
} |
| 541 |
} |
| 542 |
} else if (expType == CBuildExpression::BETESUBCLASSOF) { |
| 543 |
// only sub class expression has to be rebuild |
| 544 |
CSubClassOfExpression* subClassOfExp = (CSubClassOfExpression*)classAxiomExp; |
| 545 |
CClassTermExpression* classTermExp = subClassOfExp->getFirstClassTermExpression(); |
| 546 |
mNewBuildConceptSet.insert(classTermExp); |
| 547 |
if (!mClassTermClassAxiomSet->contains(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp))) { |
| 548 |
mClassTermClassAxiomSet->insert(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp)); |
| 549 |
if (tellAxiom) { |
| 550 |
mClassTermClassAxiomHash->insertMulti(classTermExp,classAxiomExp); |
| 551 |
} |
| 552 |
} |
| 553 |
} else if (expType == CBuildExpression::BETDISJOINTCLASSES) { |
| 554 |
// all associated classes has to be updated |
| 555 |
CDisjointClassesExpression* disClassExp = (CDisjointClassesExpression*)classAxiomExp; |
| 556 |
FOREACHIT (CClassTermExpression* classTermExp, *disClassExp->getClassTermExpressionList()) { |
| 557 |
if (classTermExp->getType() != CBuildExpression::BETCLASS) { |
| 558 |
mConstructFlags->setNonELConstructUsed(); |
| 559 |
} |
| 560 |
mNewBuildConceptSet.insert(classTermExp); |
| 561 |
if (!mClassTermClassAxiomSet->contains(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp))) { |
| 562 |
mClassTermClassAxiomSet->insert(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp)); |
| 563 |
if (tellAxiom) { |
| 564 |
mClassTermClassAxiomHash->insertMulti(classTermExp,classAxiomExp); |
| 565 |
} |
| 566 |
} |
| 567 |
} |
| 568 |
} else if (expType == CBuildExpression::BETDISJOINTUNION) { |
| 569 |
mConstructFlags->setNonELConstructUsed(); |
| 570 |
// all associated classes has to be updated |
| 571 |
CDisjointUnionExpression* disClassExp = (CDisjointUnionExpression*)classAxiomExp; |
| 572 |
FOREACHIT (CClassTermExpression* classTermExp, *disClassExp->getClassTermExpressionList()) { |
| 573 |
mNewBuildConceptSet.insert(classTermExp); |
| 574 |
if (!mClassTermClassAxiomSet->contains(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp))) { |
| 575 |
mClassTermClassAxiomSet->insert(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp)); |
| 576 |
if (tellAxiom) { |
| 577 |
mClassTermClassAxiomHash->insertMulti(classTermExp,classAxiomExp); |
| 578 |
} |
| 579 |
} |
| 580 |
} |
| 581 |
CClassTermExpression* classTermExp = disClassExp->getClassExpression(); |
| 582 |
mNewBuildConceptSet.insert(classTermExp); |
| 583 |
if (!mClassTermClassAxiomSet->contains(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp))) { |
| 584 |
mClassTermClassAxiomSet->insert(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiomExp)); |
| 585 |
if (tellAxiom) { |
| 586 |
mClassTermClassAxiomHash->insertMulti(classTermExp,classAxiomExp); |
| 587 |
} |
| 588 |
} |
| 589 |
} |
| 590 |
} |
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
FOREACHHASHIT (CObjectPropertyAxiomExpression* objPropAxiomExp, bool tellAxiom, *mUpdateObjectPropertyAxiomHash) { |
| 597 |
CBuildExpression::ExpressionType expType = objPropAxiomExp->getType(); |
| 598 |
if (expType == CBuildExpression::BETEQUIVALENTOBJECTPROPERTIES) { |
| 599 |
// all associated properties has to be updated |
| 600 |
CEquivalentObjectPropertiesExpression* eqObjPropExp = (CEquivalentObjectPropertiesExpression*)objPropAxiomExp; |
| 601 |
FOREACHIT (CObjectPropertyTermExpression* objPropTermExp, *eqObjPropExp->getObjectPropertyTermExpressionList()) { |
| 602 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 603 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 604 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 605 |
if (tellAxiom) { |
| 606 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 607 |
} |
| 608 |
} |
| 609 |
} |
| 610 |
} else if (expType == CBuildExpression::BETDISJOINTOBJECTPROPERTIES) { |
| 611 |
mConstructFlags->setNonELConstructUsed(); |
| 612 |
// all associated properties has to be updated |
| 613 |
CDisjointObjectPropertiesExpression* eqObjPropExp = (CDisjointObjectPropertiesExpression*)objPropAxiomExp; |
| 614 |
FOREACHIT (CObjectPropertyTermExpression* objPropTermExp, *eqObjPropExp->getObjectPropertyTermExpressionList()) { |
| 615 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 616 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 617 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 618 |
if (tellAxiom) { |
| 619 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 620 |
} |
| 621 |
} |
| 622 |
} |
| 623 |
} else if (expType == CBuildExpression::BETSUBOBJECTPROPERTYOF) { |
| 624 |
CSubObjectPropertyOfExpression* subObjPropExp = (CSubObjectPropertyOfExpression*)objPropAxiomExp; |
| 625 |
FOREACHIT (CObjectPropertyTermExpression* objPropTermExp, *subObjPropExp->getSubObjectPropertyTermExpressionList()) { |
| 626 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 627 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 628 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 629 |
if (tellAxiom) { |
| 630 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 631 |
} |
| 632 |
} |
| 633 |
} |
| 634 |
if (subObjPropExp->getSubObjectPropertyTermExpressionList()->count() >= 2) { |
| 635 |
mConstructFlags->setComplexRoleUsed(); |
| 636 |
CObjectPropertyTermExpression* objPropTermExp = subObjPropExp->getSuperObjectPropertyTermExpression(); |
| 637 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 638 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 639 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 640 |
if (tellAxiom) { |
| 641 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 642 |
} |
| 643 |
} |
| 644 |
} |
| 645 |
} else if (expType == CBuildExpression::BETINVERSEOBJECTPROPERTIES) { |
| 646 |
mConstructFlags->setNonELConstructUsed(); |
| 647 |
// all associated properties has to be updated |
| 648 |
CInverseObjectPropertiesExpression* invObjPropExp = (CInverseObjectPropertiesExpression*)objPropAxiomExp; |
| 649 |
CObjectPropertyTermExpression* objPropTermExp1 = invObjPropExp->getFirstObjectPropertyTermExpression(); |
| 650 |
CObjectPropertyTermExpression* objPropTermExp2 = invObjPropExp->getSecondObjectPropertyTermExpression(); |
| 651 |
mNewBuildObjectRoleSet.insert(objPropTermExp1); |
| 652 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp1,objPropAxiomExp))) { |
| 653 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp1,objPropAxiomExp)); |
| 654 |
if (tellAxiom) { |
| 655 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp1,objPropAxiomExp); |
| 656 |
} |
| 657 |
} |
| 658 |
mNewBuildObjectRoleSet.insert(objPropTermExp2); |
| 659 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp2,objPropAxiomExp))) { |
| 660 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp2,objPropAxiomExp)); |
| 661 |
if (tellAxiom) { |
| 662 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp2,objPropAxiomExp); |
| 663 |
} |
| 664 |
} |
| 665 |
} else if (expType == CBuildExpression::BETFUNCTIONALOBJECTPROPERTY) { |
| 666 |
mConstructFlags->setNonELConstructUsed(); |
| 667 |
CFunctionalObjectPropertyExpression* funcObjPropExp = (CFunctionalObjectPropertyExpression*)objPropAxiomExp; |
| 668 |
CObjectPropertyTermExpression* objPropTermExp = funcObjPropExp->getFunctionalObjectPropertyExpression(); |
| 669 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 670 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 671 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 672 |
if (tellAxiom) { |
| 673 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 674 |
} |
| 675 |
} |
| 676 |
} else if (expType == CBuildExpression::BETINVERSEFUNCTIONALPROPERTY) { |
| 677 |
mConstructFlags->setNonELConstructUsed(); |
| 678 |
CInverseFunctionalObjectPropertyExpression* funcObjPropExp = (CInverseFunctionalObjectPropertyExpression*)objPropAxiomExp; |
| 679 |
CObjectPropertyTermExpression* objPropTermExp = funcObjPropExp->getInverseFunctionalObjectPropertyExpression(); |
| 680 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 681 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 682 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 683 |
if (tellAxiom) { |
| 684 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 685 |
} |
| 686 |
} |
| 687 |
} else if (expType == CBuildExpression::BETSYMMETRICPROPERTY) { |
| 688 |
mConstructFlags->setNonELConstructUsed(); |
| 689 |
CSymmetricObjectPropertyExpression* objPropExpAxiom = (CSymmetricObjectPropertyExpression*)objPropAxiomExp; |
| 690 |
CObjectPropertyTermExpression* objPropTermExp = objPropExpAxiom->getObjectPropertyTermExpression(); |
| 691 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 692 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 693 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 694 |
if (tellAxiom) { |
| 695 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 696 |
} |
| 697 |
} |
| 698 |
} else if (expType == CBuildExpression::BETASYMMETRICPROPERTY) { |
| 699 |
mConstructFlags->setNonELConstructUsed(); |
| 700 |
CAsymmetricObjectPropertyExpression* objPropExpAxiom = (CAsymmetricObjectPropertyExpression*)objPropAxiomExp; |
| 701 |
CObjectPropertyTermExpression* objPropTermExp = objPropExpAxiom->getObjectPropertyTermExpression(); |
| 702 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 703 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 704 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 705 |
if (tellAxiom) { |
| 706 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 707 |
} |
| 708 |
} |
| 709 |
} else if (expType == CBuildExpression::BETREFLEXIVEPROPERTY) { |
| 710 |
CReflexiveObjectPropertyExpression* objPropExpAxiom = (CReflexiveObjectPropertyExpression*)objPropAxiomExp; |
| 711 |
CObjectPropertyTermExpression* objPropTermExp = objPropExpAxiom->getObjectPropertyTermExpression(); |
| 712 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 713 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 714 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 715 |
if (tellAxiom) { |
| 716 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 717 |
} |
| 718 |
} |
| 719 |
} else if (expType == CBuildExpression::BETIRREFLEXIVEPROPERTY) { |
| 720 |
mConstructFlags->setNonELConstructUsed(); |
| 721 |
CIrreflexiveObjectPropertyExpression* objPropExpAxiom = (CIrreflexiveObjectPropertyExpression*)objPropAxiomExp; |
| 722 |
CObjectPropertyTermExpression* objPropTermExp = objPropExpAxiom->getObjectPropertyTermExpression(); |
| 723 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 724 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 725 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 726 |
if (tellAxiom) { |
| 727 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 728 |
} |
| 729 |
} |
| 730 |
} else if (expType == CBuildExpression::BETTRANSITIVEOBJECTPROPERTY) { |
| 731 |
mConstructFlags->setComplexRoleUsed(); |
| 732 |
CTransetiveObjectPropertyExpression* objPropExpAxiom = (CTransetiveObjectPropertyExpression*)objPropAxiomExp; |
| 733 |
CObjectPropertyTermExpression* objPropTermExp = objPropExpAxiom->getTransetivePropertyExpression(); |
| 734 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 735 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 736 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 737 |
if (tellAxiom) { |
| 738 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 739 |
} |
| 740 |
} |
| 741 |
} else if (expType == CBuildExpression::BETOBJECTPROPERTYDOMAIN) { |
| 742 |
CObjectPropertyDomainExpression* objPropExpAxiom = (CObjectPropertyDomainExpression*)objPropAxiomExp; |
| 743 |
CObjectPropertyTermExpression* objPropTermExp = objPropExpAxiom->getObjectPropertyTermExpression(); |
| 744 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 745 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 746 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 747 |
if (tellAxiom) { |
| 748 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 749 |
} |
| 750 |
} |
| 751 |
} else if (expType == CBuildExpression::BETOBJECTPROPERTYRANGE) { |
| 752 |
CObjectPropertyRangeExpression* objPropExpAxiom = (CObjectPropertyRangeExpression*)objPropAxiomExp; |
| 753 |
CObjectPropertyTermExpression* objPropTermExp = objPropExpAxiom->getObjectPropertyTermExpression(); |
| 754 |
mNewBuildObjectRoleSet.insert(objPropTermExp); |
| 755 |
if (!mObjPropTermObjPropAxiomSet->contains(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp))) { |
| 756 |
mObjPropTermObjPropAxiomSet->insert(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiomExp)); |
| 757 |
if (tellAxiom) { |
| 758 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp,objPropAxiomExp); |
| 759 |
} |
| 760 |
} |
| 761 |
} |
| 762 |
} |
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
FOREACHHASHIT (CDataPropertyAxiomExpression* dataPropAxiomExp, bool tellAxiom, *mUpdateDataPropertyAxiomHash) { |
| 769 |
CBuildExpression::ExpressionType expType = dataPropAxiomExp->getType(); |
| 770 |
if (expType == CBuildExpression::BETEQUIVALENTDATAPROPERTIES) { |
| 771 |
// all associated properties has to be updated |
| 772 |
CEquivalentDataPropertiesExpression* eqDataPropExp = (CEquivalentDataPropertiesExpression*)dataPropAxiomExp; |
| 773 |
FOREACHIT (CDataPropertyTermExpression* dataPropTermExp, *eqDataPropExp->getDataPropertyTermExpressionList()) { |
| 774 |
mNewBuildDataRoleSet.insert(dataPropTermExp); |
| 775 |
if (!mDataPropTermDataPropAxiomSet->contains(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp))) { |
| 776 |
mDataPropTermDataPropAxiomSet->insert(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp)); |
| 777 |
if (tellAxiom) { |
| 778 |
mDataPropTermDataPropAxiomHash->insertMulti(dataPropTermExp,dataPropAxiomExp); |
| 779 |
} |
| 780 |
} |
| 781 |
} |
| 782 |
} else if (expType == CBuildExpression::BETDISJOINTDATAPROPERTIES) { |
| 783 |
mConstructFlags->setNonELConstructUsed(); |
| 784 |
// all associated properties has to be updated |
| 785 |
CDisjointDataPropertiesExpression* eqDisjPropExp = (CDisjointDataPropertiesExpression*)dataPropAxiomExp; |
| 786 |
FOREACHIT (CDataPropertyTermExpression* dataPropTermExp, *eqDisjPropExp->getDataPropertyTermExpressionList()) { |
| 787 |
mNewBuildDataRoleSet.insert(dataPropTermExp); |
| 788 |
if (!mDataPropTermDataPropAxiomSet->contains(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp))) { |
| 789 |
mDataPropTermDataPropAxiomSet->insert(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp)); |
| 790 |
if (tellAxiom) { |
| 791 |
mDataPropTermDataPropAxiomHash->insertMulti(dataPropTermExp,dataPropAxiomExp); |
| 792 |
} |
| 793 |
} |
| 794 |
} |
| 795 |
} else if (expType == CBuildExpression::BETSUBDATAPROPERTYOF) { |
| 796 |
CSubDataPropertyOfExpression* subDataPropExp = (CSubDataPropertyOfExpression*)dataPropAxiomExp; |
| 797 |
CDataPropertyTermExpression* dataPropTermExp = subDataPropExp->getSubDataPropertyTermExpression(); |
| 798 |
mNewBuildDataRoleSet.insert(dataPropTermExp); |
| 799 |
if (!mDataPropTermDataPropAxiomSet->contains(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp))) { |
| 800 |
mDataPropTermDataPropAxiomSet->insert(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp)); |
| 801 |
if (tellAxiom) { |
| 802 |
mDataPropTermDataPropAxiomHash->insertMulti(dataPropTermExp,dataPropAxiomExp); |
| 803 |
} |
| 804 |
} |
| 805 |
|
| 806 |
} else if (expType == CBuildExpression::BETFUNCTIONALDATAPROPERTY) { |
| 807 |
mConstructFlags->setNonELConstructUsed(); |
| 808 |
CFunctionalDataPropertyExpression* funcDataPropExp = (CFunctionalDataPropertyExpression*)dataPropAxiomExp; |
| 809 |
CDataPropertyTermExpression* dataPropTermExp = funcDataPropExp->getFunctionalDataPropertyExpression(); |
| 810 |
mNewBuildDataRoleSet.insert(dataPropTermExp); |
| 811 |
if (!mDataPropTermDataPropAxiomSet->contains(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp))) { |
| 812 |
mDataPropTermDataPropAxiomSet->insert(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp)); |
| 813 |
if (tellAxiom) { |
| 814 |
mDataPropTermDataPropAxiomHash->insertMulti(dataPropTermExp,dataPropAxiomExp); |
| 815 |
} |
| 816 |
} |
| 817 |
|
| 818 |
} else if (expType == CBuildExpression::BETDATAPROPERTYDOMAIN) { |
| 819 |
CDataPropertyDomainExpression* dataPropExpAxiom = (CDataPropertyDomainExpression*)dataPropAxiomExp; |
| 820 |
CDataPropertyTermExpression* dataPropTermExp = dataPropExpAxiom->getDataPropertyTermExpression(); |
| 821 |
mNewBuildDataRoleSet.insert(dataPropTermExp); |
| 822 |
if (!mDataPropTermDataPropAxiomSet->contains(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp))) { |
| 823 |
mDataPropTermDataPropAxiomSet->insert(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp)); |
| 824 |
if (tellAxiom) { |
| 825 |
mDataPropTermDataPropAxiomHash->insertMulti(dataPropTermExp,dataPropAxiomExp); |
| 826 |
} |
| 827 |
} |
| 828 |
} else if (expType == CBuildExpression::BETDATAPROPERTYRANGE) { |
| 829 |
CDataPropertyRangeExpression* dataPropExpAxiom = (CDataPropertyRangeExpression*)dataPropAxiomExp; |
| 830 |
CDataPropertyTermExpression* dataPropTermExp = dataPropExpAxiom->getDataPropertyTermExpression(); |
| 831 |
mNewBuildDataRoleSet.insert(dataPropTermExp); |
| 832 |
if (!mDataPropTermDataPropAxiomSet->contains(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp))) { |
| 833 |
mDataPropTermDataPropAxiomSet->insert(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiomExp)); |
| 834 |
if (tellAxiom) { |
| 835 |
mDataPropTermDataPropAxiomHash->insertMulti(dataPropTermExp,dataPropAxiomExp); |
| 836 |
} |
| 837 |
} |
| 838 |
} |
| 839 |
} |
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
while (mLastBuildedConcept < mBuildConceptList->size() || mLastBuildedObjectRole < mBuildObjectRoleList->size() || mLastBuildedDataRole < mBuildDataRoleList->size() || mLastBuildedIndividual < mBuildIndividualList->size() |
| 844 |
|| mLastBuildedDatatype < mBuildDatatypeList->size() || mLastBuildedDataRange < mBuildDataRangeList->size() |
| 845 |
|| !mNewBuildConceptSet.isEmpty() || !mNewBuildObjectRoleSet.isEmpty() || !mNewBuildDataRoleSet.isEmpty() || !mNewBuildIndividualSet.isEmpty() || !mNewBuildDataRangeSet.isEmpty() || !mNewBuildDatatypeSet.isEmpty()) { |
| 846 |
|
| 847 |
|
| 848 |
while (mLastBuildedConcept < mBuildConceptList->size()) { |
| 849 |
mNewBuildConceptSet.insert((*mBuildConceptList)[mLastBuildedConcept++]); |
| 850 |
} |
| 851 |
while (mLastBuildedObjectRole < mBuildObjectRoleList->size()) { |
| 852 |
mNewBuildObjectRoleSet.insert((*mBuildObjectRoleList)[mLastBuildedObjectRole++]); |
| 853 |
} |
| 854 |
while (mLastBuildedDataRole < mBuildDataRoleList->size()) { |
| 855 |
mNewBuildDataRoleSet.insert((*mBuildDataRoleList)[mLastBuildedDataRole++]); |
| 856 |
} |
| 857 |
while (mLastBuildedIndividual < mBuildIndividualList->size()) { |
| 858 |
mNewBuildIndividualSet.insert((*mBuildIndividualList)[mLastBuildedIndividual++]); |
| 859 |
} |
| 860 |
|
| 861 |
while (mLastBuildedDatatype < mBuildDatatypeList->size()) { |
| 862 |
mNewBuildDatatypeSet.insert((*mBuildDatatypeList)[mLastBuildedDatatype++]); |
| 863 |
} |
| 864 |
|
| 865 |
while (mLastBuildedDataRange < mBuildDataRangeList->size()) { |
| 866 |
mNewBuildDataRangeSet.insert((*mBuildDataRangeList)[mLastBuildedDataRange++]); |
| 867 |
} |
| 868 |
|
| 869 |
// construct concepts, roles, individuals |
| 870 |
// build all class expressions |
| 871 |
|
| 872 |
while (!mNewBuildObjectRoleSet.isEmpty()) { |
| 873 |
mBuildingObjectRoleSet = mNewBuildObjectRoleSet; |
| 874 |
mNewBuildObjectRoleSet.clear(); |
| 875 |
|
| 876 |
FOREACHIT (CObjectPropertyTermExpression* objTermExp, mBuildingObjectRoleSet) { |
| 877 |
if (!mNewBuildedObjectRoleSet.contains(objTermExp)) { |
| 878 |
mNewBuildedObjectRoleSet.insert(objTermExp); |
| 879 |
|
| 880 |
// build role for object property axioms |
| 881 |
buildObjectPropertyRole(objTermExp); |
| 882 |
} |
| 883 |
} |
| 884 |
} |
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
while (!mNewBuildDataRoleSet.isEmpty()) { |
| 889 |
mBuildingDataRoleSet = mNewBuildDataRoleSet; |
| 890 |
mNewBuildDataRoleSet.clear(); |
| 891 |
|
| 892 |
FOREACHIT (CDataPropertyTermExpression* dataTermExp, mBuildingDataRoleSet) { |
| 893 |
if (!mNewBuildedDataRoleSet.contains(dataTermExp)) { |
| 894 |
mNewBuildedDataRoleSet.insert(dataTermExp); |
| 895 |
|
| 896 |
// build role for data property axioms |
| 897 |
buildDataPropertyRole(dataTermExp); |
| 898 |
} |
| 899 |
} |
| 900 |
} |
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
while (!mNewBuildIndividualSet.isEmpty()) { |
| 908 |
mBuildingIndividualSet = mNewBuildIndividualSet; |
| 909 |
mNewBuildIndividualSet.clear(); |
| 910 |
|
| 911 |
FOREACHIT (CIndividualTermExpression* indiTermExp, mBuildingIndividualSet) { |
| 912 |
if (!mNewBuildedIndividualSet.contains(indiTermExp)) { |
| 913 |
mNewBuildedIndividualSet.insert(indiTermExp); |
| 914 |
|
| 915 |
buildIndividualIndi(indiTermExp); |
| 916 |
|
| 917 |
} |
| 918 |
} |
| 919 |
|
| 920 |
} |
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
while (!mNewBuildDatatypeSet.isEmpty()) { |
| 926 |
mBuildingDatatypeSet = mNewBuildDatatypeSet; |
| 927 |
mNewBuildDatatypeSet.clear(); |
| 928 |
|
| 929 |
FOREACHIT (CDatatypeExpression* datatypeExp, mBuildingDatatypeSet) { |
| 930 |
if (!mNewBuildedDatatypeSet.contains(datatypeExp)) { |
| 931 |
mNewBuildedDatatypeSet.insert(datatypeExp); |
| 932 |
|
| 933 |
// build datatype |
| 934 |
buildDatatype(datatypeExp); |
| 935 |
} |
| 936 |
} |
| 937 |
} |
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
while (!mNewBuildDataRangeSet.isEmpty()) { |
| 943 |
mBuildingDataRangeSet = mNewBuildDataRangeSet; |
| 944 |
mNewBuildDataRangeSet.clear(); |
| 945 |
|
| 946 |
FOREACHIT (CDataRangeTermExpression* dataRangeExp, mBuildingDataRangeSet) { |
| 947 |
if (!mNewBuildedDataRangeSet.contains(dataRangeExp)) { |
| 948 |
mNewBuildedDataRangeSet.insert(dataRangeExp); |
| 949 |
|
| 950 |
CBuildExpression::ExpressionType expType = dataRangeExp->getType(); |
| 951 |
CConcept* concept = getConceptForDataRangeTerm(dataRangeExp,true); |
| 952 |
|
| 953 |
if (expType == CBuildExpression::BETDATATYPE) { |
| 954 |
mConstructFlags->setNonELConstructUsed(); |
| 955 |
CDatatypeExpression* datatypeExp = (CDatatypeExpression*)dataRangeExp; |
| 956 |
CDatatype* datatype = getDatatypeForDatatypeExpression(datatypeExp); |
| 957 |
concept->setOperatorCode(CCDATATYPE); |
| 958 |
concept->setDatatype(datatype); |
| 959 |
|
| 960 |
} else if (expType == CBuildExpression::BETDATALITERAL) { |
| 961 |
mConstructFlags->setNonELConstructUsed(); |
| 962 |
CDataLiteralExpression* litExp = (CDataLiteralExpression*)dataRangeExp; |
| 963 |
CDataLiteral* dataLiteral = getDataLiteralForLiteralExpression(litExp); |
| 964 |
concept->setOperatorCode(CCDATALITERAL); |
| 965 |
concept->setDataLiteral(dataLiteral); |
| 966 |
} else if (expType == CBuildExpression::BETDATACOMPLEMENTOF) { |
| 967 |
CDataComplementOfExpression* dataExp = (CDataComplementOfExpression*)dataRangeExp; |
| 968 |
mConstructFlags->setNonELConstructUsed(); |
| 969 |
CDataRangeTermExpression* opDataRangeTermExp = dataExp->getDataRangeTermExpression(); |
| 970 |
setConceptOperandsFromDataRangeTerms(concept,opDataRangeTermExp); |
| 971 |
concept->setOperatorCode(CCNOT); |
| 972 |
} else if (expType == CBuildExpression::BETDATAUNIONOF) { |
| 973 |
CDataUnionOfExpression* dataExp = (CDataUnionOfExpression*)dataRangeExp; |
| 974 |
mConstructFlags->setNonELConstructUsed(); |
| 975 |
CEXPRESSIONLIST<CDataRangeTermExpression*>* opDataRangeTermExpList = dataExp->getDataRangeTermExpressionList(); |
| 976 |
setConceptOperandsFromDataRangeTerms(concept,opDataRangeTermExpList); |
| 977 |
concept->setOperatorCode(CCOR); |
| 978 |
} else if (expType == CBuildExpression::BETDATAONEOF) { |
| 979 |
CDataOneOfExpression* dataExp = (CDataOneOfExpression*)dataRangeExp; |
| 980 |
mConstructFlags->setNonELConstructUsed(); |
| 981 |
CEXPRESSIONLIST<CDataRangeTermExpression*>* opDataRangeTermExpList = dataExp->getDataRangeTermExpressionList(); |
| 982 |
setConceptOperandsFromDataRangeTerms(concept,opDataRangeTermExpList); |
| 983 |
concept->setOperatorCode(CCOR); |
| 984 |
} else if (expType == CBuildExpression::BETDATAINTERSECTIONOF) { |
| 985 |
CDataIntersectionOfExpression* dataExp = (CDataIntersectionOfExpression*)dataRangeExp; |
| 986 |
CEXPRESSIONLIST<CDataRangeTermExpression*>* opDataRangeTermExpList = dataExp->getDataRangeTermExpressionList(); |
| 987 |
setConceptOperandsFromDataRangeTerms(concept,opDataRangeTermExpList); |
| 988 |
concept->setOperatorCode(CCAND); |
| 989 |
} else if (expType == CBuildExpression::BETDATATYPERESTRICTION) { |
| 990 |
mConstructFlags->setNonELConstructUsed(); |
| 991 |
CDatatypeRestrictionExpression* dataExp = (CDatatypeRestrictionExpression*)dataRangeExp; |
| 992 |
CEXPRESSIONLIST<CDataFacetRestrictionExpression*>* facetExpList = dataExp->getDataFacetRestrictionExpressionList(); |
| 993 |
CDatatypeExpression* datatypeExpression = dataExp->getDatatypeExpression(); |
| 994 |
if (facetExpList->count() == 1) { |
| 995 |
CDataFacetRestrictionExpression* facetRestrictionExp = facetExpList->first(); |
| 996 |
CDataLiteralExpression* litExp = facetRestrictionExp->getDataLiteralExpression(); |
| 997 |
CDataFacetExpression* facetExp = facetRestrictionExp->getDataFacetExpression(); |
| 998 |
CDataLiteral* dataLiteral = getDataLiteralForLiteralExpression(litExp); |
| 999 |
CDatatype* datatype = getDatatypeForDatatypeExpression(datatypeExpression); |
| 1000 |
cint64 facetDataCode = 0; |
| 1001 |
const QString& facetIRI = facetExp->getName(); |
| 1002 |
if (facetIRI == PREFIX_MIN_INCLUSIVE_FACET) { |
| 1003 |
facetDataCode = CDFC_MIN_INCLUSIVE; |
| 1004 |
} else if (facetIRI == PREFIX_MIN_EXCLUSIVE_FACET) { |
| 1005 |
facetDataCode = CDFC_MIN_EXCLUSIVE; |
| 1006 |
} else if (facetIRI == PREFIX_MAX_INCLUSIVE_FACET) { |
| 1007 |
facetDataCode = CDFC_MAX_INCLUSIVE; |
| 1008 |
} else if (facetIRI == PREFIX_MAX_EXCLUSIVE_FACET) { |
| 1009 |
facetDataCode = CDFC_MAX_EXCLUSIVE; |
| 1010 |
} else if (facetIRI == PREFIX_MAX_LENGTH_FACET) { |
| 1011 |
facetDataCode = CDFC_MAX_LENGTH_INCLUSIVE; |
| 1012 |
} else if (facetIRI == PREFIX_MIN_LENGTH_FACET) { |
| 1013 |
facetDataCode = CDFC_MIN_LENGTH_INCLUSIVE; |
| 1014 |
} else if (facetIRI == PREFIX_LENGTH_FACET) { |
| 1015 |
facetDataCode = CDFC_LENGTH; |
| 1016 |
} else if (facetIRI == PREFIX_PATTERN_FACET) { |
| 1017 |
facetDataCode = CDFC_PATTERN; |
| 1018 |
} else if (facetIRI == PREFIX_LANGUAGE_RANGE_FACET) { |
| 1019 |
facetDataCode = CDFC_LANGUAGE_RANGE; |
| 1020 |
} |
| 1021 |
concept->setParameter(facetDataCode); |
| 1022 |
concept->setDatatype(datatype); |
| 1023 |
concept->setDataLiteral(dataLiteral); |
| 1024 |
concept->setOperatorCode(CCDATARESTRICTION); |
| 1025 |
} else { |
| 1026 |
FOREACHIT (CDataFacetRestrictionExpression* facetExp, *facetExpList) { |
| 1027 |
CDatatypeRestrictionExpression* separatedDataExp = getDatatypeRestriction(datatypeExpression,CEXPRESSIONLIST<CDataFacetRestrictionExpression*>()<<facetExp); |
| 1028 |
setConceptOperandsFromDataRangeTerms(concept,separatedDataExp); |
| 1029 |
} |
| 1030 |
concept->setOperatorCode(CCAND); |
| 1031 |
} |
| 1032 |
} |
| 1033 |
|
| 1034 |
} |
| 1035 |
} |
| 1036 |
} |
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
// construct concepts, roles, individuals |
| 1043 |
// build all class expressions |
| 1044 |
|
| 1045 |
while (!mNewBuildConceptSet.isEmpty()) { |
| 1046 |
mBuildingConceptSet = mNewBuildConceptSet; |
| 1047 |
mNewBuildConceptSet.clear(); |
| 1048 |
|
| 1049 |
FOREACHIT (CClassTermExpression* classTermExp, mBuildingConceptSet) { |
| 1050 |
if (!mNewBuildedConceptSet.contains(classTermExp)) { |
| 1051 |
mNewBuildedConceptSet.insert(classTermExp); |
| 1052 |
CBuildExpression::ExpressionType expType = classTermExp->getType(); |
| 1053 |
CConcept* concept = getConceptForClassTerm(classTermExp,true); |
| 1054 |
if (expType == CBuildExpression::BETOBJECTALLVALUEFROM) { |
| 1055 |
mConstructFlags->setNonELConstructUsed(); |
| 1056 |
CObjectAllValuesFromExpression* objExp = (CObjectAllValuesFromExpression*)classTermExp; |
| 1057 |
CObjectPropertyTermExpression* opObjPropExp = objExp->getObjectPropertyTermExpression(); |
| 1058 |
setConceptRoleFromObjectPropertyTerm(concept,opObjPropExp); |
| 1059 |
CClassTermExpression* opClassExp = objExp->getClassTermExpression(); |
| 1060 |
setConceptOperandsFromClassTerms(concept,opClassExp); |
| 1061 |
concept->setOperatorCode(CCALL); |
| 1062 |
} else if (expType == CBuildExpression::BETOBJECTSOMEVALUEFROM) { |
| 1063 |
CObjectSomeValuesFromExpression* objExp = (CObjectSomeValuesFromExpression*)classTermExp; |
| 1064 |
CObjectPropertyTermExpression* opObjPropExp = objExp->getObjectPropertyTermExpression(); |
| 1065 |
setConceptRoleFromObjectPropertyTerm(concept,opObjPropExp); |
| 1066 |
CClassTermExpression* opClassExp = objExp->getClassTermExpression(); |
| 1067 |
if (opClassExp == nullptr) { |
| 1068 |
opClassExp = mTopClassExpression; |
| 1069 |
} |
| 1070 |
setConceptOperandsFromClassTerms(concept,opClassExp); |
| 1071 |
concept->setOperatorCode(CCSOME); |
| 1072 |
|
| 1073 |
} else if (expType == CBuildExpression::BETDATASOMEVALUEFROM) { |
| 1074 |
CDataSomeValuesFromExpression* dataSomeValueExp = (CDataSomeValuesFromExpression*)classTermExp; |
| 1075 |
CDataPropertyTermExpression* dataPropPropExp = dataSomeValueExp->getDataPropertyTermExpression(); |
| 1076 |
setConceptRoleFromDataPropertyTerm(concept,dataPropPropExp); |
| 1077 |
CDataRangeTermExpression* dataRangeTermExp = dataSomeValueExp->getDataRangeTermExpression(); |
| 1078 |
if (dataRangeTermExp == nullptr) { |
| 1079 |
dataRangeTermExp = mTopDataRangeExpression; |
| 1080 |
} |
| 1081 |
setConceptOperandsFromDataRangeTerms(concept,dataRangeTermExp); |
| 1082 |
concept->setOperatorCode(CCSOME); |
| 1083 |
} else if (expType == CBuildExpression::BETDATAALLVALUEFROM) { |
| 1084 |
CDataAllValuesFromExpression* dataAllValueExp = (CDataAllValuesFromExpression*)classTermExp; |
| 1085 |
CDataPropertyTermExpression* dataPropPropExp = dataAllValueExp->getDataPropertyTermExpression(); |
| 1086 |
setConceptRoleFromDataPropertyTerm(concept,dataPropPropExp); |
| 1087 |
CDataRangeTermExpression* dataRangeTermExp = dataAllValueExp->getDataRangeTermExpression(); |
| 1088 |
setConceptOperandsFromDataRangeTerms(concept,dataRangeTermExp); |
| 1089 |
concept->setOperatorCode(CCALL); |
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
} else if (expType == CBuildExpression::BETDATAMINCARDINALITY) { |
| 1095 |
CDataMinCardinalityExpression* dataExp = (CDataMinCardinalityExpression*)classTermExp; |
| 1096 |
CDataPropertyTermExpression* opDataPropExp = dataExp->getDataPropertyTermExpression(); |
| 1097 |
setConceptRoleFromDataPropertyTerm(concept,opDataPropExp); |
| 1098 |
cint64 cardinality = dataExp->getCardinality(); |
| 1099 |
CDataRangeTermExpression* opDataRangeTermExp = dataExp->getDataRangeTermExpression(); |
| 1100 |
if (cardinality == 1) { |
| 1101 |
if (opDataRangeTermExp == nullptr) { |
| 1102 |
opDataRangeTermExp = mTopDataRangeExpression; |
| 1103 |
} |
| 1104 |
setConceptOperandsFromDataRangeTerms(concept,opDataRangeTermExp); |
| 1105 |
concept->setOperatorCode(CCSOME); |
| 1106 |
} else { |
| 1107 |
if (opDataRangeTermExp != mTopDataRangeExpression) { |
| 1108 |
setConceptOperandsFromDataRangeTerms(concept,opDataRangeTermExp); |
| 1109 |
} |
| 1110 |
mConstructFlags->setNonELConstructUsed(); |
| 1111 |
concept->setParameter(cardinality); |
| 1112 |
concept->setOperatorCode(CCATLEAST); |
| 1113 |
} |
| 1114 |
} else if (expType == CBuildExpression::BETDATAMAXCARDINALITY) { |
| 1115 |
mConstructFlags->setNonELConstructUsed(); |
| 1116 |
CDataMaxCardinalityExpression* dataExp = (CDataMaxCardinalityExpression*)classTermExp; |
| 1117 |
CDataPropertyTermExpression* opDataPropExp = dataExp->getDataPropertyTermExpression(); |
| 1118 |
setConceptRoleFromDataPropertyTerm(concept,opDataPropExp); |
| 1119 |
CDataRangeTermExpression* opDataRangeTermExp = dataExp->getDataRangeTermExpression(); |
| 1120 |
cint64 cardinality = dataExp->getCardinality(); |
| 1121 |
if (cardinality == 0) { |
| 1122 |
if (opDataRangeTermExp == nullptr) { |
| 1123 |
opDataRangeTermExp = mTopDataRangeExpression; |
| 1124 |
} |
| 1125 |
CDataComplementOfExpression* compExp = getDataComplementOf(opDataRangeTermExp); |
| 1126 |
setConceptOperandsFromDataRangeTerms(concept,compExp); |
| 1127 |
concept->setOperatorCode(CCALL); |
| 1128 |
} else { |
| 1129 |
if (opDataRangeTermExp != mTopDataRangeExpression) { |
| 1130 |
setConceptOperandsFromDataRangeTerms(concept,opDataRangeTermExp); |
| 1131 |
} |
| 1132 |
concept->setParameter(cardinality); |
| 1133 |
concept->setOperatorCode(CCATMOST); |
| 1134 |
} |
| 1135 |
} else if (expType == CBuildExpression::BETDATAEXACTCARDINALITY) { |
| 1136 |
mConstructFlags->setNonELConstructUsed(); |
| 1137 |
CDataExactCardinalityExpression* dataExp = (CDataExactCardinalityExpression*)classTermExp; |
| 1138 |
CDataPropertyTermExpression* opDataPropExp = dataExp->getDataPropertyTermExpression(); |
| 1139 |
CDataRangeTermExpression* opDataRangeTermExp = dataExp->getDataRangeTermExpression(); |
| 1140 |
cint64 cardinality = dataExp->getCardinality(); |
| 1141 |
CDataMaxCardinalityExpression* maxCardExp = getDataMaxCardinality(opDataPropExp,opDataRangeTermExp,cardinality); |
| 1142 |
CDataMinCardinalityExpression* minCardExp = getDataMinCardinality(opDataPropExp,opDataRangeTermExp,cardinality); |
| 1143 |
CObjectIntersectionOfExpression* maxMinIntersect = getObjectIntersectionOf(CEXPRESSIONLIST<CClassTermExpression*>()<<maxCardExp<<minCardExp); |
| 1144 |
setConceptRoleFromDataPropertyTerm(concept,opDataPropExp); |
| 1145 |
setConceptOperandsFromClassTerms(concept,maxMinIntersect); |
| 1146 |
concept->setParameter(cardinality); |
| 1147 |
concept->setOperatorCode(CCAND); |
| 1148 |
|
| 1149 |
} else if (expType == CBuildExpression::BETDATAHASVALUE) { |
| 1150 |
mConstructFlags->setNonELConstructUsed(); |
| 1151 |
CDataHasValueExpression* dataExp = (CDataHasValueExpression*)classTermExp; |
| 1152 |
CDataPropertyTermExpression* opDataPropExp = dataExp->getDataPropertyTermExpression(); |
| 1153 |
CDataRangeTermExpression* dataRangeExp = dataExp->getDataRangeTermExpression(); |
| 1154 |
setConceptRoleFromDataPropertyTerm(concept,opDataPropExp); |
| 1155 |
setConceptOperandsFromDataRangeTerms(concept,dataRangeExp); |
| 1156 |
concept->setOperatorCode(CCSOME); |
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
} else if (expType == CBuildExpression::BETOBJECTMINCARDINALITY) { |
| 1163 |
CObjectMinCardinalityExpression* objExp = (CObjectMinCardinalityExpression*)classTermExp; |
| 1164 |
CObjectPropertyTermExpression* opObjPropExp = objExp->getObjectPropertyTermExpression(); |
| 1165 |
setConceptRoleFromObjectPropertyTerm(concept,opObjPropExp); |
| 1166 |
cint64 cardinality = objExp->getCardinality(); |
| 1167 |
CClassTermExpression* opClassExp = objExp->getClassTermExpression(); |
| 1168 |
if (cardinality == 1) { |
| 1169 |
if (opClassExp == nullptr) { |
| 1170 |
opClassExp = mTopClassExpression; |
| 1171 |
} |
| 1172 |
setConceptOperandsFromClassTerms(concept,opClassExp); |
| 1173 |
concept->setOperatorCode(CCSOME); |
| 1174 |
} else { |
| 1175 |
if (opClassExp != mTopClassExpression) { |
| 1176 |
setConceptOperandsFromClassTerms(concept,opClassExp); |
| 1177 |
} |
| 1178 |
mConstructFlags->setNonELConstructUsed(); |
| 1179 |
concept->setParameter(cardinality); |
| 1180 |
concept->setOperatorCode(CCATLEAST); |
| 1181 |
} |
| 1182 |
} else if (expType == CBuildExpression::BETOBJECTMAXCARDINALITY) { |
| 1183 |
mConstructFlags->setNonELConstructUsed(); |
| 1184 |
CObjectMaxCardinalityExpression* objExp = (CObjectMaxCardinalityExpression*)classTermExp; |
| 1185 |
CObjectPropertyTermExpression* opObjPropExp = objExp->getObjectPropertyTermExpression(); |
| 1186 |
setConceptRoleFromObjectPropertyTerm(concept,opObjPropExp); |
| 1187 |
CClassTermExpression* opClassExp = objExp->getClassTermExpression(); |
| 1188 |
cint64 cardinality = objExp->getCardinality(); |
| 1189 |
if (cardinality == 0) { |
| 1190 |
if (opClassExp == nullptr) { |
| 1191 |
opClassExp = mTopClassExpression; |
| 1192 |
} |
| 1193 |
CObjectComplementOfExpression* compExp = getObjectComplementOf(opClassExp); |
| 1194 |
setConceptOperandsFromClassTerms(concept,compExp); |
| 1195 |
concept->setOperatorCode(CCALL); |
| 1196 |
} else { |
| 1197 |
if (opClassExp != mTopClassExpression) { |
| 1198 |
setConceptOperandsFromClassTerms(concept,opClassExp); |
| 1199 |
} |
| 1200 |
concept->setParameter(cardinality); |
| 1201 |
concept->setOperatorCode(CCATMOST); |
| 1202 |
} |
| 1203 |
} else if (expType == CBuildExpression::BETOBJECTEXACTLYCARDINALITY) { |
| 1204 |
mConstructFlags->setNonELConstructUsed(); |
| 1205 |
CObjectExactlyCardinalityExpression* objExp = (CObjectExactlyCardinalityExpression*)classTermExp; |
| 1206 |
CObjectPropertyTermExpression* opObjPropExp = objExp->getObjectPropertyTermExpression(); |
| 1207 |
CClassTermExpression* opClassExp = objExp->getClassTermExpression(); |
| 1208 |
cint64 cardinality = objExp->getCardinality(); |
| 1209 |
CObjectMaxCardinalityExpression* maxCardExp = getObjectMaxCardinality(opObjPropExp,opClassExp,cardinality); |
| 1210 |
CObjectMinCardinalityExpression* minCardExp = getObjectMinCardinality(opObjPropExp,opClassExp,cardinality); |
| 1211 |
CObjectIntersectionOfExpression* maxMinIntersect = getObjectIntersectionOf(CEXPRESSIONLIST<CClassTermExpression*>()<<maxCardExp<<minCardExp); |
| 1212 |
setConceptRoleFromObjectPropertyTerm(concept,opObjPropExp); |
| 1213 |
setConceptOperandsFromClassTerms(concept,maxMinIntersect); |
| 1214 |
concept->setParameter(cardinality); |
| 1215 |
concept->setOperatorCode(CCAND); |
| 1216 |
} else if (expType == CBuildExpression::BETOBJECTCOMPLEMENTOF) { |
| 1217 |
CObjectComplementOfExpression* objExp = (CObjectComplementOfExpression*)classTermExp; |
| 1218 |
if (!mConstructFlags->isNonELConstructUsed()) { |
| 1219 |
if (!mELExceptionExpressionSet.contains(objExp)) { |
| 1220 |
mConstructFlags->setNonELConstructUsed(); |
| 1221 |
} |
| 1222 |
} |
| 1223 |
CClassTermExpression* opClassExp = objExp->getClassTermExpression(); |
| 1224 |
setConceptOperandsFromClassTerms(concept,opClassExp); |
| 1225 |
concept->setOperatorCode(CCNOT); |
| 1226 |
} else if (expType == CBuildExpression::BETOBJECTUNION) { |
| 1227 |
CObjectUnionOfExpression* objExp = (CObjectUnionOfExpression*)classTermExp; |
| 1228 |
if (!mConstructFlags->isNonELConstructUsed()) { |
| 1229 |
if (!mELExceptionExpressionSet.contains(objExp)) { |
| 1230 |
mConstructFlags->setNonELConstructUsed(); |
| 1231 |
} |
| 1232 |
} |
| 1233 |
CEXPRESSIONLIST<CClassTermExpression*>* opClassExpList = objExp->getClassTermExpressionList(); |
| 1234 |
setConceptOperandsFromClassTerms(concept,opClassExpList); |
| 1235 |
concept->setOperatorCode(CCOR); |
| 1236 |
} else if (expType == CBuildExpression::BETOBJECTINTERSECTION) { |
| 1237 |
CObjectIntersectionOfExpression* objExp = (CObjectIntersectionOfExpression*)classTermExp; |
| 1238 |
CEXPRESSIONLIST<CClassTermExpression*>* opClassExpList = objExp->getClassTermExpressionList(); |
| 1239 |
setConceptOperandsFromClassTerms(concept,opClassExpList); |
| 1240 |
concept->setOperatorCode(CCAND); |
| 1241 |
} else if (expType == CBuildExpression::BETOBJECTHASVALUE) { |
| 1242 |
mConstructFlags->setNonELConstructUsed(); |
| 1243 |
CObjectHasValueExpression* objExp = (CObjectHasValueExpression*)classTermExp; |
| 1244 |
CObjectPropertyTermExpression* opObjPropExp = objExp->getObjectPropertyTermExpression(); |
| 1245 |
CIndividualTermExpression* indiExp = objExp->getIndividualTermExpression(); |
| 1246 |
setConceptRoleFromObjectPropertyTerm(concept,opObjPropExp); |
| 1247 |
setConceptIndividualFromIndividualTerm(concept,indiExp); |
| 1248 |
concept->setOperatorCode(CCVALUE); |
| 1249 |
} else if (expType == CBuildExpression::BETOBJECTHASSELF) { |
| 1250 |
mConstructFlags->setNonELConstructUsed(); |
| 1251 |
CObjectHasSelfExpression* objExp = (CObjectHasSelfExpression*)classTermExp; |
| 1252 |
CObjectPropertyTermExpression* opObjPropExp = objExp->getObjectPropertyTermExpression(); |
| 1253 |
setConceptRoleFromObjectPropertyTerm(concept,opObjPropExp); |
| 1254 |
concept->setOperatorCode(CCSELF); |
| 1255 |
} else if (expType == CBuildExpression::BETNOMINALINDIVIDUALVARIABLE) { |
| 1256 |
mConstructFlags->setNonELConstructUsed(); |
| 1257 |
mConstructFlags->setNominalSchemaUsed(); |
| 1258 |
mNominalConceptCreationRequired = true; |
| 1259 |
CObjectIndividualVariableExpression* objExp = (CObjectIndividualVariableExpression*)classTermExp; |
| 1260 |
cint64 indiVarID = getIndividualVariableID(concept,objExp); |
| 1261 |
concept->setParameter(indiVarID); |
| 1262 |
concept->setOperatorCode(CCNOMVAR); |
| 1263 |
} else if (expType == CBuildExpression::BETOBJECTONEOF) { |
| 1264 |
mConstructFlags->setNonELConstructUsed(); |
| 1265 |
CObjectOneOfExpression* objExp = (CObjectOneOfExpression*)classTermExp; |
| 1266 |
CEXPRESSIONLIST<CIndividualTermExpression*>* indiExpList = objExp->getIndividualTermExpressionList(); |
| 1267 |
if (indiExpList->count() == 1) { |
| 1268 |
CIndividualTermExpression* indiTermExp = indiExpList->first(); |
| 1269 |
concept->setOperatorCode(CCNOMINAL); |
| 1270 |
setConceptNominalIndividualFromIndividualTerm(concept,indiTermExp); |
| 1271 |
} else { |
| 1272 |
CEXPRESSIONLIST<CClassTermExpression*> nominalClassTermList; |
| 1273 |
FOREACHIT (CIndividualTermExpression* indiTermExp, *indiExpList) { |
| 1274 |
nominalClassTermList.append(getObjectOneOf(CEXPRESSIONLIST<CIndividualTermExpression*>()<<indiTermExp)); |
| 1275 |
} |
| 1276 |
CObjectUnionOfExpression* objUnionExp = getObjectUnionOf(nominalClassTermList); |
| 1277 |
setConceptOperandsFromClassTerms(concept,objUnionExp); |
| 1278 |
concept->setOperatorCode(CCAND); |
| 1279 |
} |
| 1280 |
} |
| 1281 |
|
| 1282 |
|
| 1283 |
// build class |
| 1284 |
buildClassConcept(classTermExp); |
| 1285 |
} |
| 1286 |
} |
| 1287 |
|
| 1288 |
if (mNominalConceptCreationRequired && !mLateIndiNominalConceptCreationList.isEmpty()) { |
| 1289 |
for (QList<CIndividualTermExpression*>::const_iterator it = mLateIndiNominalConceptCreationList.constBegin(), itEnd = mLateIndiNominalConceptCreationList.constEnd(); it != itEnd; ++it) { |
| 1290 |
CIndividualTermExpression* indiTermExp(*it); |
| 1291 |
CIndividual* individual = getIndividualForIndividualTerm(indiTermExp,true); |
| 1292 |
CClassTermExpression* nominalAssClassTermExp = getObjectOneOf(indiTermExp); |
| 1293 |
setIndividualAssertionNominalFromClassTerm(individual,nominalAssClassTermExp,false); |
| 1294 |
} |
| 1295 |
mLateIndiNominalConceptCreationList.clear(); |
| 1296 |
} |
| 1297 |
|
| 1298 |
if (mRebuildTopConcept) { |
| 1299 |
CConcept* topConcept = getConceptForClassTerm(mTopClassExpression,true); |
| 1300 |
mRebuildTopConcept = false; |
| 1301 |
FOREACHIT (CClassTermExpression* gciClassTermExp, mClassGCIExpressionSet) { |
| 1302 |
buildConceptSubClassInclusion(mTopClassExpression,gciClassTermExp); |
| 1303 |
} |
| 1304 |
mClassGCIExpressionSet.clear(); |
| 1305 |
FOREACHIT (CClassTermExpression* rebuildClassTermExp, *mTopRebuildClassTermExpressionsSet) { |
| 1306 |
if (!mNewBuildedConceptSet.contains(rebuildClassTermExp) && !mBuildingConceptSet.contains(rebuildClassTermExp)) { |
| 1307 |
mNewBuildConceptSet.insert(rebuildClassTermExp); |
| 1308 |
} |
| 1309 |
} |
| 1310 |
FOREACHIT (CObjectPropertyTermExpression* rebuildObjectPropertyTermExp, *mTopRebuildObjectPropertyTermExpressionsSet) { |
| 1311 |
if (!mNewBuildedObjectRoleSet.contains(rebuildObjectPropertyTermExp) && !mBuildingObjectRoleSet.contains(rebuildObjectPropertyTermExp)) { |
| 1312 |
mNewBuildObjectRoleSet.insert(rebuildObjectPropertyTermExp); |
| 1313 |
} |
| 1314 |
} |
| 1315 |
|
| 1316 |
} |
| 1317 |
} |
| 1318 |
} |
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
buildIndividualIDs(); |
| 1324 |
buildRoleTags(); |
| 1325 |
buildConceptTags(); |
| 1326 |
buildRoleChainTags(); |
| 1327 |
|
| 1328 |
resortAndInstallConceptsAndRolesAndIndividuals(); |
| 1329 |
|
| 1330 |
|
| 1331 |
mOntoData->getExpressionDataBoxMapping()->setLastProcessedChangedAxiom(mLastProcessedChangedAxiom); |
| 1332 |
mOntoData->getExpressionDataBoxMapping()->setLastProcessedBuildIndividual(mLastProcessedBuildIndividual); |
| 1333 |
mOntoData->getExpressionDataBoxMapping()->setLastProcessedBuildConcept(mLastProcessedBuildConcept); |
| 1334 |
mOntoData->getExpressionDataBoxMapping()->setLastProcessedBuildObjectRole(mLastProcessedBuildObjectRole); |
| 1335 |
mOntoData->getExpressionDataBoxMapping()->setLastProcessedBuildDataRole(mLastProcessedBuildDataRole); |
| 1336 |
mOntoData->getExpressionDataBoxMapping()->setLastProcessedBuildDataRange(mLastProcessedBuildDataRange); |
| 1337 |
mOntoData->getExpressionDataBoxMapping()->setLastProcessedBuildDatatype(mLastProcessedBuildDatatype); |
| 1338 |
|
| 1339 |
mOntoData->getExpressionDataBoxMapping()->setLastProcessedInverseProperty(mLastProcessedInverseProperty); |
| 1340 |
mOntoData->getExpressionDataBoxMapping()->setLastProcessedExpression(mLastProcessedExpression); |
| 1341 |
|
| 1342 |
mOntoData->getExpressionDataBoxMapping()->setLastBuildedIndividual(mLastBuildedIndividual); |
| 1343 |
mOntoData->getExpressionDataBoxMapping()->setLastBuildedConcept(mLastBuildedConcept); |
| 1344 |
mOntoData->getExpressionDataBoxMapping()->setLastBuildedObjectRole(mLastBuildedObjectRole); |
| 1345 |
mOntoData->getExpressionDataBoxMapping()->setLastBuildedDataRole(mLastBuildedDataRole); |
| 1346 |
mOntoData->getExpressionDataBoxMapping()->setLastBuildedDataRange(mLastBuildedDataRange); |
| 1347 |
mOntoData->getExpressionDataBoxMapping()->setLastBuildedDatatype(mLastBuildedDatatype); |
| 1348 |
|
| 1349 |
return true; |
| 1350 |
} |
| 1351 |
|
| 1352 |
|
| 1353 |
bool CConcreteOntologyUpdateBuilder::buildClassConcept(CClassTermExpression* classTermExp) { |
| 1354 |
if (classTermExp == mTopClassExpression) { |
| 1355 |
mRebuildTopConcept = true; |
| 1356 |
} else if (mTopRebuildClassTermExpressionsSet->contains(classTermExp)) { |
| 1357 |
if (!mNewBuildedConceptSet.contains(mTopClassExpression) && !mBuildingConceptSet.contains(mTopClassExpression)) { |
| 1358 |
mNewBuildConceptSet.insert(mTopClassExpression); |
| 1359 |
} |
| 1360 |
} |
| 1361 |
if (mClassTermClassAxiomHash->contains(classTermExp)) { |
| 1362 |
CBUILDLIST<CClassAxiomExpression*> classAccAxiomList(mClassTermClassAxiomHash->values(classTermExp)); |
| 1363 |
if (!classAccAxiomList.isEmpty()) { |
| 1364 |
mClassTermClassAxiomHash->remove(classTermExp); |
| 1365 |
FOREACHIT (CClassAxiomExpression* classAxiom, classAccAxiomList) { |
| 1366 |
if (!mRetractUpdatedAxiomSet->contains(classAxiom)) { |
| 1367 |
mClassTermClassAxiomHash->insertMulti(classTermExp,classAxiom); |
| 1368 |
CBuildExpression::ExpressionType expType = classAxiom->getType(); |
| 1369 |
if (expType == CBuildExpression::BETESUBCLASSOF) { |
| 1370 |
CSubClassOfExpression* axiomExp = (CSubClassOfExpression*)classAxiom; |
| 1371 |
buildConceptSubClassInclusion(classTermExp,axiomExp->getSecondClassTermExpression()); |
| 1372 |
} else if (expType == CBuildExpression::BETEQUIVALENTCLASSES) { |
| 1373 |
CEquivalentClassesExpression* axiomExp = (CEquivalentClassesExpression*)classAxiom; |
| 1374 |
buildPermutableConceptEquivalentClass(classTermExp,*axiomExp->getClassTermExpressionList()); |
| 1375 |
} else if (expType == CBuildExpression::BETDISJOINTCLASSES) { |
| 1376 |
CDisjointClassesExpression* axiomExp = (CDisjointClassesExpression*)classAxiom; |
| 1377 |
buildPermutableConceptDisjointClass(classTermExp,*axiomExp->getClassTermExpressionList()); |
| 1378 |
} else if (expType == CBuildExpression::BETDISJOINTUNION) { |
| 1379 |
CDisjointUnionExpression* axiomExp = (CDisjointUnionExpression*)classAxiom; |
| 1380 |
CClassTermExpression* unionClassExp = axiomExp->getClassExpression(); |
| 1381 |
if (classTermExp == unionClassExp) { |
| 1382 |
buildDisjointUnionConceptClass(classTermExp,*axiomExp->getClassTermExpressionList()); |
| 1383 |
} else { |
| 1384 |
buildPermutableConceptDisjointClass(classTermExp,*axiomExp->getClassTermExpressionList()); |
| 1385 |
} |
| 1386 |
} |
| 1387 |
} else { |
| 1388 |
mClassTermClassAxiomSet->remove(QPair<CClassTermExpression*,CClassAxiomExpression*>(classTermExp,classAxiom)); |
| 1389 |
} |
| 1390 |
} |
| 1391 |
} |
| 1392 |
} |
| 1393 |
return true; |
| 1394 |
} |
| 1395 |
|
| 1396 |
|
| 1397 |
bool CConcreteOntologyUpdateBuilder::buildIndividualIndi(CIndividualTermExpression* indiTermExp) { |
| 1398 |
|
| 1399 |
//CClassTermExpression* nominalAssClassTermExp = nullptr; |
| 1400 |
bool nominalAssClass = false; |
| 1401 |
|
| 1402 |
CIndividual* individual = getIndividualForIndividualTerm(indiTermExp,true); |
| 1403 |
|
| 1404 |
if (mIndiTermAssertionAxiomHash->contains(indiTermExp)) { |
| 1405 |
CBUILDLIST<CAssertionAxiomExpression*> indiAssAxiomList(mIndiTermAssertionAxiomHash->values(indiTermExp)); |
| 1406 |
mIndiTermAssertionAxiomHash->remove(indiTermExp); |
| 1407 |
|
| 1408 |
FOREACHIT (CAssertionAxiomExpression* assAxiom, indiAssAxiomList) { |
| 1409 |
|
| 1410 |
CBuildExpression::ExpressionType expType = assAxiom->getType(); |
| 1411 |
if (!mRetractUpdatedAxiomSet->contains(assAxiom)) { |
| 1412 |
mIndiTermAssertionAxiomHash->insertMulti(indiTermExp,assAxiom); |
| 1413 |
|
| 1414 |
if (expType == CBuildExpression::BETCLASSASSERTION) { |
| 1415 |
CClassAssertionExpression* classAssExp = (CClassAssertionExpression*)assAxiom; |
| 1416 |
CClassTermExpression* classTermExp = classAssExp->getClassTermExpression(); |
| 1417 |
setIndividualAssertionConceptFromClassTerm(individual,classTermExp,false); |
| 1418 |
if (classTermExp->getType() == CBuildExpression::BETOBJECTONEOF) { |
| 1419 |
CObjectOneOfExpression* objectOneOfExp = (CObjectOneOfExpression*)classTermExp; |
| 1420 |
CEXPRESSIONLIST<CIndividualTermExpression*>* indiTermExpList = objectOneOfExp->getIndividualTermExpressionList(); |
| 1421 |
if (indiTermExpList->count() == 1) { |
| 1422 |
CIndividualTermExpression* indiTerm = indiTermExpList->first(); |
| 1423 |
if (indiTerm == indiTermExp) { |
| 1424 |
nominalAssClass = true; |
| 1425 |
} |
| 1426 |
} |
| 1427 |
} |
| 1428 |
} else if (expType == CBuildExpression::BETOBJECTPROPERTYASSERTION) { |
| 1429 |
CObjectPropertyAssertionExpression* propAssExp = (CObjectPropertyAssertionExpression*)assAxiom; |
| 1430 |
CObjectPropertyTermExpression* objPropTermExp = propAssExp->getObjectPropertyTermExpression(); |
| 1431 |
CIndividualTermExpression* destIndiTermExp = propAssExp->getSecondIndividualTermExpression(); |
| 1432 |
setIndividualAssertionRoleFromObjectPropertyTerm(individual,objPropTermExp,destIndiTermExp); |
| 1433 |
//CClassTermExpression* classTermExp = getObjectHasValue(objPropTermExp,destIndiTermExp); |
| 1434 |
//setIndividualAssertionConceptFromClassTerm(individual,classTermExp,false); |
| 1435 |
|
| 1436 |
} else if (expType == CBuildExpression::BETDATAPROPERTYASSERTION) { |
| 1437 |
CDataPropertyAssertionExpression* dataAssExp = (CDataPropertyAssertionExpression*)assAxiom; |
| 1438 |
CDataPropertyTermExpression* dataPropTermExp = dataAssExp->getDataPropertyTermExpression(); |
| 1439 |
CDataLiteralExpression* dataLiteralExp = dynamic_cast<CDataLiteralExpression*>(dataAssExp->getDataLiteralTermExpression()); |
| 1440 |
setIndividualAssertionDataFromDataLiteralTerm(individual, dataPropTermExp, dataLiteralExp); |
| 1441 |
|
| 1442 |
} else if (expType == CBuildExpression::BETNEGATIVEDATAPROPERTYASSERTION) { |
| 1443 |
CNegativeDataPropertyAssertionExpression* dataAssExp = (CNegativeDataPropertyAssertionExpression*)assAxiom; |
| 1444 |
CDataPropertyTermExpression* dataPropTermExp = dataAssExp->getDataPropertyTermExpression(); |
| 1445 |
CDataLiteralExpression* dataLiteralExp = dynamic_cast<CDataLiteralExpression*>(dataAssExp->getDataLiteralTermExpression()); |
| 1446 |
CClassTermExpression* classTermExp = getDataHasValue(dataPropTermExp,dataLiteralExp); |
| 1447 |
if (dataLiteralExp) { |
| 1448 |
setIndividualAssertionConceptFromClassTerm(individual, classTermExp, true); |
| 1449 |
} |
| 1450 |
|
| 1451 |
} else if (expType == CBuildExpression::BETNEGATIVEOBJECTPROPERTYASSERTION) { |
| 1452 |
CNegativeObjectPropertyAssertionExpression* propAssExp = (CNegativeObjectPropertyAssertionExpression*)assAxiom; |
| 1453 |
CObjectPropertyTermExpression* objPropTermExp = propAssExp->getObjectPropertyTermExpression(); |
| 1454 |
CIndividualTermExpression* destIndiTermExp = propAssExp->getSecondIndividualTermExpression(); |
| 1455 |
CClassTermExpression* classTermExp = getObjectHasValue(objPropTermExp,destIndiTermExp); |
| 1456 |
setIndividualAssertionConceptFromClassTerm(individual,classTermExp,true); |
| 1457 |
|
| 1458 |
} else if (expType == CBuildExpression::BETSAMEINDIVIDUAL) { |
| 1459 |
CSameIndividualExpression* sameIndiAssExp = (CSameIndividualExpression*)assAxiom; |
| 1460 |
FOREACHIT (CIndividualTermExpression* indiTermExp2, *sameIndiAssExp->getIndividualTermExpressionList()) { |
| 1461 |
if (indiTermExp != indiTermExp2) { |
| 1462 |
CClassTermExpression* classTermExp = getObjectOneOf(indiTermExp2); |
| 1463 |
setIndividualAssertionConceptFromClassTerm(individual,classTermExp,false); |
| 1464 |
} |
| 1465 |
} |
| 1466 |
} else if (expType == CBuildExpression::BETDIFFERENTINDIVIDUAL) { |
| 1467 |
CDifferentIndividualsExpression* diffIndiAssExp = (CDifferentIndividualsExpression*)assAxiom; |
| 1468 |
FOREACHIT (CIndividualTermExpression* indiTermExp2, *diffIndiAssExp->getIndividualTermExpressionList()) { |
| 1469 |
if (indiTermExp != indiTermExp2) { |
| 1470 |
CClassTermExpression* classTermExp = getObjectOneOf(indiTermExp2); |
| 1471 |
setIndividualAssertionConceptFromClassTerm(individual,classTermExp,true); |
| 1472 |
} |
| 1473 |
} |
| 1474 |
} |
| 1475 |
} |
| 1476 |
} |
| 1477 |
} |
| 1478 |
if (!nominalAssClass) { |
| 1479 |
if (mConstructFlags->isNominalSchemaUsed()) { |
| 1480 |
CClassTermExpression* nominalAssClassTermExp = getObjectOneOf(indiTermExp); |
| 1481 |
setIndividualAssertionNominalFromClassTerm(individual,nominalAssClassTermExp,false); |
| 1482 |
} else { |
| 1483 |
mLateIndiNominalConceptCreationList.append(indiTermExp); |
| 1484 |
} |
| 1485 |
} |
| 1486 |
|
| 1487 |
//if (!nominalAssClass && mConstructFlags->isNominalSchemaUsed()) { |
| 1488 |
// CClassTermExpression* nominalAssClassTermExp = getObjectOneOf(indiTermExp); |
| 1489 |
// setIndividualAssertionNominalFromClassTerm(individual,nominalAssClassTermExp,false); |
| 1490 |
//} |
| 1491 |
if (!individual->isAnonymousIndividual()) { |
| 1492 |
CConceptAssertionLinker* opConLinker = CObjectAllocator< CConceptAssertionLinker >::allocateAndConstruct(mMemManager); |
| 1493 |
opConLinker->initNegLinker(tBox->getIndividualTriggerConcept(),false); |
| 1494 |
individual->addAssertionConceptLinker(opConLinker); |
| 1495 |
} |
| 1496 |
|
| 1497 |
return true; |
| 1498 |
} |
| 1499 |
|
| 1500 |
|
| 1501 |
bool CConcreteOntologyUpdateBuilder::buildDatatype(CDatatypeExpression* datatypeExp) { |
| 1502 |
return true; |
| 1503 |
} |
| 1504 |
|
| 1505 |
|
| 1506 |
bool CConcreteOntologyUpdateBuilder::buildDataPropertyRole(CDataPropertyTermExpression* dataPropTermExp) { |
| 1507 |
|
| 1508 |
|
| 1509 |
CBUILDLIST<CDataPropertyAxiomExpression*> dataPropAccAxiomList(mDataPropTermDataPropAxiomHash->values(dataPropTermExp)); |
| 1510 |
mDataPropTermDataPropAxiomHash->remove(dataPropTermExp); |
| 1511 |
|
| 1512 |
|
| 1513 |
CRole* role = getRoleForDataPropertyTerm(dataPropTermExp,true); |
| 1514 |
|
| 1515 |
|
| 1516 |
|
| 1517 |
FOREACHIT (CDataPropertyAxiomExpression* dataPropAxiom, dataPropAccAxiomList) { |
| 1518 |
if (!mRetractUpdatedAxiomSet->contains(dataPropAxiom)) { |
| 1519 |
mDataPropTermDataPropAxiomHash->insertMulti(dataPropTermExp,dataPropAxiom); |
| 1520 |
CBuildExpression::ExpressionType expType = dataPropAxiom->getType(); |
| 1521 |
if (expType == CBuildExpression::BETSUBDATAPROPERTYOF) { |
| 1522 |
CSubDataPropertyOfExpression* dataPropAxiomExp = (CSubDataPropertyOfExpression*)dataPropAxiom; |
| 1523 |
CDataPropertyTermExpression* superDataPropertyExpression = dataPropAxiomExp->getSuperDataPropertyTermExpression(); |
| 1524 |
if (superDataPropertyExpression != mTopDataPropExpression) { |
| 1525 |
CRole* superRole = getRoleForDataPropertyTerm(superDataPropertyExpression); |
| 1526 |
if (!role->hasSuperRole(superRole)) { |
| 1527 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1528 |
roleLinker->init(superRole,false); |
| 1529 |
role->addSuperRoleLinker(roleLinker); |
| 1530 |
} |
| 1531 |
} |
| 1532 |
} else if (expType == CBuildExpression::BETEQUIVALENTDATAPROPERTIES) { |
| 1533 |
CEquivalentDataPropertiesExpression* dataPropAxiomExp = (CEquivalentDataPropertiesExpression*)dataPropAxiom; |
| 1534 |
CEXPRESSIONLIST<CDataPropertyTermExpression*>* eqDataPropertyExpressionList = dataPropAxiomExp->getDataPropertyTermExpressionList(); |
| 1535 |
FOREACHIT (CDataPropertyTermExpression* eqDataPropTermExp, *eqDataPropertyExpressionList) { |
| 1536 |
if (dataPropTermExp != eqDataPropTermExp) { |
| 1537 |
CRole* eqRole = getRoleForDataPropertyTerm(eqDataPropTermExp); |
| 1538 |
if (!role->hasEquivalentRole(eqRole)) { |
| 1539 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1540 |
roleLinker->init(eqRole,false); |
| 1541 |
role->addEquivalentRoleLinker(roleLinker); |
| 1542 |
} |
| 1543 |
} |
| 1544 |
} |
| 1545 |
} else if (expType == CBuildExpression::BETDISJOINTDATAPROPERTIES) { |
| 1546 |
CDisjointDataPropertiesExpression* dataPropAxiomExp = (CDisjointDataPropertiesExpression*)dataPropAxiom; |
| 1547 |
CEXPRESSIONLIST<CDataPropertyTermExpression*>* disDataPropertyExpressionList = dataPropAxiomExp->getDataPropertyTermExpressionList(); |
| 1548 |
FOREACHIT (CDataPropertyTermExpression* disDataPropTermExp, *disDataPropertyExpressionList) { |
| 1549 |
if (dataPropTermExp != disDataPropTermExp) { |
| 1550 |
CRole* disRole = getRoleForDataPropertyTerm(disDataPropTermExp); |
| 1551 |
if (!role->hasDisjointRole(disRole)) { |
| 1552 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1553 |
roleLinker->init(disRole,false); |
| 1554 |
role->addDisjointRoleLinker(roleLinker); |
| 1555 |
} |
| 1556 |
} |
| 1557 |
} |
| 1558 |
} else if (expType == CBuildExpression::BETDATAPROPERTYDOMAIN) { |
| 1559 |
CDataPropertyDomainExpression* dataPropAxiomExp = (CDataPropertyDomainExpression*)dataPropAxiom; |
| 1560 |
CClassTermExpression* domainExp = dataPropAxiomExp->getClassTermExpression(); |
| 1561 |
CConcept* domainCon = getConceptForClassTerm(domainExp); |
| 1562 |
CSortedNegLinker<CConcept*>* conceptLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 1563 |
conceptLinker->init(domainCon, domainCon->hasMappingNegation()); |
| 1564 |
role->addDomainConceptLinker(conceptLinker); |
| 1565 |
} else if (expType == CBuildExpression::BETDATAPROPERTYRANGE) { |
| 1566 |
CDataPropertyRangeExpression* dataPropAxiomExp = (CDataPropertyRangeExpression*)dataPropAxiom; |
| 1567 |
CDataRangeTermExpression* rangeExp = dataPropAxiomExp->getDataRangeTermExpression(); |
| 1568 |
CConcept* rangeCon = getConceptForDataRangeTerm(rangeExp); |
| 1569 |
CSortedNegLinker<CConcept*>* conceptLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 1570 |
conceptLinker->init(rangeCon, rangeCon->hasMappingNegation()); |
| 1571 |
role->addRangeConceptLinker(conceptLinker); |
| 1572 |
} else if (expType == CBuildExpression::BETFUNCTIONALDATAPROPERTY) { |
| 1573 |
CFunctionalDataPropertyExpression* dataPropAxiomExp = (CFunctionalDataPropertyExpression*)dataPropAxiom; |
| 1574 |
CDataMaxCardinalityExpression* funcCardExp = getDataMaxCardinality(dataPropTermExp,mTopDataPropExpression,1); |
| 1575 |
CConcept* domainCon = getConceptForClassTerm(funcCardExp); |
| 1576 |
CSortedNegLinker<CConcept*>* conceptLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 1577 |
conceptLinker->init(domainCon, domainCon->hasMappingNegation()); |
| 1578 |
role->addDomainConceptLinker(conceptLinker); |
| 1579 |
role->setFunctional(true); |
| 1580 |
} |
| 1581 |
} else { |
| 1582 |
mDataPropTermDataPropAxiomSet->remove(QPair<CDataPropertyTermExpression*,CDataPropertyAxiomExpression*>(dataPropTermExp,dataPropAxiom)); |
| 1583 |
} |
| 1584 |
} |
| 1585 |
return true; |
| 1586 |
} |
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
bool CConcreteOntologyUpdateBuilder::buildObjectPropertyRole(CObjectPropertyTermExpression* objPropTermExp) { |
| 1592 |
if (mTopRebuildObjectPropertyTermExpressionsSet->contains(objPropTermExp)) { |
| 1593 |
if (!mNewBuildedObjectRoleSet.contains(mTopObjPropExpression) && !mBuildingObjectRoleSet.contains(mTopObjPropExpression)) { |
| 1594 |
mNewBuildObjectRoleSet.insert(mTopObjPropExpression); |
| 1595 |
} |
| 1596 |
} |
| 1597 |
|
| 1598 |
CBUILDLIST<CObjectPropertyAxiomExpression*> objPropAccAxiomList(mObjPropTermObjPropAxiomHash->values(objPropTermExp)); |
| 1599 |
mObjPropTermObjPropAxiomHash->remove(objPropTermExp); |
| 1600 |
|
| 1601 |
CObjectPropertyTermExpression* inverseObjPropTermExp = mInverseObjectPropertyHash->value(objPropTermExp,nullptr); |
| 1602 |
|
| 1603 |
CRole* role = nullptr; |
| 1604 |
if (objPropAccAxiomList.isEmpty() && inverseObjPropTermExp) { |
| 1605 |
role = mObjPropTermRoleHash->value(objPropTermExp); |
| 1606 |
CRole* invRole = mObjPropTermRoleHash->value(inverseObjPropTermExp); |
| 1607 |
if (!role && invRole) { |
| 1608 |
role = invRole->getInverseRole(); |
| 1609 |
if (role) { |
| 1610 |
mObjPropTermRoleHash->insert(objPropTermExp, role); |
| 1611 |
} |
| 1612 |
} |
| 1613 |
} |
| 1614 |
|
| 1615 |
if (!role) { |
| 1616 |
role = getRoleForObjectPropertyTerm(objPropTermExp, true); |
| 1617 |
} |
| 1618 |
|
| 1619 |
if (inverseObjPropTermExp) { |
| 1620 |
CRole* invRole = getRoleForObjectPropertyTerm(inverseObjPropTermExp); |
| 1621 |
if (!role->hasInverseRole(invRole)) { |
| 1622 |
if (!role->getInverseRole()) { |
| 1623 |
role->setInverseRole(invRole); |
| 1624 |
} |
| 1625 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1626 |
roleLinker->init(invRole,true); |
| 1627 |
role->addInverseRoleLinker(roleLinker); |
| 1628 |
} |
| 1629 |
if (!invRole->hasInverseRole(role)) { |
| 1630 |
if (!invRole->getInverseRole()) { |
| 1631 |
invRole->setInverseRole(role); |
| 1632 |
} |
| 1633 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1634 |
roleLinker->init(role,true); |
| 1635 |
invRole->addInverseRoleLinker(roleLinker); |
| 1636 |
} |
| 1637 |
} |
| 1638 |
|
| 1639 |
FOREACHIT(CObjectPropertyAxiomExpression* objPropAxiom, objPropAccAxiomList) { |
| 1640 |
if (!mRetractUpdatedAxiomSet->contains(objPropAxiom)) { |
| 1641 |
mObjPropTermObjPropAxiomHash->insertMulti(objPropTermExp, objPropAxiom); |
| 1642 |
CBuildExpression::ExpressionType expType = objPropAxiom->getType(); |
| 1643 |
if (expType == CBuildExpression::BETINVERSEOBJECTPROPERTIES) { |
| 1644 |
CInverseObjectPropertiesExpression* objPropAxiomExp = (CInverseObjectPropertiesExpression*)objPropAxiom; |
| 1645 |
CObjectPropertyTermExpression* invObjPropTermExp = nullptr; |
| 1646 |
if (objPropTermExp == objPropAxiomExp->getFirstObjectPropertyTermExpression()) { |
| 1647 |
invObjPropTermExp = objPropAxiomExp->getSecondObjectPropertyTermExpression(); |
| 1648 |
} else { |
| 1649 |
invObjPropTermExp = objPropAxiomExp->getFirstObjectPropertyTermExpression(); |
| 1650 |
} |
| 1651 |
mInverseObjectPropertyHash->insert(objPropTermExp, invObjPropTermExp); |
| 1652 |
mInverseObjectPropertyHash->insert(invObjPropTermExp, objPropTermExp); |
| 1653 |
CRole* invRole = getRoleForObjectPropertyTerm(invObjPropTermExp); |
| 1654 |
if (!role->hasInverseRole(invRole)) { |
| 1655 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1656 |
roleLinker->init(invRole, true); |
| 1657 |
role->addInverseRoleLinker(roleLinker); |
| 1658 |
} |
| 1659 |
} |
| 1660 |
} |
| 1661 |
} |
| 1662 |
|
| 1663 |
FOREACHIT (CObjectPropertyAxiomExpression* objPropAxiom, objPropAccAxiomList) { |
| 1664 |
if (!mRetractUpdatedAxiomSet->contains(objPropAxiom)) { |
| 1665 |
CBuildExpression::ExpressionType expType = objPropAxiom->getType(); |
| 1666 |
if (expType == CBuildExpression::BETSUBOBJECTPROPERTYOF) { |
| 1667 |
if (objPropTermExp != mBottomObjPropExpression) { |
| 1668 |
CSubObjectPropertyOfExpression* objPropAxiomExp = (CSubObjectPropertyOfExpression*)objPropAxiom; |
| 1669 |
CEXPRESSIONLIST<CObjectPropertyTermExpression*>* subObjectPropertyExpressionList = objPropAxiomExp->getSubObjectPropertyTermExpressionList(); |
| 1670 |
// build only once |
| 1671 |
CObjectPropertyTermExpression* superObjectPropertyExpression = objPropAxiomExp->getSuperObjectPropertyTermExpression(); |
| 1672 |
if (subObjectPropertyExpressionList->count() <= 1) { |
| 1673 |
// build simple sub role relation |
| 1674 |
if (superObjectPropertyExpression != mTopObjPropExpression) { |
| 1675 |
CRole* superRole = getRoleForObjectPropertyTerm(superObjectPropertyExpression); |
| 1676 |
if (!role->hasSuperRole(superRole)) { |
| 1677 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1678 |
roleLinker->init(superRole,false); |
| 1679 |
role->addSuperRoleLinker(roleLinker); |
| 1680 |
} |
| 1681 |
} |
| 1682 |
} else { |
| 1683 |
// build role chain |
| 1684 |
CRoleChain* roleChain = buildRoleChainForSubObjectPropertyOfExpression(objPropAxiomExp); |
| 1685 |
CXLinker<CRoleChain*>* roleChainLinker = CObjectAllocator< CXLinker<CRoleChain*> >::allocateAndConstruct(mMemManager); |
| 1686 |
roleChainLinker->initLinker(roleChain); |
| 1687 |
if (objPropTermExp == superObjectPropertyExpression) { |
| 1688 |
// role is super role |
| 1689 |
role->addRoleChainSuperSharingLinker(roleChainLinker); |
| 1690 |
} else { |
| 1691 |
role->addRoleChainSubSharingLinker(roleChainLinker); |
| 1692 |
} |
| 1693 |
} |
| 1694 |
} |
| 1695 |
} else if (expType == CBuildExpression::BETEQUIVALENTOBJECTPROPERTIES) { |
| 1696 |
CEquivalentObjectPropertiesExpression* objPropAxiomExp = (CEquivalentObjectPropertiesExpression*)objPropAxiom; |
| 1697 |
CEXPRESSIONLIST<CObjectPropertyTermExpression*>* eqObjectPropertyExpressionList = objPropAxiomExp->getObjectPropertyTermExpressionList(); |
| 1698 |
FOREACHIT (CObjectPropertyTermExpression* eqObjPropTermExp, *eqObjectPropertyExpressionList) { |
| 1699 |
if (objPropTermExp != eqObjPropTermExp) { |
| 1700 |
CRole* eqRole = getRoleForObjectPropertyTerm(eqObjPropTermExp); |
| 1701 |
if (!role->hasEquivalentRole(eqRole)) { |
| 1702 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1703 |
roleLinker->init(eqRole,false); |
| 1704 |
role->addEquivalentRoleLinker(roleLinker); |
| 1705 |
} |
| 1706 |
} |
| 1707 |
} |
| 1708 |
} else if (expType == CBuildExpression::BETDISJOINTOBJECTPROPERTIES) { |
| 1709 |
CDisjointObjectPropertiesExpression* objPropAxiomExp = (CDisjointObjectPropertiesExpression*)objPropAxiom; |
| 1710 |
CEXPRESSIONLIST<CObjectPropertyTermExpression*>* disObjectPropertyExpressionList = objPropAxiomExp->getObjectPropertyTermExpressionList(); |
| 1711 |
FOREACHIT (CObjectPropertyTermExpression* disObjPropTermExp, *disObjectPropertyExpressionList) { |
| 1712 |
if (objPropTermExp != disObjPropTermExp) { |
| 1713 |
CRole* disRole = getRoleForObjectPropertyTerm(disObjPropTermExp); |
| 1714 |
if (!role->hasDisjointRole(disRole)) { |
| 1715 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1716 |
roleLinker->init(disRole,false); |
| 1717 |
role->addDisjointRoleLinker(roleLinker); |
| 1718 |
} |
| 1719 |
} |
| 1720 |
} |
| 1721 |
} else if (expType == CBuildExpression::BETOBJECTPROPERTYDOMAIN) { |
| 1722 |
CObjectPropertyDomainExpression* objPropAxiomExp = (CObjectPropertyDomainExpression*)objPropAxiom; |
| 1723 |
CClassTermExpression* domainExp = objPropAxiomExp->getClassTermExpression(); |
| 1724 |
CConcept* domainCon = getConceptForClassTerm(domainExp); |
| 1725 |
CSortedNegLinker<CConcept*>* conceptLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 1726 |
conceptLinker->init(domainCon,domainCon->hasMappingNegation()); |
| 1727 |
role->addDomainConceptLinker(conceptLinker); |
| 1728 |
} else if (expType == CBuildExpression::BETOBJECTPROPERTYRANGE) { |
| 1729 |
CObjectPropertyRangeExpression* objPropAxiomExp = (CObjectPropertyRangeExpression*)objPropAxiom; |
| 1730 |
CClassTermExpression* rangeExp = objPropAxiomExp->getClassTermExpression(); |
| 1731 |
CConcept* rangeCon = getConceptForClassTerm(rangeExp); |
| 1732 |
CSortedNegLinker<CConcept*>* conceptLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 1733 |
conceptLinker->init(rangeCon, rangeCon->hasMappingNegation()); |
| 1734 |
role->addRangeConceptLinker(conceptLinker); |
| 1735 |
} else if (expType == CBuildExpression::BETFUNCTIONALOBJECTPROPERTY) { |
| 1736 |
CFunctionalObjectPropertyExpression* objPropAxiomExp = (CFunctionalObjectPropertyExpression*)objPropAxiom; |
| 1737 |
CObjectMaxCardinalityExpression* funcCardExp = getObjectMaxCardinality(objPropTermExp,mTopClassExpression,1); |
| 1738 |
CConcept* domainCon = getConceptForClassTerm(funcCardExp); |
| 1739 |
CSortedNegLinker<CConcept*>* conceptLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 1740 |
conceptLinker->init(domainCon, domainCon->hasMappingNegation()); |
| 1741 |
role->addDomainConceptLinker(conceptLinker); |
| 1742 |
role->setFunctional(true); |
| 1743 |
} else if (expType == CBuildExpression::BETINVERSEFUNCTIONALPROPERTY) { |
| 1744 |
CInverseFunctionalObjectPropertyExpression* objPropAxiomExp = (CInverseFunctionalObjectPropertyExpression*)objPropAxiom; |
| 1745 |
CObjectMaxCardinalityExpression* funcCardExp = getObjectMaxCardinality(getCorrectedInverseObjectPropertyOf(objPropTermExp),mTopClassExpression,1); |
| 1746 |
CConcept* rangeCon = getConceptForClassTerm(funcCardExp); |
| 1747 |
CSortedNegLinker<CConcept*>* conceptLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 1748 |
conceptLinker->init(rangeCon, rangeCon->hasMappingNegation()); |
| 1749 |
role->addRangeConceptLinker(conceptLinker); |
| 1750 |
role->setInverseFunctional(true); |
| 1751 |
} else if (expType == CBuildExpression::BETREFLEXIVEPROPERTY) { |
| 1752 |
CReflexiveObjectPropertyExpression* objPropAxiomExp = (CReflexiveObjectPropertyExpression*)objPropAxiom; |
| 1753 |
CObjectHasSelfExpression* gciSelfExp = getObjectHasSelf(objPropTermExp); |
| 1754 |
buildGeneralConceptInclusionClassExpression(gciSelfExp); |
| 1755 |
role->setReflexive(true); |
| 1756 |
} else if (expType == CBuildExpression::BETIRREFLEXIVEPROPERTY) { |
| 1757 |
CIrreflexiveObjectPropertyExpression* objPropAxiomExp = (CIrreflexiveObjectPropertyExpression*)objPropAxiom; |
| 1758 |
CObjectHasSelfExpression* selfExp = getObjectHasSelf(objPropTermExp); |
| 1759 |
CObjectComplementOfExpression* gciNotSelfExp = getObjectComplementOf(selfExp); |
| 1760 |
buildGeneralConceptInclusionClassExpression(gciNotSelfExp); |
| 1761 |
role->setIrreflexive(true); |
| 1762 |
} else if (expType == CBuildExpression::BETSYMMETRICPROPERTY) { |
| 1763 |
// has it self as inverse |
| 1764 |
CSymmetricObjectPropertyExpression* objPropAxiomExp = (CSymmetricObjectPropertyExpression*)objPropAxiom; |
| 1765 |
CRole* invRole = role; |
| 1766 |
if (!role->hasInverseRole(invRole)) { |
| 1767 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1768 |
roleLinker->init(invRole,true); |
| 1769 |
role->addInverseRoleLinker(roleLinker); |
| 1770 |
role->setInverseRole(role); |
| 1771 |
} |
| 1772 |
role->setSymmetric(true); |
| 1773 |
} else if (expType == CBuildExpression::BETASYMMETRICPROPERTY) { |
| 1774 |
// disjoint to the inverse |
| 1775 |
CAsymmetricObjectPropertyExpression* objPropAxiomExp = (CAsymmetricObjectPropertyExpression*)objPropAxiom; |
| 1776 |
CObjectPropertyTermExpression* invObjPropTermExp = getCorrectedInverseObjectPropertyOf(objPropTermExp); |
| 1777 |
CRole* invRole = getRoleForObjectPropertyTerm(invObjPropTermExp); |
| 1778 |
if (!role->hasDisjointRole(invRole)) { |
| 1779 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1780 |
roleLinker->init(invRole,false); |
| 1781 |
role->addDisjointRoleLinker(roleLinker); |
| 1782 |
} |
| 1783 |
if (!invRole->hasDisjointRole(role)) { |
| 1784 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1785 |
roleLinker->init(role,false); |
| 1786 |
invRole->addDisjointRoleLinker(roleLinker); |
| 1787 |
} |
| 1788 |
role->setAsymmetric(true); |
| 1789 |
} else if (expType == CBuildExpression::BETTRANSITIVEOBJECTPROPERTY) { |
| 1790 |
// TODO: build RR [= R ?? |
| 1791 |
CTransetiveObjectPropertyExpression* objPropAxiomExp = (CTransetiveObjectPropertyExpression*)objPropAxiom; |
| 1792 |
CRoleChain* roleChain = buildRoleChainForTransetiveObjectPropertyExpression(objPropAxiomExp); |
| 1793 |
|
| 1794 |
CXLinker<CRoleChain*>* superRoleChainLinker = CObjectAllocator< CXLinker<CRoleChain*> >::allocateAndConstruct(mMemManager); |
| 1795 |
superRoleChainLinker->initLinker(roleChain); |
| 1796 |
role->addRoleChainSuperSharingLinker(superRoleChainLinker); |
| 1797 |
CXLinker<CRoleChain*>* subRoleChainLinker = CObjectAllocator< CXLinker<CRoleChain*> >::allocateAndConstruct(mMemManager); |
| 1798 |
subRoleChainLinker->initLinker(roleChain); |
| 1799 |
role->addRoleChainSubSharingLinker(subRoleChainLinker); |
| 1800 |
role->setTransitive(true); |
| 1801 |
} |
| 1802 |
} else { |
| 1803 |
mObjPropTermObjPropAxiomSet->remove(QPair<CObjectPropertyTermExpression*,CObjectPropertyAxiomExpression*>(objPropTermExp,objPropAxiom)); |
| 1804 |
} |
| 1805 |
} |
| 1806 |
return true; |
| 1807 |
} |
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
CRoleChain* CConcreteOntologyUpdateBuilder::buildRoleChainForTransetiveObjectPropertyExpression(CTransetiveObjectPropertyExpression* objPropAxiomExp) { |
| 1812 |
CRoleChain* roleChain = nullptr; |
| 1813 |
roleChain = mObjPropTermRoleChainHash->value(objPropAxiomExp,nullptr); |
| 1814 |
if (!roleChain) { |
| 1815 |
roleChain = CObjectAllocator< CRoleChain >::allocateAndConstruct(mMemManager); |
| 1816 |
roleChain->initRoleChain(); |
| 1817 |
mObjPropTermRoleChainHash->insert(objPropAxiomExp,roleChain); |
| 1818 |
mRoleChainObjPropTermHash->insert(roleChain,objPropAxiomExp); |
| 1819 |
CObjectPropertyTermExpression* transObjectProperty = objPropAxiomExp->getTransetivePropertyExpression(); |
| 1820 |
CRole* transRole = getRoleForObjectPropertyTerm(transObjectProperty); |
| 1821 |
CXLinker<CRole*>* chainedRoleLinker1 = CObjectAllocator< CXLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1822 |
chainedRoleLinker1->initLinker(transRole); |
| 1823 |
roleChain->appendRoleChainLinker(chainedRoleLinker1); |
| 1824 |
CXLinker<CRole*>* chainedRoleLinker2 = CObjectAllocator< CXLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1825 |
chainedRoleLinker2->initLinker(transRole); |
| 1826 |
roleChain->appendRoleChainLinker(chainedRoleLinker2); |
| 1827 |
mTaggingRoleChainSet.insert(roleChain); |
| 1828 |
} |
| 1829 |
return roleChain; |
| 1830 |
} |
| 1831 |
|
| 1832 |
|
| 1833 |
CRoleChain* CConcreteOntologyUpdateBuilder::buildRoleChainForSubObjectPropertyOfExpression(CSubObjectPropertyOfExpression* subObPropExp) { |
| 1834 |
CRoleChain* roleChain = nullptr; |
| 1835 |
roleChain = mObjPropTermRoleChainHash->value(subObPropExp,nullptr); |
| 1836 |
if (!roleChain) { |
| 1837 |
roleChain = CObjectAllocator< CRoleChain >::allocateAndConstruct(mMemManager); |
| 1838 |
roleChain->initRoleChain(); |
| 1839 |
mObjPropTermRoleChainHash->insert(subObPropExp,roleChain); |
| 1840 |
mRoleChainObjPropTermHash->insert(roleChain,subObPropExp); |
| 1841 |
CEXPRESSIONLIST<CObjectPropertyTermExpression*>* subObjPropList = subObPropExp->getSubObjectPropertyTermExpressionList(); |
| 1842 |
FOREACHIT (CObjectPropertyTermExpression* subObjProp, *subObjPropList) { |
| 1843 |
CRole* subRole = getRoleForObjectPropertyTerm(subObjProp); |
| 1844 |
CXLinker<CRole*>* chainedRoleLinker = CObjectAllocator< CXLinker<CRole*> >::allocateAndConstruct(mMemManager); |
| 1845 |
chainedRoleLinker->initLinker(subRole); |
| 1846 |
roleChain->appendRoleChainLinker(chainedRoleLinker); |
| 1847 |
} |
| 1848 |
mTaggingRoleChainSet.insert(roleChain); |
| 1849 |
} |
| 1850 |
return roleChain; |
| 1851 |
} |
| 1852 |
|
| 1853 |
|
| 1854 |
bool CConcreteOntologyUpdateBuilder::buildDisjointUnionConceptClass(CClassTermExpression* disCallClassExp, const CEXPRESSIONLIST<CClassTermExpression*>& disClassExpList) { |
| 1855 |
cint64 disjCount = disClassExpList.count(); |
| 1856 |
if (disjCount > 0) { |
| 1857 |
if (disjCount == 1) { |
| 1858 |
CClassTermExpression* disjClassExp = disClassExpList.first(); |
| 1859 |
buildConceptSubClassInclusion(disCallClassExp,disjClassExp); |
| 1860 |
buildConceptSubClassInclusion(disjClassExp,disCallClassExp); |
| 1861 |
} else { |
| 1862 |
CClassTermExpression* orDisjExp = getObjectUnionOf(disClassExpList); |
| 1863 |
buildConceptSubClassInclusion(disCallClassExp,orDisjExp); |
| 1864 |
buildConceptSubClassInclusion(orDisjExp,disCallClassExp); |
| 1865 |
} |
| 1866 |
} |
| 1867 |
return true; |
| 1868 |
} |
| 1869 |
|
| 1870 |
|
| 1871 |
bool CConcreteOntologyUpdateBuilder::buildPermutableConceptEquivalentClass(CClassTermExpression* eqCallClassExp, const CEXPRESSIONLIST<CClassTermExpression*>& eqClassExpList) { |
| 1872 |
if (eqClassExpList.count() == 2) { |
| 1873 |
CClassTermExpression* firstEqClassExp = eqClassExpList.first(); |
| 1874 |
CClassTermExpression* secondEqClassExp = eqClassExpList.last(); |
| 1875 |
buildPermutableConceptEquivalentClass(firstEqClassExp,secondEqClassExp); |
| 1876 |
} else { |
| 1877 |
FOREACHIT (CClassTermExpression* eqClassExp2, eqClassExpList) { |
| 1878 |
if (eqClassExp2 != eqCallClassExp) { |
| 1879 |
buildConceptSubClassInclusion(eqCallClassExp,eqClassExp2); |
| 1880 |
} |
| 1881 |
} |
| 1882 |
} |
| 1883 |
return true; |
| 1884 |
} |
| 1885 |
|
| 1886 |
|
| 1887 |
bool CConcreteOntologyUpdateBuilder::buildPermutableConceptDisjointClass(CClassTermExpression* disCallClassExp, const CEXPRESSIONLIST<CClassTermExpression*>& disClassExpList) { |
| 1888 |
bool sameDisCallClassOcc = false; |
| 1889 |
FOREACHIT (CClassTermExpression* disClassExp2, disClassExpList) { |
| 1890 |
if (disCallClassExp != disClassExp2 || sameDisCallClassOcc) { |
| 1891 |
buildConceptSubClassInclusion(disCallClassExp,disClassExp2,true); |
| 1892 |
} else { |
| 1893 |
sameDisCallClassOcc = true; |
| 1894 |
} |
| 1895 |
} |
| 1896 |
return true; |
| 1897 |
} |
| 1898 |
|
| 1899 |
|
| 1900 |
bool CConcreteOntologyUpdateBuilder::buildPermutableConceptEquivalentClass(CClassTermExpression* classExp1, CClassTermExpression* classExp2) { |
| 1901 |
CConcept* concept1 = getConceptForClassTerm(classExp1); |
| 1902 |
CConcept* concept2 = getConceptForClassTerm(classExp2); |
| 1903 |
CClassTermExpression* defEqClassExp = nullptr; |
| 1904 |
CConcept* defEqConcept = nullptr; |
| 1905 |
CClassTermExpression* eqClassExp = nullptr; |
| 1906 |
CConcept* eqConcept = nullptr; |
| 1907 |
if (concept1->getOperatorCode() == CCEQ && concept1->getOperandCount() == 1 && concept1->hasOperandConcept(concept2,false) || concept2->getOperatorCode() == CCEQ && concept2->getOperandCount() == 1 && concept2->hasOperandConcept(concept1,false)) { |
| 1908 |
// equivalent class is already build |
| 1909 |
return true; |
| 1910 |
} else { |
| 1911 |
if (classExp1->getType() == CBuildExpression::BETCLASS && concept1->getOperatorCode() == CCNONE) { |
| 1912 |
defEqClassExp = classExp1; |
| 1913 |
defEqConcept = concept1; |
| 1914 |
eqClassExp = classExp2; |
| 1915 |
eqConcept = concept2; |
| 1916 |
} else { |
| 1917 |
defEqClassExp = classExp2; |
| 1918 |
defEqConcept = concept2; |
| 1919 |
eqClassExp = classExp1; |
| 1920 |
eqConcept = concept1; |
| 1921 |
} |
| 1922 |
return buildConceptEquivalentClass(defEqClassExp,eqClassExp); |
| 1923 |
} |
| 1924 |
} |
| 1925 |
|
| 1926 |
bool CConcreteOntologyUpdateBuilder::buildConceptEquivalentClass(CClassTermExpression* classExp1, CClassTermExpression* classExp2) { |
| 1927 |
CConcept* concept1 = getConceptForClassTerm(classExp1); |
| 1928 |
CConcept* concept2 = getConceptForClassTerm(classExp2); |
| 1929 |
CClassTermExpression* defEqClassExp = nullptr; |
| 1930 |
CConcept* defEqConcept = nullptr; |
| 1931 |
CClassTermExpression* eqClassExp = nullptr; |
| 1932 |
CConcept* eqConcept = nullptr; |
| 1933 |
defEqClassExp = classExp1; |
| 1934 |
defEqConcept = concept1; |
| 1935 |
eqClassExp = classExp2; |
| 1936 |
eqConcept = concept2; |
| 1937 |
|
| 1938 |
|
| 1939 |
if (defEqClassExp->getType() == CBuildExpression::BETCLASS && defEqConcept->getOperatorCode() == CCNONE) { |
| 1940 |
// can build completely defined equivalent concept |
| 1941 |
defEqConcept->setOperatorCode(CCEQ); |
| 1942 |
setConceptOperandsFromClassTerms(defEqConcept,eqClassExp); |
| 1943 |
} else { |
| 1944 |
|
| 1945 |
// build each other inclusion with SubClassOf expressions |
| 1946 |
buildConceptSubClassInclusion(defEqClassExp,eqClassExp); |
| 1947 |
buildConceptSubClassInclusion(eqClassExp,defEqClassExp); |
| 1948 |
} |
| 1949 |
return true; |
| 1950 |
} |
| 1951 |
|
| 1952 |
|
| 1953 |
bool CConcreteOntologyUpdateBuilder::buildConceptSubClassInclusion(CClassTermExpression* subClassExp, CClassTermExpression* inclusionClassExp, bool negate) { |
| 1954 |
if (subClassExp != mBottomClassExpression) { |
| 1955 |
CConcept* concept = getConceptForClassTerm(subClassExp); |
| 1956 |
qint64 opCode = concept->getOperatorCode(); |
| 1957 |
if (opCode == CCEQ) { |
| 1958 |
CSortedNegLinker<CConcept*>* opConLinker = concept->getOperandList(); |
| 1959 |
|
| 1960 |
concept->setOperatorCode(CCSUB); |
| 1961 |
opCode = CCSUB; |
| 1962 |
|
| 1963 |
// there is only one equivalent concept and is not negated by the linker |
| 1964 |
CConcept* eqConcept = opConLinker->getData(); |
| 1965 |
CClassTermExpression* eqClassExp = mConceptClassTermHash->value(eqConcept); |
| 1966 |
if (eqConcept->getOperatorCode() == CCATOM) { |
| 1967 |
concept->setOperandCount(0); |
| 1968 |
concept->setOperandList(nullptr); |
| 1969 |
// order rebuild equivalent class |
| 1970 |
if (mNewBuildedConceptSet.contains(eqClassExp)) { |
| 1971 |
mNewBuildedConceptSet.remove(eqClassExp); |
| 1972 |
} |
| 1973 |
mNewBuildConceptSet.insert(eqClassExp); |
| 1974 |
} else { |
| 1975 |
buildConceptSubClassInclusion(eqClassExp,subClassExp); |
| 1976 |
} |
| 1977 |
|
| 1978 |
} |
| 1979 |
if (opCode == CCSUB || opCode == CCTOP) { |
| 1980 |
// build simple subclass inclusion |
| 1981 |
setConceptOperandsFromClassTerms(concept,inclusionClassExp,negate); |
| 1982 |
} else if (opCode == CCNONE && subClassExp->getType() == CBuildExpression::BETCLASS) { |
| 1983 |
// build simple subclass inclusion |
| 1984 |
setConceptOperandsFromClassTerms(concept,inclusionClassExp,negate); |
| 1985 |
concept->setOperatorCode(CCSUB); |
| 1986 |
} else { |
| 1987 |
// build GCI |
| 1988 |
CClassTermExpression* compSubClassExp = getObjectComplementOf(subClassExp); |
| 1989 |
if (!mConstructFlags->isNonELConstructUsed() && !mInitialBuildConceptSet->contains(compSubClassExp)) { |
| 1990 |
mELExceptionExpressionSet.insert(compSubClassExp); |
| 1991 |
} |
| 1992 |
CClassTermExpression* neIinclusionClassExp = inclusionClassExp; |
| 1993 |
if (negate) { |
| 1994 |
neIinclusionClassExp = getObjectComplementOf(inclusionClassExp); |
| 1995 |
mELExceptionExpressionSet.insert(neIinclusionClassExp); |
| 1996 |
} |
| 1997 |
CClassTermExpression* gciIncusionExp = getObjectUnionOf(CEXPRESSIONLIST<CClassTermExpression*>()<<compSubClassExp<<neIinclusionClassExp); |
| 1998 |
if (!mConstructFlags->isNonELConstructUsed() && !mInitialBuildConceptSet->contains(gciIncusionExp)) { |
| 1999 |
mELExceptionExpressionSet.insert(gciIncusionExp); |
| 2000 |
} |
| 2001 |
buildGeneralConceptInclusionClassExpression(gciIncusionExp); |
| 2002 |
} |
| 2003 |
} |
| 2004 |
return true; |
| 2005 |
} |
| 2006 |
|
| 2007 |
bool CConcreteOntologyUpdateBuilder::buildGeneralConceptInclusionClassExpression(CClassTermExpression* gciClassTermExp) { |
| 2008 |
mClassGCIExpressionSet.insert(gciClassTermExp); |
| 2009 |
mRebuildTopConcept = true; |
| 2010 |
return true; |
| 2011 |
} |
| 2012 |
|
| 2013 |
|
| 2014 |
bool CConcreteOntologyUpdateBuilder::updateName(CNamedItem* item, const QString& name) { |
| 2015 |
bool nameAdded = false; |
| 2016 |
if (!CIRIName::hasIRIName(item->getNameLinker(),name)) { |
| 2017 |
cint64 lastNameID = CName::getLastNameVersionID(item->getNameLinker()); |
| 2018 |
if (lastNameID < 0) { |
| 2019 |
lastNameID = 0; |
| 2020 |
} |
| 2021 |
FOREACHHASHIT (QString prefix, CNamePrefix* namePrefix, *mNamePrefixMapHash) { |
| 2022 |
if (name.startsWith(prefix)) { |
| 2023 |
CAbbreviatedIRIName* newName = CObjectAllocator<CAbbreviatedIRIName>::allocateAndConstruct(mMemManager); |
| 2024 |
QString abbString = name.mid(prefix.length()); |
| 2025 |
newName->init(namePrefix,abbString); |
| 2026 |
newName->setNameVersionID(lastNameID); |
| 2027 |
CLinker<CName*>* newNameLinker = CObjectAllocator< CLinker<CName*> >::allocateAndConstruct(mMemManager); |
| 2028 |
newNameLinker->init(newName); |
| 2029 |
item->addNameLinker(newNameLinker); |
| 2030 |
nameAdded = true; |
| 2031 |
break; |
| 2032 |
} |
| 2033 |
} |
| 2034 |
if (!nameAdded) { |
| 2035 |
CIRIName* newName = CObjectAllocator<CIRIName>::allocateAndConstruct(mMemManager); |
| 2036 |
newName->init(name); |
| 2037 |
newName->setNameVersionID(lastNameID); |
| 2038 |
CLinker<CName*>* newNameLinker = CObjectAllocator< CLinker<CName*> >::allocateAndConstruct(mMemManager); |
| 2039 |
newNameLinker->init(newName); |
| 2040 |
item->addNameLinker(newNameLinker); |
| 2041 |
} |
| 2042 |
} |
| 2043 |
return nameAdded; |
| 2044 |
} |
| 2045 |
|
| 2046 |
|
| 2047 |
|
| 2048 |
CConcept* CConcreteOntologyUpdateBuilder::getConceptForClassTerm(CClassTermExpression* classTermExp, bool forceLocalisation) { |
| 2049 |
CConcept* concept = nullptr; |
| 2050 |
bool forceCreation = false; |
| 2051 |
if (mInitialBuild && (classTermExp == mTopClassExpression || classTermExp == mBottomClassExpression)) { |
| 2052 |
forceLocalisation = true; |
| 2053 |
} |
| 2054 |
concept = mClassTermConceptHash->value(classTermExp); |
| 2055 |
if (concept && concept->getTag() == -1) { |
| 2056 |
forceLocalisation = false; |
| 2057 |
} |
| 2058 |
if (concept && forceLocalisation) { |
| 2059 |
if (!mLocalisationSet.contains(classTermExp)) { |
| 2060 |
forceCreation = true; |
| 2061 |
} |
| 2062 |
} |
| 2063 |
if (!concept || forceCreation) { |
| 2064 |
CConcept* prevConcept = concept; |
| 2065 |
if (forceLocalisation) { |
| 2066 |
mLocalisationSet.insert(classTermExp); |
| 2067 |
} |
| 2068 |
concept = CObjectAllocator<CConcept>::allocateAndConstruct(mMemManager); |
| 2069 |
concept->initConcept(); |
| 2070 |
if (prevConcept) { |
| 2071 |
cint64 prevConceptTag = prevConcept->getConceptTag(); |
| 2072 |
concept->initTag(prevConceptTag); |
| 2073 |
cint64 prevConceptOpCode = prevConcept->getOperatorCode(); |
| 2074 |
if (prevConceptOpCode == CCTOP || prevConceptOpCode == CCBOTTOM) { |
| 2075 |
concept->setOperatorCode(prevConceptOpCode); |
| 2076 |
} |
| 2077 |
mInstallConceptList.append(concept); |
| 2078 |
} else { |
| 2079 |
concept->setTag(-1); |
| 2080 |
mTaggingConceptList.append(concept); |
| 2081 |
} |
| 2082 |
mClassTermConceptHash->insert(classTermExp,concept); |
| 2083 |
mConceptClassTermHash->insert(concept,classTermExp); |
| 2084 |
|
| 2085 |
if (classTermExp->getType() == CBuildExpression::BETCLASS) { |
| 2086 |
// update name |
| 2087 |
CClassExpression* classExp = (CClassExpression*)classTermExp; |
| 2088 |
QString className = classExp->getName(); |
| 2089 |
updateName(concept,className); |
| 2090 |
} |
| 2091 |
} |
| 2092 |
return concept; |
| 2093 |
} |
| 2094 |
|
| 2095 |
CDataLiteral* CConcreteOntologyUpdateBuilder::getDataLiteralForLiteralExpression(CDataLiteralExpression* dataLiteralExp, bool forceLocalisation) { |
| 2096 |
CDatatypeExpression* datatypeExp = dataLiteralExp->getDatatypeExpression(); |
| 2097 |
CDataLexicalValueExpression* lexDatValueExp = dataLiteralExp->getDataLexicalValueExpression(); |
| 2098 |
CDatatype* datatype = getDatatypeForDatatypeExpression(datatypeExp); |
| 2099 |
CDataLiteral*& dataLiteral = (*mLexicalDataExpDatatypePairDataLiteralHash)[QPair<CDataLexicalValueExpression*, CDatatype*>(lexDatValueExp, datatype)]; |
| 2100 |
if (!dataLiteral) { |
| 2101 |
dataLiteral = CObjectParameterizingAllocator<CDataLiteral, CContext*>::allocateAndConstructAndParameterize(mMemManager, mBoxContext); |
| 2102 |
dataLiteral->initDataLiteral(lexDatValueExp->getName(), datatype); |
| 2103 |
} |
| 2104 |
return dataLiteral; |
| 2105 |
} |
| 2106 |
|
| 2107 |
|
| 2108 |
CDatatype* CConcreteOntologyUpdateBuilder::getDatatypeForDatatypeExpression(CDatatypeExpression* datatypeExp, bool forceLocalisation) { |
| 2109 |
CDatatype* datatype = nullptr; |
| 2110 |
datatype = mDatatypeExpDatatypeHash->value(datatypeExp); |
| 2111 |
bool forceCreation = false; |
| 2112 |
if (datatype && forceLocalisation) { |
| 2113 |
if (!mLocalisationSet.contains(datatypeExp)) { |
| 2114 |
forceCreation = true; |
| 2115 |
} |
| 2116 |
} |
| 2117 |
if (!datatype || forceCreation) { |
| 2118 |
if (forceLocalisation) { |
| 2119 |
mLocalisationSet.insert(datatypeExp); |
| 2120 |
} |
| 2121 |
datatype = CObjectAllocator<CDatatype>::allocateAndConstruct(mMemManager); |
| 2122 |
datatype->initDatatype(datatypeExp->getName()); |
| 2123 |
CDatatypeVector* datatypeVec = tBox->getDatatypeVector(); |
| 2124 |
cint64 nextDatatypeTag = datatypeVec->getItemCount(); |
| 2125 |
datatype->setDatatypeTag(nextDatatypeTag); |
| 2126 |
datatypeVec->setData(nextDatatypeTag,datatype); |
| 2127 |
mDatatypeExpDatatypeHash->insert(datatypeExp,datatype); |
| 2128 |
mDatatypeDatatypeExpHash->insert(datatype,datatypeExp); |
| 2129 |
|
| 2130 |
} |
| 2131 |
return datatype; |
| 2132 |
} |
| 2133 |
|
| 2134 |
|
| 2135 |
|
| 2136 |
|
| 2137 |
CConcept* CConcreteOntologyUpdateBuilder::getConceptForDataRangeTerm(CDataRangeTermExpression* dataRangeExp, bool forceLocalisation) { |
| 2138 |
CConcept* concept = nullptr; |
| 2139 |
concept = mDataRangeTermConceptHash->value(dataRangeExp); |
| 2140 |
bool forceCreation = false; |
| 2141 |
if (concept && concept->getTag() == -1) { |
| 2142 |
forceLocalisation = false; |
| 2143 |
} |
| 2144 |
if (concept && forceLocalisation) { |
| 2145 |
if (!mLocalisationSet.contains(dataRangeExp)) { |
| 2146 |
forceCreation = true; |
| 2147 |
} |
| 2148 |
} |
| 2149 |
if (!concept || forceCreation) { |
| 2150 |
CConcept* prevConcept = concept; |
| 2151 |
if (forceLocalisation) { |
| 2152 |
mLocalisationSet.insert(dataRangeExp); |
| 2153 |
} |
| 2154 |
concept = CObjectAllocator<CConcept>::allocateAndConstruct(mMemManager); |
| 2155 |
concept->initConcept(); |
| 2156 |
if (prevConcept) { |
| 2157 |
cint64 prevConceptTag = prevConcept->getConceptTag(); |
| 2158 |
concept->initTag(prevConceptTag); |
| 2159 |
cint64 prevConceptOpCode = prevConcept->getOperatorCode(); |
| 2160 |
mInstallConceptList.append(concept); |
| 2161 |
} else { |
| 2162 |
mTaggingConceptList.append(concept); |
| 2163 |
concept->setTag(-1); |
| 2164 |
} |
| 2165 |
mDataRangeTermConceptHash->insert(dataRangeExp,concept); |
| 2166 |
mConceptDataRangeTermHash->insert(concept,dataRangeExp); |
| 2167 |
} |
| 2168 |
return concept; |
| 2169 |
} |
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
|
| 2174 |
CIndividual* CConcreteOntologyUpdateBuilder::getIndividualForIndividualTerm(CIndividualTermExpression* indiTermExp, bool forceLocalisation) { |
| 2175 |
CIndividual* indi = nullptr; |
| 2176 |
indi = mIndividulTermIndiHash->value(indiTermExp); |
| 2177 |
if (!indi && mIndividualNameIndividualMapHash) { |
| 2178 |
CNamedIndividualExpression* namedIndiExp = (CNamedIndividualExpression*)indiTermExp; |
| 2179 |
indi = mIndividualNameIndividualMapHash->value(namedIndiExp->getName()); |
| 2180 |
} |
| 2181 |
bool forceCreation = false; |
| 2182 |
if (indi && indi->getTag() == -1) { |
| 2183 |
forceLocalisation = false; |
| 2184 |
} |
| 2185 |
if (indi && forceLocalisation) { |
| 2186 |
if (!mLocalisationSet.contains(indiTermExp)) { |
| 2187 |
forceCreation = true; |
| 2188 |
} |
| 2189 |
} |
| 2190 |
if (!indi || forceCreation) { |
| 2191 |
CIndividual* prevIndi = indi; |
| 2192 |
if (forceLocalisation) { |
| 2193 |
mLocalisationSet.insert(indiTermExp); |
| 2194 |
} |
| 2195 |
indi = CObjectAllocator<CIndividual>::allocateAndConstruct(mMemManager); |
| 2196 |
indi->initIndividual(); |
| 2197 |
|
| 2198 |
QString indiName; |
| 2199 |
if (indiTermExp->getType() == CBuildExpression::BETNAMEDINDIVIDUAL) { |
| 2200 |
CNamedIndividualExpression* namedIndiExp = (CNamedIndividualExpression*)indiTermExp; |
| 2201 |
indiName = namedIndiExp->getName(); |
| 2202 |
} else if (indiTermExp->getType() == CBuildExpression::BETANONYMOUSINDIVIDUAL) { |
| 2203 |
CAnonymousIndividualExpression* anonymousIndiExp = (CAnonymousIndividualExpression*)indiTermExp; |
| 2204 |
indiName = anonymousIndiExp->getName(); |
| 2205 |
} |
| 2206 |
|
| 2207 |
cint64 useIndiTag = -1; |
| 2208 |
if (prevIndi) { |
| 2209 |
useIndiTag = prevIndi->getIndividualID(); |
| 2210 |
} else if (mIndexedTriplesAssertionAccessor) { |
| 2211 |
useIndiTag = mIndexedTriplesAssertionAccessor->getIndividualId(indiName); |
| 2212 |
} |
| 2213 |
|
| 2214 |
if (useIndiTag >= 0) { |
| 2215 |
indi->initTag(useIndiTag); |
| 2216 |
mInstallIndividualList.append(indi); |
| 2217 |
} else { |
| 2218 |
mTaggingIndividualSet.append(indi); |
| 2219 |
indi->setTag(-1); |
| 2220 |
} |
| 2221 |
mIndividulTermIndiHash->insert(indiTermExp,indi); |
| 2222 |
mIndiIndividulTermHash->insert(indi,indiTermExp); |
| 2223 |
|
| 2224 |
updateName(indi, indiName); |
| 2225 |
if (indiTermExp->getType() == CBuildExpression::BETANONYMOUSINDIVIDUAL) { |
| 2226 |
indi->setAnonymousIndividual(true); |
| 2227 |
} |
| 2228 |
|
| 2229 |
|
| 2230 |
} |
| 2231 |
return indi; |
| 2232 |
} |
| 2233 |
|
| 2234 |
|
| 2235 |
|
| 2236 |
|
| 2237 |
CRole* CConcreteOntologyUpdateBuilder::getRoleForDataPropertyTerm(CDataPropertyTermExpression* dataPropTermExp, bool forceLocalisation) { |
| 2238 |
CRole* role = nullptr; |
| 2239 |
role = mDataPropTermRoleHash->value(dataPropTermExp); |
| 2240 |
bool forceCreation = false; |
| 2241 |
if (mInitialBuild && dataPropTermExp == mTopDataPropExpression) { |
| 2242 |
mConstructFlags->setTopDataRoleUsed(); |
| 2243 |
forceLocalisation = true; |
| 2244 |
} else if (mInitialBuild && dataPropTermExp == mBottomDataPropExpression) { |
| 2245 |
mConstructFlags->setBottomDataRoleUsed(); |
| 2246 |
forceLocalisation = true; |
| 2247 |
} |
| 2248 |
if (role && role->getTag() == -1) { |
| 2249 |
forceLocalisation = false; |
| 2250 |
} |
| 2251 |
if (role && forceLocalisation) { |
| 2252 |
if (!mLocalisationSet.contains(dataPropTermExp)) { |
| 2253 |
forceCreation = true; |
| 2254 |
} |
| 2255 |
} |
| 2256 |
if (!role || forceCreation) { |
| 2257 |
CRole* prevRole = role; |
| 2258 |
if (forceLocalisation) { |
| 2259 |
mLocalisationSet.insert(dataPropTermExp); |
| 2260 |
} |
| 2261 |
role = CObjectAllocator<CRole>::allocateAndConstruct(mMemManager); |
| 2262 |
role->initRole(); |
| 2263 |
if (prevRole) { |
| 2264 |
role->initTag(prevRole->getRoleTag()); |
| 2265 |
mInstallRoleList.append(role); |
| 2266 |
} else { |
| 2267 |
mTaggingRoleSet.insert(role); |
| 2268 |
role->setTag(-1); |
| 2269 |
} |
| 2270 |
role->setDataRole(true); |
| 2271 |
mDataPropTermRoleHash->insert(dataPropTermExp,role); |
| 2272 |
mRoleDataPropTermHash->insert(role,dataPropTermExp); |
| 2273 |
|
| 2274 |
if (dataPropTermExp->getType() == CBuildExpression::BETDATAPROPERTY) { |
| 2275 |
// update name |
| 2276 |
CDataPropertyExpression* dataPropExp = (CDataPropertyExpression*)dataPropTermExp; |
| 2277 |
QString propName = dataPropExp->getName(); |
| 2278 |
updateName(role,propName); |
| 2279 |
} |
| 2280 |
|
| 2281 |
} |
| 2282 |
return role; |
| 2283 |
} |
| 2284 |
|
| 2285 |
|
| 2286 |
CRole* CConcreteOntologyUpdateBuilder::getRoleForObjectPropertyTerm(CObjectPropertyTermExpression* objPropTermExp, bool forceLocalisation) { |
| 2287 |
CRole* role = nullptr; |
| 2288 |
role = mObjPropTermRoleHash->value(objPropTermExp); |
| 2289 |
bool forceCreation = false; |
| 2290 |
if (mInitialBuild && objPropTermExp == mTopObjPropExpression) { |
| 2291 |
mConstructFlags->setTopObjectRoleUsed(); |
| 2292 |
forceLocalisation = true; |
| 2293 |
} else if (mInitialBuild && objPropTermExp == mBottomObjPropExpression) { |
| 2294 |
mConstructFlags->setBottomObjectRoleUsed(); |
| 2295 |
forceLocalisation = true; |
| 2296 |
} |
| 2297 |
if (role && role->getTag() == -1) { |
| 2298 |
forceLocalisation = false; |
| 2299 |
} |
| 2300 |
|
| 2301 |
if (role && forceLocalisation) { |
| 2302 |
if (!mLocalisationSet.contains(objPropTermExp)) { |
| 2303 |
forceCreation = true; |
| 2304 |
} |
| 2305 |
} |
| 2306 |
if (!role || forceCreation) { |
| 2307 |
CRole* prevRole = role; |
| 2308 |
if (forceLocalisation) { |
| 2309 |
mLocalisationSet.insert(objPropTermExp); |
| 2310 |
} |
| 2311 |
role = CObjectAllocator<CRole>::allocateAndConstruct(mMemManager); |
| 2312 |
role->initRole(); |
| 2313 |
if (prevRole) { |
| 2314 |
role->initTag(prevRole->getRoleTag()); |
| 2315 |
mInstallRoleList.append(role); |
| 2316 |
} else { |
| 2317 |
mTaggingRoleSet.insert(role); |
| 2318 |
role->setTag(-1); |
| 2319 |
} |
| 2320 |
mObjPropTermRoleHash->insert(objPropTermExp,role); |
| 2321 |
mRoleObjPropTermHash->insert(role,objPropTermExp); |
| 2322 |
|
| 2323 |
if (objPropTermExp->getType() == CBuildExpression::BETOBJECTPROPERTY) { |
| 2324 |
// update name |
| 2325 |
CObjectPropertyExpression* objPropExp = (CObjectPropertyExpression*)objPropTermExp; |
| 2326 |
QString propName = objPropExp->getName(); |
| 2327 |
updateName(role,propName); |
| 2328 |
} |
| 2329 |
|
| 2330 |
} |
| 2331 |
return role; |
| 2332 |
} |
| 2333 |
|
| 2334 |
|
| 2335 |
bool CConcreteOntologyUpdateBuilder::setConceptNominalIndividualFromIndividualTerm(CConcept* concept, CIndividualTermExpression* indiTermExp) { |
| 2336 |
CIndividual* opIndi = getIndividualForIndividualTerm(indiTermExp,false); |
| 2337 |
concept->setNominalIndividual(opIndi); |
| 2338 |
if (!opIndi->getIndividualNominalConcept()) { |
| 2339 |
opIndi->setIndividualNominalConcept(concept); |
| 2340 |
} |
| 2341 |
return true; |
| 2342 |
} |
| 2343 |
|
| 2344 |
|
| 2345 |
bool CConcreteOntologyUpdateBuilder::setConceptIndividualFromIndividualTerm(CConcept* concept, CIndividualTermExpression* indiTermExp) { |
| 2346 |
CIndividual* opIndi = getIndividualForIndividualTerm(indiTermExp,false); |
| 2347 |
concept->setNominalIndividual(opIndi); |
| 2348 |
return true; |
| 2349 |
} |
| 2350 |
|
| 2351 |
|
| 2352 |
bool CConcreteOntologyUpdateBuilder::setConceptRoleFromObjectPropertyTerm(CConcept* concept, CObjectPropertyTermExpression* objectPropertyTermExp) { |
| 2353 |
CRole* opRole = getRoleForObjectPropertyTerm(objectPropertyTermExp); |
| 2354 |
concept->setRole(opRole); |
| 2355 |
return true; |
| 2356 |
} |
| 2357 |
|
| 2358 |
bool CConcreteOntologyUpdateBuilder::setConceptRoleFromDataPropertyTerm(CConcept* concept, CDataPropertyTermExpression* dataPropertyTermExp) { |
| 2359 |
CRole* opRole = getRoleForDataPropertyTerm(dataPropertyTermExp); |
| 2360 |
concept->setRole(opRole); |
| 2361 |
return true; |
| 2362 |
} |
| 2363 |
|
| 2364 |
|
| 2365 |
cint64 CConcreteOntologyUpdateBuilder::getIndividualVariableID(CConcept* concept, CObjectIndividualVariableExpression* objectIndVarExp) { |
| 2366 |
cint64 indVarID = mIndividualVariableIDHash->value(objectIndVarExp,0); |
| 2367 |
if (indVarID <= 0) { |
| 2368 |
indVarID = mIndividualVariableIDHash->count()+1; |
| 2369 |
mIndividualVariableIDHash->insert(objectIndVarExp,indVarID); |
| 2370 |
} |
| 2371 |
return indVarID; |
| 2372 |
} |
| 2373 |
|
| 2374 |
|
| 2375 |
|
| 2376 |
bool CConcreteOntologyUpdateBuilder::setConceptOperandsFromClassTerms(CConcept* concept, CEXPRESSIONLIST<CClassTermExpression*>* classTermList, bool negate) { |
| 2377 |
FOREACHIT (CClassTermExpression* classTermExp, *classTermList) { |
| 2378 |
CConcept* opConcept = getConceptForClassTerm(classTermExp); |
| 2379 |
//if (!concept->hasOperandConcept(opConcept,negate)) { |
| 2380 |
bool opConNegation = negate; |
| 2381 |
CSortedNegLinker<CConcept*>* opConLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 2382 |
if (opConcept->hasMappingNegation()) { |
| 2383 |
opConNegation = !opConNegation; |
| 2384 |
} |
| 2385 |
opConLinker->init(opConcept, opConNegation); |
| 2386 |
concept->addOperandLinker(opConLinker); |
| 2387 |
concept->incOperandCount(); |
| 2388 |
//} |
| 2389 |
} |
| 2390 |
return true; |
| 2391 |
} |
| 2392 |
|
| 2393 |
bool CConcreteOntologyUpdateBuilder::setIndividualAssertionRoleFromObjectPropertyTerm(CIndividual* individual, CObjectPropertyTermExpression* objPropTermExp, CIndividualTermExpression* destIndiTermExp) { |
| 2394 |
CIndividual* desIndividual = getIndividualForIndividualTerm(destIndiTermExp); |
| 2395 |
CRole* role = getRoleForObjectPropertyTerm(objPropTermExp); |
| 2396 |
CRoleAssertionLinker* roleAssLinker = CObjectAllocator< CRoleAssertionLinker >::allocateAndConstruct(mMemManager); |
| 2397 |
roleAssLinker->initRoleAssertionLinker(role,desIndividual); |
| 2398 |
individual->addAssertionRoleLinker(roleAssLinker); |
| 2399 |
return true; |
| 2400 |
} |
| 2401 |
|
| 2402 |
bool CConcreteOntologyUpdateBuilder::setIndividualAssertionConceptFromClassTerm(CIndividual* individual, CClassTermExpression* classTermExp, bool negate) { |
| 2403 |
CConcept* opConcept = getConceptForClassTerm((CClassTermExpression*)classTermExp); |
| 2404 |
CConceptAssertionLinker* opConLinker = CObjectAllocator< CConceptAssertionLinker >::allocateAndConstruct(mMemManager); |
| 2405 |
opConLinker->initNegLinker(opConcept,negate); |
| 2406 |
individual->addAssertionConceptLinker(opConLinker); |
| 2407 |
return true; |
| 2408 |
} |
| 2409 |
|
| 2410 |
bool CConcreteOntologyUpdateBuilder::setIndividualAssertionDataFromDataLiteralTerm(CIndividual* individual, CDataPropertyTermExpression* dataPropTermExp, CDataLiteralExpression* dataLitExp) { |
| 2411 |
CRole* role = getRoleForDataPropertyTerm(dataPropTermExp); |
| 2412 |
CDataLiteral* dataLiteral = getDataLiteralForLiteralExpression(dataLitExp); |
| 2413 |
CDataAssertionLinker* dataAssLinker = CObjectAllocator< CDataAssertionLinker >::allocateAndConstruct(mMemManager); |
| 2414 |
dataAssLinker->initDataAssertionLinker(role, dataLiteral); |
| 2415 |
individual->addAssertionDataLinker(dataAssLinker); |
| 2416 |
return true; |
| 2417 |
} |
| 2418 |
|
| 2419 |
bool CConcreteOntologyUpdateBuilder::setIndividualAssertionNominalFromClassTerm(CIndividual* individual, CClassTermExpression* classTermExp, bool negate) { |
| 2420 |
CConcept* opConcept = getConceptForClassTerm((CClassTermExpression*)classTermExp); |
| 2421 |
individual->setIndividualNominalConcept(opConcept); |
| 2422 |
CConceptAssertionLinker* opConLinker = CObjectAllocator< CConceptAssertionLinker >::allocateAndConstruct(mMemManager); |
| 2423 |
opConLinker->initNegLinker(opConcept,negate); |
| 2424 |
individual->addAssertionConceptLinker(opConLinker); |
| 2425 |
return true; |
| 2426 |
} |
| 2427 |
|
| 2428 |
|
| 2429 |
bool CConcreteOntologyUpdateBuilder::setConceptOperandsFromClassTerms(CConcept* concept, CClassTermExpression* classTermExp, bool negate) { |
| 2430 |
if (classTermExp) { |
| 2431 |
CConcept* opConcept = getConceptForClassTerm((CClassTermExpression*)classTermExp); |
| 2432 |
//if (!concept->hasOperandConcept(opConcept,negate)) { |
| 2433 |
CSortedNegLinker<CConcept*>* opConLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 2434 |
if (opConcept->hasMappingNegation()) { |
| 2435 |
negate = !negate; |
| 2436 |
} |
| 2437 |
opConLinker->init(opConcept,negate); |
| 2438 |
concept->addOperandLinker(opConLinker); |
| 2439 |
concept->incOperandCount(); |
| 2440 |
//} |
| 2441 |
return true; |
| 2442 |
} |
| 2443 |
return false; |
| 2444 |
} |
| 2445 |
|
| 2446 |
|
| 2447 |
bool CConcreteOntologyUpdateBuilder::setConceptOperandsFromDataRangeTerms(CConcept* concept, CDataRangeTermExpression* dataRangeTermExp, bool negate) { |
| 2448 |
if (dataRangeTermExp) { |
| 2449 |
CConcept* opConcept = getConceptForDataRangeTerm(dataRangeTermExp); |
| 2450 |
//if (!concept->hasOperandConcept(opConcept,negate)) { |
| 2451 |
CSortedNegLinker<CConcept*>* opConLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 2452 |
if (opConcept->hasMappingNegation()) { |
| 2453 |
negate = !negate; |
| 2454 |
} |
| 2455 |
opConLinker->init(opConcept,negate); |
| 2456 |
concept->addOperandLinker(opConLinker); |
| 2457 |
concept->incOperandCount(); |
| 2458 |
//} |
| 2459 |
return true; |
| 2460 |
} |
| 2461 |
return false; |
| 2462 |
} |
| 2463 |
|
| 2464 |
bool CConcreteOntologyUpdateBuilder::setConceptOperandsFromDataRangeTerms(CConcept* concept, CEXPRESSIONLIST<CDataRangeTermExpression*>* dataRangeTermExpList, bool negate) { |
| 2465 |
FOREACHIT (CDataRangeTermExpression* dataRangeTermExp, *dataRangeTermExpList) { |
| 2466 |
CConcept* opConcept = getConceptForDataRangeTerm(dataRangeTermExp); |
| 2467 |
//if (!concept->hasOperandConcept(opConcept,negate)) { |
| 2468 |
CSortedNegLinker<CConcept*>* opConLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 2469 |
if (opConcept->hasMappingNegation()) { |
| 2470 |
negate = !negate; |
| 2471 |
} |
| 2472 |
opConLinker->init(opConcept,negate); |
| 2473 |
concept->addOperandLinker(opConLinker); |
| 2474 |
concept->incOperandCount(); |
| 2475 |
//} |
| 2476 |
} |
| 2477 |
return true; |
| 2478 |
} |
| 2479 |
|
| 2480 |
bool CConcreteOntologyUpdateBuilder::setConceptOperands(CConcept* concept, CConcept* operandConcept, bool negate) { |
| 2481 |
//if (!concept->hasOperandConcept(operandConcept,negate)) { |
| 2482 |
CSortedNegLinker<CConcept*>* opConLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemManager); |
| 2483 |
if (operandConcept->hasMappingNegation()) { |
| 2484 |
negate = !negate; |
| 2485 |
} |
| 2486 |
opConLinker->init(operandConcept,negate); |
| 2487 |
concept->addOperandLinker(opConLinker); |
| 2488 |
concept->incOperandCount(); |
| 2489 |
//} |
| 2490 |
return true; |
| 2491 |
} |
| 2492 |
|
| 2493 |
|
| 2494 |
bool CConcreteOntologyUpdateBuilder::tellOntologyAxiom(CAxiomExpression* axiom) { |
| 2495 |
if (!mTellAxiomSet->contains(axiom)) { |
| 2496 |
mRetractAxiomSet->remove(axiom); |
| 2497 |
mTellAxiomSet->insert(axiom); |
| 2498 |
if (mRetractUpdatedAxiomSet->contains(axiom)) { |
| 2499 |
mRetractUpdatedAxiomSet->remove(axiom); |
| 2500 |
} else { |
| 2501 |
mTellUpdatedAxiomSet->insert(axiom); |
| 2502 |
} |
| 2503 |
} |
| 2504 |
return true; |
| 2505 |
} |
| 2506 |
|
| 2507 |
bool CConcreteOntologyUpdateBuilder::retractOntologyAxiom(CAxiomExpression* axiom) { |
| 2508 |
if (mTellAxiomSet->contains(axiom)) { |
| 2509 |
mTellAxiomSet->remove(axiom); |
| 2510 |
mRetractAxiomSet->insert(axiom); |
| 2511 |
if (mTellUpdatedAxiomSet->contains(axiom)) { |
| 2512 |
mTellUpdatedAxiomSet->remove(axiom); |
| 2513 |
} else { |
| 2514 |
mRetractUpdatedAxiomSet->insert(axiom); |
| 2515 |
} |
| 2516 |
} |
| 2517 |
return true; |
| 2518 |
} |
| 2519 |
|
| 2520 |
|
| 2521 |
bool CConcreteOntologyUpdateBuilder::buildRoleTags() { |
| 2522 |
cint64 nextRoleTag = rBox->getRoleCount(); |
| 2523 |
FOREACHIT (CRole* role, mTaggingRoleSet) { |
| 2524 |
role->setRoleTag(nextRoleTag++); |
| 2525 |
mInstallRoleList.append(role); |
| 2526 |
} |
| 2527 |
return true; |
| 2528 |
} |
| 2529 |
|
| 2530 |
|
| 2531 |
bool CConcreteOntologyUpdateBuilder::buildIndividualIDs() { |
| 2532 |
cint64 nextIndiID = aBox->getIndividualCount(); |
| 2533 |
|
| 2534 |
|
| 2535 |
|
| 2536 |
class CIndividualTaggingDependingItem : public CIndividualData { |
| 2537 |
public: |
| 2538 |
CIndividualTaggingDependingItem() { |
| 2539 |
mDependent = false; |
| 2540 |
} |
| 2541 |
public: |
| 2542 |
bool mDependent; |
| 2543 |
}; |
| 2544 |
|
| 2545 |
|
| 2546 |
cint64 taggingCount = mTaggingIndividualSet.count(); |
| 2547 |
CIndividualTaggingDependingItem* taggingItemVec = new CIndividualTaggingDependingItem[taggingCount]; |
| 2548 |
|
| 2549 |
cint64 itemIdx = 0; |
| 2550 |
for (CBUILDLIST<CIndividual*>::const_iterator it1 = mTaggingIndividualSet.constBegin(), it1End = mTaggingIndividualSet.constEnd(); it1 != it1End; ++it1) { |
| 2551 |
CIndividual* individual = *it1; |
| 2552 |
if (!individual->hasIndividualData()) { |
| 2553 |
CIndividualTaggingDependingItem* taggingItem = &taggingItemVec[itemIdx++]; |
| 2554 |
individual->setIndividualData(taggingItem); |
| 2555 |
} |
| 2556 |
} |
| 2557 |
|
| 2558 |
CBUILDLIST<CIndividual*> dependedIndividualList; |
| 2559 |
CBUILDLIST<CIndividual*> directIndividualList; |
| 2560 |
CBUILDLIST<CIndividual*> currentIndividualList; |
| 2561 |
|
| 2562 |
for (CBUILDLIST<CIndividual*>::const_iterator it1 = mTaggingIndividualSet.constBegin(), it1End = mTaggingIndividualSet.constEnd(); it1 != it1End; ++it1) { |
| 2563 |
CIndividual* individual = *it1; |
| 2564 |
for (CRoleAssertionLinker* roleAssLinkIt = individual->getAssertionRoleLinker(); roleAssLinkIt; roleAssLinkIt = roleAssLinkIt->getNext()) { |
| 2565 |
CIndividual* otIndi = roleAssLinkIt->getIndividual(); |
| 2566 |
if (otIndi->getIndividualID() <= 0) { |
| 2567 |
CIndividualTaggingDependingItem* taggingItem = (CIndividualTaggingDependingItem*)otIndi->getIndividualData(); |
| 2568 |
if (taggingItem && !taggingItem->mDependent) { |
| 2569 |
taggingItem->mDependent = true; |
| 2570 |
dependedIndividualList.append(otIndi); |
| 2571 |
} |
| 2572 |
} |
| 2573 |
} |
| 2574 |
} |
| 2575 |
for (CBUILDLIST<CIndividual*>::const_iterator it1 = mTaggingIndividualSet.constBegin(), it1End = mTaggingIndividualSet.constEnd(); it1 != it1End; ++it1) { |
| 2576 |
CIndividual* individual = *it1; |
| 2577 |
CIndividualTaggingDependingItem* taggingItem = (CIndividualTaggingDependingItem*)individual->getIndividualData(); |
| 2578 |
if (!taggingItem->mDependent) { |
| 2579 |
directIndividualList.append(individual); |
| 2580 |
} |
| 2581 |
} |
| 2582 |
CBUILDLIST<CIndividual*> taggingIndividualList; |
| 2583 |
while (!directIndividualList.isEmpty() || !dependedIndividualList.isEmpty()) { |
| 2584 |
CIndividual* individual = nullptr; |
| 2585 |
if (currentIndividualList.isEmpty() && !directIndividualList.isEmpty()) { |
| 2586 |
individual = directIndividualList.takeFirst(); |
| 2587 |
currentIndividualList.append(individual); |
| 2588 |
} |
| 2589 |
if (currentIndividualList.isEmpty() && !dependedIndividualList.isEmpty()) { |
| 2590 |
CIndividual* individual = dependedIndividualList.takeFirst(); |
| 2591 |
CIndividualTaggingDependingItem* taggingItem = (CIndividualTaggingDependingItem*)individual->getIndividualData(); |
| 2592 |
if (taggingItem && taggingItem->mDependent) { |
| 2593 |
taggingItem->mDependent = false; |
| 2594 |
currentIndividualList.append(individual); |
| 2595 |
} |
| 2596 |
} |
| 2597 |
CBUILDLIST<CIndividual*> nextTaggingConceptList; |
| 2598 |
while (!currentIndividualList.isEmpty()) { |
| 2599 |
individual = currentIndividualList.takeFirst(); |
| 2600 |
nextTaggingConceptList.append(individual); |
| 2601 |
|
| 2602 |
for (CRoleAssertionLinker* roleAssLinkIt = individual->getAssertionRoleLinker(); roleAssLinkIt; roleAssLinkIt = roleAssLinkIt->getNext()) { |
| 2603 |
CIndividual* otIndi = roleAssLinkIt->getIndividual(); |
| 2604 |
if (otIndi->getIndividualID() <= 0) { |
| 2605 |
CIndividualTaggingDependingItem* taggingItem = (CIndividualTaggingDependingItem*)otIndi->getIndividualData(); |
| 2606 |
if (taggingItem && taggingItem->mDependent) { |
| 2607 |
taggingItem->mDependent = false; |
| 2608 |
currentIndividualList.append(otIndi); |
| 2609 |
} |
| 2610 |
} |
| 2611 |
} |
| 2612 |
} |
| 2613 |
for (CBUILDLIST<CIndividual*>::const_iterator it1 = nextTaggingConceptList.constBegin(), it1End = nextTaggingConceptList.constEnd(); it1 != it1End; ++it1) { |
| 2614 |
taggingIndividualList.append(*it1); |
| 2615 |
} |
| 2616 |
|
| 2617 |
} |
| 2618 |
for (CBUILDLIST<CIndividual*>::const_iterator it1 = taggingIndividualList.constBegin(), it1End = taggingIndividualList.constEnd(); it1 != it1End; ++it1) { |
| 2619 |
CIndividual* taggingIndividual = *it1; |
| 2620 |
taggingIndividual->setIndividualID(nextIndiID++); |
| 2621 |
mInstallIndividualList.append(taggingIndividual); |
| 2622 |
} |
| 2623 |
|
| 2624 |
for (CBUILDLIST<CIndividual*>::const_iterator it1 = mTaggingIndividualSet.constBegin(), it1End = mTaggingIndividualSet.constEnd(); it1 != it1End; ++it1) { |
| 2625 |
CIndividual* individual = *it1; |
| 2626 |
individual->setIndividualData(nullptr); |
| 2627 |
} |
| 2628 |
|
| 2629 |
delete [] taggingItemVec; |
| 2630 |
|
| 2631 |
|
| 2632 |
|
| 2633 |
|
| 2634 |
//FOREACHIT (CIndividual* indi, mTaggingIndividualSet) { |
| 2635 |
|
| 2636 |
// QString indiName = CIRIName::getRecentIRIName(indi->getIndividualNameLinker()); |
| 2637 |
// indiName = indiName.replace("file:/C:/temp/s",""); |
| 2638 |
// cint64 indiNameID = indiName.toLongLong(); |
| 2639 |
// indi->setIndividualID(indiNameID); |
| 2640 |
|
| 2641 |
// //indi->setIndividualID(nextIndiID++); |
| 2642 |
// mInstallIndividualList.append(indi); |
| 2643 |
//} |
| 2644 |
return true; |
| 2645 |
} |
| 2646 |
|
| 2647 |
|
| 2648 |
|
| 2649 |
bool CConcreteOntologyUpdateBuilder::buildRoleChainTags() { |
| 2650 |
cint64 nextRoleChainTag = rBox->getRoleChainCount(); |
| 2651 |
FOREACHIT (CRoleChain* roleChain, mTaggingRoleChainSet) { |
| 2652 |
roleChain->setRoleChainTag(nextRoleChainTag++); |
| 2653 |
mInstallRoleChainList.append(roleChain); |
| 2654 |
} |
| 2655 |
return true; |
| 2656 |
} |
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
bool CConcreteOntologyUpdateBuilder::buildConceptTags() { |
| 2661 |
cint64 lastFreeConceptTag = tBox->getConceptCount(); |
| 2662 |
|
| 2663 |
class CConceptTaggingDependingItem : public CConceptData { |
| 2664 |
public: |
| 2665 |
CConceptTaggingDependingItem() { |
| 2666 |
mDependent = false; |
| 2667 |
} |
| 2668 |
public: |
| 2669 |
bool mDependent; |
| 2670 |
}; |
| 2671 |
|
| 2672 |
|
| 2673 |
cint64 taggingCount = mTaggingConceptList.count(); |
| 2674 |
CConceptTaggingDependingItem* taggingItemVec = new CConceptTaggingDependingItem[taggingCount]; |
| 2675 |
|
| 2676 |
cint64 itemIdx = 0; |
| 2677 |
for (CBUILDLIST<CConcept*>::const_iterator it1 = mTaggingConceptList.constBegin(), it1End = mTaggingConceptList.constEnd(); it1 != it1End; ++it1) { |
| 2678 |
CConcept* concept = *it1; |
| 2679 |
if (!concept->hasConceptData()) { |
| 2680 |
CConceptTaggingDependingItem* taggingItem = &taggingItemVec[itemIdx++]; |
| 2681 |
concept->setConceptData(taggingItem); |
| 2682 |
} |
| 2683 |
} |
| 2684 |
|
| 2685 |
CBUILDLIST<CConcept*> dependedConceptList; |
| 2686 |
CBUILDLIST<CConcept*> directConceptList; |
| 2687 |
CBUILDLIST<CConcept*> currentConceptList; |
| 2688 |
|
| 2689 |
for (CBUILDLIST<CConcept*>::const_iterator it1 = mTaggingConceptList.constBegin(), it1End = mTaggingConceptList.constEnd(); it1 != it1End; ++it1) { |
| 2690 |
CConcept* concept = *it1; |
| 2691 |
CSortedNegLinker<CConcept*>* opConLinker = concept->getOperandList(); |
| 2692 |
while (opConLinker) { |
| 2693 |
CConcept* opConcept = opConLinker->getData(); |
| 2694 |
if (opConcept && opConcept->getConceptTag() == -1) { |
| 2695 |
CConceptTaggingDependingItem* taggingItem = (CConceptTaggingDependingItem*)opConcept->getConceptData(); |
| 2696 |
if (taggingItem && !taggingItem->mDependent) { |
| 2697 |
taggingItem->mDependent = true; |
| 2698 |
dependedConceptList.append(opConcept); |
| 2699 |
} |
| 2700 |
} |
| 2701 |
opConLinker = opConLinker->getNext(); |
| 2702 |
} |
| 2703 |
} |
| 2704 |
for (CBUILDLIST<CConcept*>::const_iterator it1 = mTaggingConceptList.constBegin(), it1End = mTaggingConceptList.constEnd(); it1 != it1End; ++it1) { |
| 2705 |
CConcept* concept = *it1; |
| 2706 |
CConceptTaggingDependingItem* taggingItem = (CConceptTaggingDependingItem*)concept->getConceptData(); |
| 2707 |
if (!taggingItem->mDependent) { |
| 2708 |
directConceptList.append(concept); |
| 2709 |
} |
| 2710 |
} |
| 2711 |
CBUILDLIST<CConcept*> taggingConceptList; |
| 2712 |
while (!directConceptList.isEmpty() || !dependedConceptList.isEmpty()) { |
| 2713 |
CConcept* concept = nullptr; |
| 2714 |
if (currentConceptList.isEmpty() && !directConceptList.isEmpty()) { |
| 2715 |
concept = directConceptList.takeFirst(); |
| 2716 |
currentConceptList.append(concept); |
| 2717 |
} |
| 2718 |
if (currentConceptList.isEmpty() && !dependedConceptList.isEmpty()) { |
| 2719 |
CConcept* concept = dependedConceptList.takeFirst(); |
| 2720 |
CConceptTaggingDependingItem* taggingItem = (CConceptTaggingDependingItem*)concept->getConceptData(); |
| 2721 |
if (taggingItem && taggingItem->mDependent) { |
| 2722 |
taggingItem->mDependent = false; |
| 2723 |
currentConceptList.append(concept); |
| 2724 |
} |
| 2725 |
} |
| 2726 |
CBUILDLIST<CConcept*> nextTaggingConceptList; |
| 2727 |
while (!currentConceptList.isEmpty()) { |
| 2728 |
concept = currentConceptList.takeFirst(); |
| 2729 |
nextTaggingConceptList.prepend(concept); |
| 2730 |
|
| 2731 |
CSortedNegLinker<CConcept*>* opConLinker = concept->getOperandList(); |
| 2732 |
while (opConLinker) { |
| 2733 |
CConcept* opConcept = opConLinker->getData(); |
| 2734 |
if (opConcept && opConcept->getConceptTag() == -1) { |
| 2735 |
CConceptTaggingDependingItem* taggingItem = (CConceptTaggingDependingItem*)opConcept->getConceptData(); |
| 2736 |
if (taggingItem && taggingItem->mDependent) { |
| 2737 |
taggingItem->mDependent = false; |
| 2738 |
currentConceptList.append(opConcept); |
| 2739 |
} |
| 2740 |
} |
| 2741 |
opConLinker = opConLinker->getNext(); |
| 2742 |
} |
| 2743 |
} |
| 2744 |
for (CBUILDLIST<CConcept*>::const_iterator it1 = nextTaggingConceptList.constBegin(), it1End = nextTaggingConceptList.constEnd(); it1 != it1End; ++it1) { |
| 2745 |
taggingConceptList.append(*it1); |
| 2746 |
} |
| 2747 |
|
| 2748 |
} |
| 2749 |
for (CBUILDLIST<CConcept*>::const_iterator it1 = taggingConceptList.constBegin(), it1End = taggingConceptList.constEnd(); it1 != it1End; ++it1) { |
| 2750 |
CConcept* taggingConcept = *it1; |
| 2751 |
taggingConcept->setConceptTag(lastFreeConceptTag++); |
| 2752 |
mInstallConceptList.append(taggingConcept); |
| 2753 |
} |
| 2754 |
|
| 2755 |
for (CBUILDLIST<CConcept*>::const_iterator it1 = mTaggingConceptList.constBegin(), it1End = mTaggingConceptList.constEnd(); it1 != it1End; ++it1) { |
| 2756 |
CConcept* concept = *it1; |
| 2757 |
concept->setConceptData(nullptr); |
| 2758 |
} |
| 2759 |
|
| 2760 |
delete [] taggingItemVec; |
| 2761 |
|
| 2762 |
|
| 2763 |
|
| 2764 |
|
| 2765 |
//CBUILDSET<CConcept*> dependedConceptSet; |
| 2766 |
//CBUILDSET<CConcept*> taggedConceptSet; |
| 2767 |
//CBUILDLIST<CConcept*> directConceptList; |
| 2768 |
//CBUILDLIST<CConcept*> currentConceptList; |
| 2769 |
//for (CBUILDSET<CConcept*>::const_iterator it1 = mTaggingConceptSet.constBegin(), it1End = mTaggingConceptSet.constEnd(); it1 != it1End; ++it1) { |
| 2770 |
// CConcept* concept = *it1; |
| 2771 |
// CSortedNegLinker<CConcept*>* opConLinker = concept->getOperandList(); |
| 2772 |
// while (opConLinker) { |
| 2773 |
// CConcept* opConcept = opConLinker->getData(); |
| 2774 |
// if (opConcept && mTaggingConceptSet.contains(opConcept)) { |
| 2775 |
// dependedConceptSet.insert(opConcept); |
| 2776 |
// } |
| 2777 |
// opConLinker = opConLinker->getNext(); |
| 2778 |
// } |
| 2779 |
//} |
| 2780 |
//for (CBUILDSET<CConcept*>::const_iterator it1 = mTaggingConceptSet.constBegin(), it1End = mTaggingConceptSet.constEnd(); it1 != it1End; ++it1) { |
| 2781 |
// CConcept* concept = *it1; |
| 2782 |
// if (!dependedConceptSet.contains(concept)) { |
| 2783 |
// directConceptList.append(concept); |
| 2784 |
// } |
| 2785 |
//} |
| 2786 |
//CBUILDLIST<CConcept*> taggingConceptList; |
| 2787 |
//while (!directConceptList.isEmpty() || !dependedConceptSet.isEmpty()) { |
| 2788 |
// CConcept* concept = nullptr; |
| 2789 |
// if (currentConceptList.isEmpty() && !directConceptList.isEmpty()) { |
| 2790 |
// concept = directConceptList.takeFirst(); |
| 2791 |
// currentConceptList.append(concept); |
| 2792 |
// } |
| 2793 |
// if (currentConceptList.isEmpty() && !dependedConceptSet.isEmpty()) { |
| 2794 |
// CBUILDSET<CConcept*>::iterator firstDepConIt = dependedConceptSet.begin(); |
| 2795 |
// concept = *firstDepConIt; |
| 2796 |
// currentConceptList.append(concept); |
| 2797 |
// dependedConceptSet.erase(firstDepConIt); |
| 2798 |
// } |
| 2799 |
// CBUILDLIST<CConcept*> nextTaggingConceptList; |
| 2800 |
// while (!currentConceptList.isEmpty()) { |
| 2801 |
// concept = currentConceptList.takeFirst(); |
| 2802 |
// nextTaggingConceptList.prepend(concept); |
| 2803 |
|
| 2804 |
// CSortedNegLinker<CConcept*>* opConLinker = concept->getOperandList(); |
| 2805 |
// while (opConLinker) { |
| 2806 |
// CConcept* opConcept = opConLinker->getData(); |
| 2807 |
// if (opConcept && dependedConceptSet.contains(opConcept)) { |
| 2808 |
// dependedConceptSet.remove(opConcept); |
| 2809 |
// currentConceptList.prepend(opConcept); |
| 2810 |
// } |
| 2811 |
// opConLinker = opConLinker->getNext(); |
| 2812 |
// } |
| 2813 |
// } |
| 2814 |
// for (CBUILDLIST<CConcept*>::const_iterator it1 = nextTaggingConceptList.constBegin(), it1End = nextTaggingConceptList.constEnd(); it1 != it1End; ++it1) { |
| 2815 |
// taggingConceptList.append(*it1); |
| 2816 |
// } |
| 2817 |
|
| 2818 |
//} |
| 2819 |
//for (CBUILDLIST<CConcept*>::const_iterator it1 = taggingConceptList.constBegin(), it1End = taggingConceptList.constEnd(); it1 != it1End; ++it1) { |
| 2820 |
// CConcept* taggingConcept = *it1; |
| 2821 |
// taggingConcept->setConceptTag(lastFreeConceptTag++); |
| 2822 |
// mInstallConceptList.append(taggingConcept); |
| 2823 |
//} |
| 2824 |
|
| 2825 |
|
| 2826 |
|
| 2827 |
//cint64 nextUsedConceptTag = lastFreeConceptTag+mTaggingConceptSet.count()-1; |
| 2828 |
//CBUILDSET<CConcept*> directConceptSet; |
| 2829 |
//CBUILDHASH<CConcept*,CConcept*> succConceptHash; |
| 2830 |
//CBUILDHASH<CConcept*,cint64> prevConceptCountHash; |
| 2831 |
|
| 2832 |
//FOREACHIT (CConcept* concept, mTaggingConceptSet) { |
| 2833 |
// if (prevConceptCountHash.value(concept,0) <= 0) { |
| 2834 |
// directConceptSet.insert(concept); |
| 2835 |
// } |
| 2836 |
// CSortedNegLinker<CConcept*>* opConLinker = concept->getOperandList(); |
| 2837 |
// while (opConLinker) { |
| 2838 |
// CConcept* opConcept = opConLinker->getData(); |
| 2839 |
// if (opConcept && mTaggingConceptSet.contains(opConcept)) { |
| 2840 |
// succConceptHash.insertMulti(concept,opConcept); |
| 2841 |
// cint64 prevCount = prevConceptCountHash.value(opConcept,0); |
| 2842 |
// if (prevCount <= 0) { |
| 2843 |
// directConceptSet.remove(opConcept); |
| 2844 |
// } |
| 2845 |
// ++prevCount; |
| 2846 |
// prevConceptCountHash.insert(opConcept,prevCount); |
| 2847 |
// } |
| 2848 |
// opConLinker = opConLinker->getNext(); |
| 2849 |
// } |
| 2850 |
//} |
| 2851 |
//CBUILDLIST<CConcept*> nextConceptTaggingList; |
| 2852 |
//FOREACHIT (CConcept* concept, directConceptSet) { |
| 2853 |
// nextConceptTaggingList.append(concept); |
| 2854 |
//} |
| 2855 |
//if (nextConceptTaggingList.isEmpty() && nextUsedConceptTag >= lastFreeConceptTag) { |
| 2856 |
// // search next concept for tagging with minimal dependency |
| 2857 |
// cint64 minPrevCount = 0; |
| 2858 |
// CConcept* minPrevConcept = nullptr; |
| 2859 |
// FOREACHHASHIT (CConcept* concept, cint64 prevCount, prevConceptCountHash) { |
| 2860 |
// if (!minPrevConcept || prevCount < minPrevCount && prevCount > 0) { |
| 2861 |
// minPrevCount = prevCount; |
| 2862 |
// minPrevConcept = concept; |
| 2863 |
// } |
| 2864 |
// } |
| 2865 |
// nextConceptTaggingList.append(minPrevConcept); |
| 2866 |
//} |
| 2867 |
//while (!nextConceptTaggingList.isEmpty()) { |
| 2868 |
// CConcept* taggingConcept = nextConceptTaggingList.takeLast(); |
| 2869 |
// taggingConcept->setConceptTag(nextUsedConceptTag--); |
| 2870 |
// mInstallConceptList.append(taggingConcept); |
| 2871 |
// prevConceptCountHash.insert(taggingConcept,0); |
| 2872 |
|
| 2873 |
// FOREACHIT (CConcept* succConcept, succConceptHash.values(taggingConcept)) { |
| 2874 |
// cint64 prevCount = prevConceptCountHash.value(succConcept)-1; |
| 2875 |
// if (prevCount == 0) { |
| 2876 |
// nextConceptTaggingList.append(succConcept); |
| 2877 |
// } |
| 2878 |
// prevConceptCountHash.insert(succConcept,prevCount); |
| 2879 |
// } |
| 2880 |
|
| 2881 |
// if (nextConceptTaggingList.isEmpty() && nextUsedConceptTag >= lastFreeConceptTag) { |
| 2882 |
// // search next concept for tagging with minimal dependency |
| 2883 |
// cint64 minPrevCount = 0; |
| 2884 |
// CConcept* minPrevConcept = nullptr; |
| 2885 |
// FOREACHHASHIT (CConcept* concept, cint64 prevCount, prevConceptCountHash) { |
| 2886 |
// if ((!minPrevConcept || prevCount < minPrevCount) && prevCount > 0) { |
| 2887 |
// minPrevCount = prevCount; |
| 2888 |
// minPrevConcept = concept; |
| 2889 |
// } |
| 2890 |
// } |
| 2891 |
// nextConceptTaggingList.append(minPrevConcept); |
| 2892 |
// } |
| 2893 |
|
| 2894 |
//} |
| 2895 |
return true; |
| 2896 |
} |
| 2897 |
|
| 2898 |
|
| 2899 |
bool CConcreteOntologyUpdateBuilder::resortAndInstallConceptsAndRolesAndIndividuals() { |
| 2900 |
CConceptVector* conVec = tBox->getConceptVector(); |
| 2901 |
FOREACHIT (CConcept* concept, mInstallConceptList) { |
| 2902 |
CSortedNegLinker<CConcept*>* opConceptLinkerIt = concept->getOperandList(); |
| 2903 |
opConceptLinkerIt = resortConceptLinkersByTagging(opConceptLinkerIt,concept->getOperandCount()); |
| 2904 |
concept->setOperandList(opConceptLinkerIt); |
| 2905 |
conVec->setData(concept->getConceptTag(),concept); |
| 2906 |
} |
| 2907 |
CRoleVector* roleVec = rBox->getRoleVector(); |
| 2908 |
FOREACHIT (CRole* role, mInstallRoleList) { |
| 2909 |
CSortedNegLinker<CRole*>* roleLinkerIt = nullptr; |
| 2910 |
|
| 2911 |
roleLinkerIt = role->getSuperRoleList(); |
| 2912 |
roleLinkerIt = resortRoleLinkersByTagging(roleLinkerIt); |
| 2913 |
role->setSuperRoleList(roleLinkerIt); |
| 2914 |
|
| 2915 |
roleLinkerIt = role->getDisjointRoleList(); |
| 2916 |
roleLinkerIt = resortRoleLinkersByTagging(roleLinkerIt); |
| 2917 |
role->setDisjointRoleList(roleLinkerIt); |
| 2918 |
|
| 2919 |
roleLinkerIt = role->getInverseEquivalentRoleList(); |
| 2920 |
roleLinkerIt = resortRoleLinkersByTagging(roleLinkerIt); |
| 2921 |
role->setInverseEquivalentRoleList(roleLinkerIt); |
| 2922 |
|
| 2923 |
CSortedNegLinker<CConcept*>* conceptLinkerIt = nullptr; |
| 2924 |
|
| 2925 |
conceptLinkerIt = role->getDomainConceptList(); |
| 2926 |
conceptLinkerIt = resortConceptLinkersByTagging(conceptLinkerIt); |
| 2927 |
role->setDomainConceptList(conceptLinkerIt); |
| 2928 |
|
| 2929 |
conceptLinkerIt = role->getRangeConceptList(); |
| 2930 |
conceptLinkerIt = resortConceptLinkersByTagging(conceptLinkerIt); |
| 2931 |
role->setRangeConceptList(conceptLinkerIt); |
| 2932 |
|
| 2933 |
roleVec->setData(role->getRoleTag(),role); |
| 2934 |
} |
| 2935 |
|
| 2936 |
CRoleChainVector* roleChainVec = rBox->getRoleChainVector(); |
| 2937 |
FOREACHIT (CRoleChain* roleChain, mInstallRoleChainList) { |
| 2938 |
roleChainVec->setData(roleChain->getRoleChainTag(),roleChain); |
| 2939 |
} |
| 2940 |
|
| 2941 |
CIndividualVector* indiVec = aBox->getIndividualVector(); |
| 2942 |
FOREACHIT (CIndividual* indi, mInstallIndividualList) { |
| 2943 |
indiVec->setData(indi->getIndividualID(),indi); |
| 2944 |
} |
| 2945 |
return false; |
| 2946 |
} |
| 2947 |
|
| 2948 |
|
| 2949 |
CSortedNegLinker<CConcept*>* CConcreteOntologyUpdateBuilder::resortConceptLinkersByTagging(CSortedNegLinker<CConcept*>* conceptLinkers, cint64 linkerCount) { |
| 2950 |
if (linkerCount > 100) { |
| 2951 |
QMap<cint64,CSortedNegLinker<CConcept*>*> linkerSortMap; |
| 2952 |
CSortedNegLinker<CConcept*>* conceptLinkerIt = conceptLinkers; |
| 2953 |
while (conceptLinkerIt) { |
| 2954 |
CSortedNegLinker<CConcept*>* tmpConceptLinker = conceptLinkerIt; |
| 2955 |
conceptLinkerIt = conceptLinkerIt->getNext(); |
| 2956 |
tmpConceptLinker->setNext(nullptr); |
| 2957 |
linkerSortMap.insertMulti(tmpConceptLinker->getData()->getConceptTag(),tmpConceptLinker); |
| 2958 |
} |
| 2959 |
CSortedNegLinker<CConcept*>* newConceptLinkers = nullptr; |
| 2960 |
CSortedNegLinker<CConcept*>* lastNewConceptLinkers = nullptr; |
| 2961 |
for (QMap<cint64,CSortedNegLinker<CConcept*>*>::const_iterator it = linkerSortMap.constBegin(), itEnd = linkerSortMap.constEnd(); it != itEnd; ++it) { |
| 2962 |
CSortedNegLinker<CConcept*>* tmpConceptLinker = *it; |
| 2963 |
if (!newConceptLinkers) { |
| 2964 |
lastNewConceptLinkers = newConceptLinkers = tmpConceptLinker; |
| 2965 |
} else { |
| 2966 |
lastNewConceptLinkers->setNext(tmpConceptLinker); |
| 2967 |
lastNewConceptLinkers = tmpConceptLinker; |
| 2968 |
} |
| 2969 |
} |
| 2970 |
return newConceptLinkers; |
| 2971 |
} else { |
| 2972 |
CSortedNegLinker<CConcept*>* newConceptLinkers = nullptr; |
| 2973 |
while (conceptLinkers) { |
| 2974 |
CSortedNegLinker<CConcept*>* tmpConceptLinker = conceptLinkers; |
| 2975 |
conceptLinkers = conceptLinkers->getNext(); |
| 2976 |
tmpConceptLinker->setNext(nullptr); |
| 2977 |
if (!newConceptLinkers) { |
| 2978 |
newConceptLinkers = tmpConceptLinker; |
| 2979 |
} else { |
| 2980 |
newConceptLinkers = newConceptLinkers->insertSortedNextSorted(tmpConceptLinker); |
| 2981 |
} |
| 2982 |
} |
| 2983 |
return newConceptLinkers; |
| 2984 |
} |
| 2985 |
} |
| 2986 |
|
| 2987 |
|
| 2988 |
CSortedNegLinker<CRole*>* CConcreteOntologyUpdateBuilder::resortRoleLinkersByTagging(CSortedNegLinker<CRole*>* roleLinkers) { |
| 2989 |
CSortedNegLinker<CRole*>* newRoleLinkers = nullptr; |
| 2990 |
while (roleLinkers) { |
| 2991 |
CSortedNegLinker<CRole*>* tmpRoleLinker = roleLinkers; |
| 2992 |
roleLinkers = roleLinkers->getNext(); |
| 2993 |
tmpRoleLinker->setNext(nullptr); |
| 2994 |
if (!newRoleLinkers) { |
| 2995 |
newRoleLinkers = tmpRoleLinker; |
| 2996 |
} else { |
| 2997 |
newRoleLinkers = newRoleLinkers->insertSortedNextSorted(tmpRoleLinker); |
| 2998 |
} |
| 2999 |
} |
| 3000 |
return newRoleLinkers; |
| 3001 |
} |
| 3002 |
|
| 3003 |
|
| 3004 |
|
| 3005 |
}; // end namespace Generator |
| 3006 |
|
| 3007 |
}; // end namespace Reasoner |
| 3008 |
|
| 3009 |
}; // end namespace Konclude |