| 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 "CRoleChainAutomataTransformationPreProcess.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Preprocess { |
| 29 |
|
| 30 |
|
| 31 |
CRoleChainAutomataTransformationPreProcess::CRoleChainAutomataTransformationPreProcess() { |
| 32 |
mConfSaveTransitiveTransitions = true; |
| 33 |
mOntology = nullptr; |
| 34 |
mLastConceptForallId = 0; |
| 35 |
mLastConceptValueId = 0; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
CRoleChainAutomataTransformationPreProcess::~CRoleChainAutomataTransformationPreProcess() { |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
CConcreteOntology *CRoleChainAutomataTransformationPreProcess::preprocess(CConcreteOntology *ontology, CPreProcessContext* context) { |
| 44 |
mOntology = nullptr; |
| 45 |
mLastConceptForallId = 0; |
| 46 |
mLastConceptValueId = 0; |
| 47 |
bool complexRoleConstructsUsed = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getBuildConstructFlags()->isComplexRoleUsed(); |
| 48 |
if (complexRoleConstructsUsed) { |
| 49 |
mOntology = ontology; |
| 50 |
CTBox* tbox = ontology->getDataBoxes()->getTBox(); |
| 51 |
CABox *abox = ontology->getDataBoxes()->getABox(); |
| 52 |
CRBox *rbox = ontology->getDataBoxes()->getRBox(); |
| 53 |
CMBox* mBox = ontology->getDataBoxes()->getMBox(); |
| 54 |
|
| 55 |
mStatAutomateTransitionConceptCount = 0; |
| 56 |
mStatAutomateStateConceptCount = 0; |
| 57 |
mStatAutomateTransformedConceptCount = 0; |
| 58 |
mStatAutomateTransitiveSavedCount = 0; |
| 59 |
mStatCreatedDomainPropagationCount = 0; |
| 60 |
mStatCreatedRangePropagationCount = 0; |
| 61 |
mStatPropagatedAlreadyInDomainRangeCount = 0; |
| 62 |
mStatPropagationAlreadyInDomainRangeCount = 0; |
| 63 |
mStatDomainPropagationCount = 0; |
| 64 |
mStatRangePropagationCount = 0; |
| 65 |
|
| 66 |
|
| 67 |
mRoleVec = rbox->getRoleVector(); |
| 68 |
mConVec = tbox->getConceptVector(); |
| 69 |
mNextConceptTag = tbox->getNextConceptID(); |
| 70 |
|
| 71 |
mMemMan = ontology->getDataBoxes()->getBoxContext()->getMemoryAllocationManager(); |
| 72 |
|
| 73 |
mRoleObjPropTermHash = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getRoleObjectPropertyTermMappingHash(); |
| 74 |
mObjPropTermRoleHash = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getObjectPropertyTermRoleMappingHash(); |
| 75 |
mExpressionBuildContainerList = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getExpressionBuildListContainer(); |
| 76 |
mInverseObjectPropertyHash = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getInverseObjectPropertyHash(); |
| 77 |
mExpressionBuildHash = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getStructuralExpressionBuildHash(); |
| 78 |
|
| 79 |
|
| 80 |
collectSubRoleChains(); |
| 81 |
|
| 82 |
createMissingInverseChainedRoles(); |
| 83 |
|
| 84 |
createInverseRoleChainLinkers(); |
| 85 |
|
| 86 |
transformVALUERestrictions(); |
| 87 |
|
| 88 |
createDomainRangePropagations(); |
| 89 |
|
| 90 |
createRecursiveTraversalData(); |
| 91 |
|
| 92 |
transformFORALLPropagations(); |
| 93 |
|
| 94 |
|
| 95 |
if (mStatAutomateTransformedConceptCount > 0) { |
| 96 |
LOG(INFO,"::Konclude::Reasoner::Preprocess::RoleChainAutomataTransformation",logTr("Transformed %1 concepts to automate.").arg(mStatAutomateTransformedConceptCount),this); |
| 97 |
LOG(INFO,"::Konclude::Reasoner::Preprocess::RoleChainAutomataTransformation",logTr("Generated %1 automate state and %2 automate transaction concepts.").arg(mStatAutomateStateConceptCount).arg(mStatAutomateTransitionConceptCount),this); |
| 98 |
} |
| 99 |
|
| 100 |
} |
| 101 |
|
| 102 |
return ontology; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
CConcreteOntology* CRoleChainAutomataTransformationPreProcess::continuePreprocessing() { |
| 108 |
if (mOntology) { |
| 109 |
mNextConceptTag = mOntology->getTBox()->getNextConceptID(); |
| 110 |
transformVALUERestrictions(); |
| 111 |
transformFORALLPropagations(); |
| 112 |
} |
| 113 |
return mOntology; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
CRoleChainAutomataTransformationPreProcess* CRoleChainAutomataTransformationPreProcess::transformFORALLPropagations() { |
| 118 |
cint64 conCount = mConVec->getItemCount(); |
| 119 |
for (qint64 i = mLastConceptForallId; i < conCount; ++i) { |
| 120 |
CConcept *concept = mConVec->getLocalData(i); |
| 121 |
if (concept) { |
| 122 |
cint64 opCode = concept->getOperatorCode(); |
| 123 |
if (opCode == CCALL || opCode == CCSOME || opCode == CCIMPLALL || opCode == CCBRANCHALL || opCode == CCVARBINDALL || opCode == CCPBINDALL || opCode == CCVARPBACKALL) { |
| 124 |
CRole* role = concept->getRole(); |
| 125 |
role = mRoleVec->getData(role->getRoleTag()); |
| 126 |
if (role->isComplexRole()) { |
| 127 |
concept = CConceptRoleIndividualLocator::getLocatedConcept(concept, mOntology); |
| 128 |
// translate into concept role automate |
| 129 |
++mStatAutomateTransformedConceptCount; |
| 130 |
convertAutomatConcept(concept); |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
mLastConceptForallId = conCount; |
| 136 |
return this; |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
CConcreteOntology* CRoleChainAutomataTransformationPreProcess::preprocess(CConcreteOntology *ontology, QSet<CConcept*>* transformConceptSet, CPreProcessContext* context) { |
| 141 |
mOntology = ontology; |
| 142 |
CTBox* tbox = ontology->getDataBoxes()->getTBox(); |
| 143 |
CABox *abox = ontology->getDataBoxes()->getABox(); |
| 144 |
CRBox *rbox = ontology->getDataBoxes()->getRBox(); |
| 145 |
CMBox* mBox = ontology->getDataBoxes()->getMBox(); |
| 146 |
|
| 147 |
mStatAutomateTransitionConceptCount = 0; |
| 148 |
mStatAutomateStateConceptCount = 0; |
| 149 |
mStatAutomateTransformedConceptCount = 0; |
| 150 |
mStatAutomateTransitiveSavedCount = 0; |
| 151 |
mStatCreatedDomainPropagationCount = 0; |
| 152 |
mStatCreatedRangePropagationCount = 0; |
| 153 |
mStatPropagatedAlreadyInDomainRangeCount = 0; |
| 154 |
mStatPropagationAlreadyInDomainRangeCount = 0; |
| 155 |
mStatDomainPropagationCount = 0; |
| 156 |
mStatRangePropagationCount = 0; |
| 157 |
|
| 158 |
|
| 159 |
mRoleVec = rbox->getRoleVector(); |
| 160 |
mConVec = tbox->getConceptVector(); |
| 161 |
mNextConceptTag = tbox->getNextConceptID(); |
| 162 |
|
| 163 |
mMemMan = ontology->getDataBoxes()->getBoxContext()->getMemoryAllocationManager(); |
| 164 |
|
| 165 |
mRoleObjPropTermHash = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getRoleObjectPropertyTermMappingHash(); |
| 166 |
mObjPropTermRoleHash = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getObjectPropertyTermRoleMappingHash(); |
| 167 |
mExpressionBuildContainerList = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getExpressionBuildListContainer(); |
| 168 |
mInverseObjectPropertyHash = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getInverseObjectPropertyHash(); |
| 169 |
mExpressionBuildHash = ontology->getDataBoxes()->getExpressionDataBoxMapping()->getStructuralExpressionBuildHash(); |
| 170 |
|
| 171 |
|
| 172 |
collectSubRoleChains(); |
| 173 |
|
| 174 |
createRecursiveTraversalData(); |
| 175 |
|
| 176 |
|
| 177 |
for (QSet<CConcept*>::const_iterator conIt = transformConceptSet->constBegin(), conItEnd = transformConceptSet->constEnd(); conIt != conItEnd; ++conIt) { |
| 178 |
CConcept *concept(*conIt); |
| 179 |
if (concept) { |
| 180 |
cint64 opCode = concept->getOperatorCode(); |
| 181 |
if (opCode == CCALL || opCode == CCSOME || opCode == CCIMPLALL || opCode == CCBRANCHALL || opCode == CCVARBINDALL || opCode == CCPBINDALL || opCode == CCVARPBACKALL) { |
| 182 |
CRole* role = concept->getRole(); |
| 183 |
role = mRoleVec->getData(role->getRoleTag()); |
| 184 |
if (role->isComplexRole()) { |
| 185 |
concept = CConceptRoleIndividualLocator::getLocatedConcept(concept,ontology); |
| 186 |
// translate into concept role automate |
| 187 |
++mStatAutomateTransformedConceptCount; |
| 188 |
convertAutomatConcept(concept); |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
} |
| 193 |
return mOntology; |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
CRoleChainAutomataTransformationPreProcess* CRoleChainAutomataTransformationPreProcess::transformVALUERestrictions() { |
| 199 |
cint64 conCount = mConVec->getItemCount(); |
| 200 |
for (qint64 i = mLastConceptValueId; i < conCount; ++i) { |
| 201 |
bool localFlag = false; |
| 202 |
//CConcept *concept = mConVec->getData(i, &localFlag); |
| 203 |
CConcept *concept = mConVec->getLocalData(i); |
| 204 |
if (concept) { |
| 205 |
bool transformToExistentialNominal = false; |
| 206 |
cint64 opCode = concept->getOperatorCode(); |
| 207 |
if (opCode == CCVALUE) { |
| 208 |
CRole* role = concept->getRole(); |
| 209 |
role = mRoleVec->getData(role->getRoleTag()); |
| 210 |
if (role->isComplexRole()) { |
| 211 |
transformToExistentialNominal = true; |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
if (transformToExistentialNominal) { |
| 216 |
//if (!localFlag) { |
| 217 |
// concept = CConceptRoleIndividualLocator::getLocatedConcept(concept,mOntology); |
| 218 |
//} |
| 219 |
CIndividual* nomIndividual = concept->getNominalIndividual(); |
| 220 |
concept->setOperatorCode(CCSOME); |
| 221 |
concept->setNominalIndividual(nullptr); |
| 222 |
CConcept* nomIndividualConcept = nomIndividual->getIndividualNominalConcept(); |
| 223 |
if (!nomIndividualConcept) { |
| 224 |
nomIndividualConcept = createNominalConcept(nomIndividual); |
| 225 |
} |
| 226 |
CSortedNegLinker<CConcept*>* opLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemMan); |
| 227 |
opLinker->init(nomIndividualConcept,false); |
| 228 |
concept->setOperandList(opLinker); |
| 229 |
} |
| 230 |
} |
| 231 |
} |
| 232 |
mLastConceptValueId = conCount; |
| 233 |
return this; |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
CRoleChainAutomataTransformationPreProcess* CRoleChainAutomataTransformationPreProcess::createDomainRangePropagations() { |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
QSet<CConcept*> domRangePropCocneptSet; |
| 243 |
qint64 itemCounts = mRoleVec->getItemCount(); |
| 244 |
for (qint64 i = 0; i < itemCounts; ++i) { |
| 245 |
CRole *role = mRoleVec->getLocalData(i); |
| 246 |
if (role && role->isComplexRole()) { |
| 247 |
|
| 248 |
CRole* inverseRole = nullptr; |
| 249 |
|
| 250 |
for (CSortedNegLinker<CConcept*>* domainConLinker = role->getDomainConceptList(); domainConLinker; domainConLinker = domainConLinker->getNext()) { |
| 251 |
CConcept* domCon = domainConLinker->getData(); |
| 252 |
bool domConNeg = domainConLinker->isNegated(); |
| 253 |
|
| 254 |
if (domConNeg || !domRangePropCocneptSet.contains(domCon)) { |
| 255 |
|
| 256 |
++mStatRangePropagationCount; |
| 257 |
if (!inverseRole) { |
| 258 |
inverseRole = getInverseRole(role); |
| 259 |
} |
| 260 |
|
| 261 |
QList<CRoleSubRoleChainDataItem> subRoleItemList; |
| 262 |
foreach (CRoleSubRoleChainData data, mRoleSubRoleChainDataHash.values(role)) { |
| 263 |
subRoleItemList.append(CRoleSubRoleChainDataItem(data)); |
| 264 |
} |
| 265 |
CConcept* propConcept = nullptr; |
| 266 |
|
| 267 |
while (!subRoleItemList.isEmpty()) { |
| 268 |
CRoleSubRoleChainData subRoleData = nullptr; |
| 269 |
bool allowPropagatedConcept = true; |
| 270 |
bool inversedToOrginal = false; |
| 271 |
CRoleSubRoleChainDataItem dataItem(subRoleItemList.takeFirst()); |
| 272 |
subRoleData = dataItem.mChainData; |
| 273 |
allowPropagatedConcept = dataItem.mAllowPropagated; |
| 274 |
inversedToOrginal = dataItem.mNegated ^ subRoleData.mInverse; |
| 275 |
CRoleChain* roleChain = subRoleData.mRoleChain; |
| 276 |
|
| 277 |
CRole* firstSubRole = nullptr; |
| 278 |
CRole* lastSubRole = nullptr; |
| 279 |
|
| 280 |
if (inversedToOrginal) { |
| 281 |
firstSubRole = getInverseRole(roleChain->getInverseRoleChainLinker()->getData()); |
| 282 |
lastSubRole = getInverseRole(roleChain->getInverseRoleChainLinker()->getLastListLink()->getData()); |
| 283 |
} else { |
| 284 |
firstSubRole = roleChain->getRoleChainLinker()->getData(); |
| 285 |
lastSubRole = roleChain->getRoleChainLinker()->getLastListLink()->getData(); |
| 286 |
} |
| 287 |
|
| 288 |
|
| 289 |
if (!hasPropagationConcept(domConNeg,domCon,inverseRole,lastSubRole->getIndirectSuperRoleList(),true) && (!allowPropagatedConcept || !hasPropagatedConcept(domConNeg,domCon,firstSubRole->getIndirectSuperRoleList(),true))) { |
| 290 |
if (!propConcept) { |
| 291 |
propConcept = createTransitionConcept(inverseRole,TTNORMAL); |
| 292 |
propConcept->setOperatorCode(CCALL); |
| 293 |
appendTransitionOperandConceptLinker(propConcept,createTransitionOperandConceptLinker(domCon,domConNeg)); |
| 294 |
} |
| 295 |
domRangePropCocneptSet.insert(propConcept); |
| 296 |
CSortedNegLinker<CConcept*>* newConLinker = createTransitionOperandConceptLinker(propConcept,false); |
| 297 |
|
| 298 |
lastSubRole->addRangeConceptLinker(newConLinker); |
| 299 |
++mStatCreatedDomainPropagationCount; |
| 300 |
|
| 301 |
foreach (CRoleSubRoleChainData data, mRoleSubRoleChainDataHash.values(lastSubRole)) { |
| 302 |
subRoleItemList.append(CRoleSubRoleChainDataItem(data,false)); |
| 303 |
} |
| 304 |
} |
| 305 |
} |
| 306 |
} |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
for (CSortedNegLinker<CConcept*>* rangeConLinker = role->getRangeConceptList(); rangeConLinker; rangeConLinker = rangeConLinker->getNext()) { |
| 311 |
CConcept* rangeCon = rangeConLinker->getData(); |
| 312 |
bool rangeConNeg = rangeConLinker->isNegated(); |
| 313 |
|
| 314 |
if (rangeConNeg || !domRangePropCocneptSet.contains(rangeCon)) { |
| 315 |
|
| 316 |
++mStatDomainPropagationCount; |
| 317 |
QList<CRoleSubRoleChainDataItem> subRoleItemList; |
| 318 |
foreach (CRoleSubRoleChainData data, mRoleSubRoleChainDataHash.values(role)) { |
| 319 |
subRoleItemList.append(CRoleSubRoleChainDataItem(data)); |
| 320 |
} |
| 321 |
CConcept* propConcept = nullptr; |
| 322 |
|
| 323 |
while (!subRoleItemList.isEmpty()) { |
| 324 |
CRoleSubRoleChainData subRoleData = nullptr; |
| 325 |
bool allowPropagatedConcept = true; |
| 326 |
bool inversedToOrginal = false; |
| 327 |
CRoleSubRoleChainDataItem dataItem(subRoleItemList.takeFirst()); |
| 328 |
subRoleData = dataItem.mChainData; |
| 329 |
allowPropagatedConcept = dataItem.mAllowPropagated; |
| 330 |
inversedToOrginal = dataItem.mNegated ^ subRoleData.mInverse; |
| 331 |
CRoleChain* roleChain = subRoleData.mRoleChain; |
| 332 |
|
| 333 |
CRole* firstSubRole = nullptr; |
| 334 |
CRole* lastSubRole = nullptr; |
| 335 |
|
| 336 |
if (inversedToOrginal) { |
| 337 |
firstSubRole = getInverseRole(roleChain->getInverseRoleChainLinker()->getData()); |
| 338 |
lastSubRole = getInverseRole(roleChain->getInverseRoleChainLinker()->getLastListLink()->getData()); |
| 339 |
} else { |
| 340 |
firstSubRole = roleChain->getRoleChainLinker()->getData(); |
| 341 |
lastSubRole = roleChain->getRoleChainLinker()->getLastListLink()->getData(); |
| 342 |
} |
| 343 |
|
| 344 |
if (!hasPropagationConcept(rangeConNeg,rangeCon,role,firstSubRole->getIndirectSuperRoleList(),false) && (!allowPropagatedConcept || !hasPropagatedConcept(rangeConNeg,rangeCon,lastSubRole->getIndirectSuperRoleList(),false))) { |
| 345 |
if (!propConcept) { |
| 346 |
propConcept = createTransitionConcept(role,TTNORMAL); |
| 347 |
propConcept->setOperatorCode(CCALL); |
| 348 |
appendTransitionOperandConceptLinker(propConcept,createTransitionOperandConceptLinker(rangeCon,rangeConNeg)); |
| 349 |
} |
| 350 |
domRangePropCocneptSet.insert(propConcept); |
| 351 |
CSortedNegLinker<CConcept*>* newConLinker = createTransitionOperandConceptLinker(propConcept,false); |
| 352 |
|
| 353 |
firstSubRole->addDomainConceptLinker(newConLinker); |
| 354 |
++mStatCreatedRangePropagationCount; |
| 355 |
|
| 356 |
foreach (CRoleSubRoleChainData data, mRoleSubRoleChainDataHash.values(firstSubRole)) { |
| 357 |
subRoleItemList.append(CRoleSubRoleChainDataItem(data,false)); |
| 358 |
} |
| 359 |
} |
| 360 |
} |
| 361 |
} |
| 362 |
} |
| 363 |
|
| 364 |
} |
| 365 |
} |
| 366 |
return this; |
| 367 |
} |
| 368 |
|
| 369 |
bool CRoleChainAutomataTransformationPreProcess::hasPropagatedConcept(bool negated, CConcept* concept, CSortedNegLinker<CRole*>* roleList, bool inverseDomRange) { |
| 370 |
for (CSortedNegLinker<CRole*>* roleListLinker = roleList; roleListLinker; roleListLinker = roleListLinker->getNext()) { |
| 371 |
CRole* superRole = roleListLinker->getData(); |
| 372 |
bool superRoleNeg = roleListLinker->isNegated(); |
| 373 |
bool switchDomainRange = inverseDomRange ^ superRoleNeg; |
| 374 |
|
| 375 |
CSortedNegLinker<CConcept*>* conList = superRole->getDomainRangeConceptList(!switchDomainRange); |
| 376 |
for (CSortedNegLinker<CConcept*>* conListLinker = conList; conListLinker; conListLinker = conListLinker->getNext()) { |
| 377 |
CConcept* con = conListLinker->getData(); |
| 378 |
bool conNeg = conListLinker->isNegated(); |
| 379 |
cint64 conCode = con->getOperatorCode(); |
| 380 |
if (con == concept && conNeg == negated) { |
| 381 |
++mStatPropagatedAlreadyInDomainRangeCount; |
| 382 |
return true; |
| 383 |
} |
| 384 |
} |
| 385 |
} |
| 386 |
return false; |
| 387 |
} |
| 388 |
|
| 389 |
bool CRoleChainAutomataTransformationPreProcess::hasPropagationConcept(bool negated, CConcept* concept, CRole* role, CSortedNegLinker<CRole*>* roleList, bool inverseDomRange) { |
| 390 |
for (CSortedNegLinker<CRole*>* roleListLinker = roleList; roleListLinker; roleListLinker = roleListLinker->getNext()) { |
| 391 |
CRole* superRole = roleListLinker->getData(); |
| 392 |
bool superRoleNeg = roleListLinker->isNegated(); |
| 393 |
bool switchDomainRange = inverseDomRange ^ superRoleNeg; |
| 394 |
|
| 395 |
CSortedNegLinker<CConcept*>* conList = superRole->getDomainRangeConceptList(switchDomainRange); |
| 396 |
for (CSortedNegLinker<CConcept*>* conListLinker = conList; conListLinker; conListLinker = conListLinker->getNext()) { |
| 397 |
CConcept* con = conListLinker->getData(); |
| 398 |
bool conNeg = conListLinker->isNegated(); |
| 399 |
if (con->getRole() == role) { |
| 400 |
cint64 conCode = con->getOperatorCode(); |
| 401 |
if ((conCode == CCALL || conCode == CCAQALL || conCode == CCIMPLALL) && !conNeg || conNeg && (conCode == CCSOME)) { |
| 402 |
for (CSortedNegLinker<CConcept*>* opListLinker = con->getOperandList(); opListLinker; opListLinker = opListLinker->getNext()) { |
| 403 |
if (opListLinker->getData() == concept && opListLinker->isNegated()^conNeg == negated) { |
| 404 |
++mStatPropagationAlreadyInDomainRangeCount; |
| 405 |
return true; |
| 406 |
} |
| 407 |
} |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
} |
| 412 |
return false; |
| 413 |
} |
| 414 |
|
| 415 |
|
| 416 |
CRoleChainAutomataTransformationPreProcess* CRoleChainAutomataTransformationPreProcess::convertAutomatConcept(CConcept* concept) { |
| 417 |
CSortedNegLinker<CConcept*>* opConLinker = concept->getOperandList(); |
| 418 |
cint64 opCount = concept->getOperandCount(); |
| 419 |
CRole* role = concept->getRole(); |
| 420 |
role = mRoleVec->getData(role->getRoleTag()); |
| 421 |
bool existNegation = false; |
| 422 |
if (concept->getOperatorCode() == CCSOME) { |
| 423 |
existNegation = true; |
| 424 |
} |
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
//if (CIRIName::getRecentIRIName(role->getPropertyNameLinker()) == "#LocativeAttribute") { |
| 429 |
// if (CIRIName::getRecentIRIName(concept->getOperandList()->getData()->getClassNameLinker()) == "#Heart") { |
| 430 |
// bool bug = true; |
| 431 |
// } |
| 432 |
//} |
| 433 |
|
| 434 |
// transformation into automat concept |
| 435 |
|
| 436 |
bool implTransisition = false; |
| 437 |
TRANSLATIONTYPE transType = TTNORMAL; |
| 438 |
cint64 opCode = concept->getOperatorCode(); |
| 439 |
if (opCode == CCIMPLALL) { |
| 440 |
// implication transition is never negated |
| 441 |
transType = TTIMPL; |
| 442 |
} else if (opCode == CCBRANCHALL) { |
| 443 |
transType = TTBRANCH; |
| 444 |
} else if (opCode == CCPBINDALL) { |
| 445 |
transType = TTPROPBIND; |
| 446 |
} else if (opCode == CCVARPBACKALL) { |
| 447 |
transType = TTBACKPROP; |
| 448 |
} else if (opCode == CCVARBINDALL) { |
| 449 |
transType = TTVARBIND; |
| 450 |
} |
| 451 |
|
| 452 |
CConcept* generatingConcept = nullptr; |
| 453 |
CConcept* beginState = nullptr; |
| 454 |
CConcept* propCon = nullptr; |
| 455 |
CConcept* endState = nullptr; |
| 456 |
|
| 457 |
if (transType == TTNORMAL) { |
| 458 |
concept->setOperatorCode(CCAQCHOOCE); |
| 459 |
generatingConcept = createAutomatGeneratingConcept(opConLinker,!existNegation,role); |
| 460 |
beginState = createStateConcept(transType); |
| 461 |
} else { |
| 462 |
beginState = concept; |
| 463 |
cint64 opCode = CCAQAND; |
| 464 |
if (transType == TTIMPL) { |
| 465 |
opCode = CCIMPLAQAND; |
| 466 |
} else if (transType == TTBRANCH) { |
| 467 |
opCode = CCBRANCHAQAND; |
| 468 |
} else if (transType == TTPROPBIND) { |
| 469 |
opCode = CCPBINDAQAND; |
| 470 |
} else if (transType == TTBACKPROP) { |
| 471 |
opCode = CCVARPBACKAQAND; |
| 472 |
} else if (transType == TTVARBIND) { |
| 473 |
opCode = CCVARBINDAQAND; |
| 474 |
} |
| 475 |
beginState->setOperatorCode(opCode); |
| 476 |
beginState->setRole(nullptr); |
| 477 |
} |
| 478 |
concept->setOperandList(nullptr); |
| 479 |
concept->setOperandCount(0); |
| 480 |
|
| 481 |
propCon = createTransitionConcept(role,transType); |
| 482 |
endState = createStateConcept(transType); |
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
CSortedNegLinker<CConcept*>* opLinkerIt = opConLinker; |
| 487 |
while (opLinkerIt) { |
| 488 |
CConcept* opConcept = opLinkerIt->getData(); |
| 489 |
bool opNegation = opLinkerIt->isNegated() ^ existNegation; |
| 490 |
appendTransitionOperandConceptLinker(endState,createTransitionOperandConceptLinker(opConcept,opNegation)); |
| 491 |
opLinkerIt = opLinkerIt->getNext(); |
| 492 |
} |
| 493 |
|
| 494 |
if (transType == TTNORMAL) { |
| 495 |
appendTransitionOperandConceptLinker(concept,createTransitionOperandConceptLinker(generatingConcept,!existNegation)); |
| 496 |
appendTransitionOperandConceptLinker(concept,createTransitionOperandConceptLinker(beginState,existNegation)); |
| 497 |
} |
| 498 |
|
| 499 |
|
| 500 |
appendTransitionOperandConceptLinker(beginState,createTransitionOperandConceptLinker(propCon,false)); |
| 501 |
appendTransitionOperandConceptLinker(propCon,createTransitionOperandConceptLinker(endState,false)); |
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
//const QList<CRoleSubRoleChainData> subRoleChainDataList(mRoleSubRoleChainDataHash.values(role)); |
| 507 |
if (role->getRoleTag() == 1) { |
| 508 |
appendTransitionOperandConceptLinker(endState, createTransitionOperandConceptLinker(beginState, false)); |
| 509 |
|
| 510 |
} else { |
| 511 |
const CRecTravSubRoleChainDataItem& recTravSubRoleChainDataItem(mRoleRecTravSubRoleChainDataHash.value(role)); |
| 512 |
QSet<CRole*> locUnfoldRoleSet; |
| 513 |
generateRoleChainAutomatConcept(role, recTravSubRoleChainDataItem, locUnfoldRoleSet, beginState, endState, transType); |
| 514 |
} |
| 515 |
|
| 516 |
// search fitting sub role chains |
| 517 |
//bool hasFittingSubRole = false; |
| 518 |
//QList<CRoleSubRoleChainData> subRoleChainDataList(mRoleSubRoleChainDataHash.values(role)); |
| 519 |
//hasFittingSubRole = !subRoleChainDataList.isEmpty(); |
| 520 |
//if (hasFittingSubRole) { |
| 521 |
|
| 522 |
// bool transitiveRole = true; |
| 523 |
// for (QList<CRoleSubRoleChainData>::const_iterator it = subRoleChainDataList.constBegin(), itEnd = subRoleChainDataList.constEnd(); it != itEnd; ++it) { |
| 524 |
// CRoleSubRoleChainData subRoleChainData(*it); |
| 525 |
// CRoleChain* subRoleChain = subRoleChainData.mRoleChain; |
| 526 |
// bool subRoleNegation = subRoleChainData.mInverse; |
| 527 |
// CRole* superRole = subRoleChainData.mRole; |
| 528 |
|
| 529 |
// CXLinker<CRole*>* roleChainLinkerIt = subRoleChain->getRoleChainLinker(); |
| 530 |
// while (roleChainLinkerIt) { |
| 531 |
// CRole* chainRole = roleChainLinkerIt->getData(); |
| 532 |
// if (chainRole != superRole) { |
| 533 |
// transitiveRole = false; |
| 534 |
// break; |
| 535 |
// } |
| 536 |
// roleChainLinkerIt = roleChainLinkerIt->getNext(); |
| 537 |
// } |
| 538 |
// } |
| 539 |
|
| 540 |
|
| 541 |
// if (transitiveRole && subRoleChainDataList.count() > 1) { |
| 542 |
|
| 543 |
// QHash<CRole*,cint64> roleCountHash; |
| 544 |
// QHash<CRole*,CRoleSubRoleChainData> roleChainDataHash; |
| 545 |
// for (QList<CRoleSubRoleChainData>::const_iterator it = subRoleChainDataList.constBegin(), itEnd = subRoleChainDataList.constEnd(); it != itEnd; ++it) { |
| 546 |
// CRoleSubRoleChainData subRoleChainData(*it); |
| 547 |
// CRole* superRole = subRoleChainData.mRole; |
| 548 |
// roleCountHash.insert(superRole,0); |
| 549 |
// roleChainDataHash.insert(superRole,subRoleChainData); |
| 550 |
// } |
| 551 |
// for (QList<CRoleSubRoleChainData>::const_iterator it = subRoleChainDataList.constBegin(), itEnd = subRoleChainDataList.constEnd(); it != itEnd; ++it) { |
| 552 |
// CRoleSubRoleChainData subRoleChainData(*it); |
| 553 |
// CRole* superRole = subRoleChainData.mRole; |
| 554 |
// CSortedNegLinker<CRole*>* superSuperLinkerIt = superRole->getIndirectSuperRoleList(); |
| 555 |
// while (superSuperLinkerIt) { |
| 556 |
// CRole* superSuperRole = superSuperLinkerIt->getData(); |
| 557 |
// cint64 count = roleCountHash.value(superSuperRole,-1); |
| 558 |
// if (count >= 0) { |
| 559 |
// roleCountHash.insert(superSuperRole,count+1); |
| 560 |
// } |
| 561 |
// superSuperLinkerIt = superSuperLinkerIt->getNext(); |
| 562 |
// } |
| 563 |
// } |
| 564 |
// QMap<cint64,CRole*> countRoleMap; |
| 565 |
// for (QHash<CRole*,cint64>::const_iterator it = roleCountHash.constBegin(), itEnd = roleCountHash.constEnd(); it != itEnd; ++it) { |
| 566 |
// CRole* role = it.key(); |
| 567 |
// cint64 count = it.value(); |
| 568 |
// countRoleMap.insertMulti(-count,role); |
| 569 |
// } |
| 570 |
|
| 571 |
// QSet<CRole*> locUnfoldRoleSet; |
| 572 |
// for (QMap<cint64,CRole*>::const_iterator it = countRoleMap.constBegin(), itEnd = countRoleMap.constEnd(); it != itEnd; ++it) { |
| 573 |
// CRole* superRole = it.value(); |
| 574 |
// CRoleSubRoleChainData subRoleChainData(roleChainDataHash.value(superRole)); |
| 575 |
// CRoleChain* subRoleChain = subRoleChainData.mRoleChain; |
| 576 |
// bool subRoleNegation = subRoleChainData.mInverse; |
| 577 |
// bool requiresAutomatGeneration = true; |
| 578 |
|
| 579 |
// CSortedNegLinker<CRole*>* superSuperLinkerIt = superRole->getIndirectSuperRoleList(); |
| 580 |
// while (superSuperLinkerIt) { |
| 581 |
// CRole* superSuperRole = superSuperLinkerIt->getData(); |
| 582 |
// if (locUnfoldRoleSet.contains(superSuperRole)) { |
| 583 |
// requiresAutomatGeneration = false; |
| 584 |
// break; |
| 585 |
// } |
| 586 |
// superSuperLinkerIt = superSuperLinkerIt->getNext(); |
| 587 |
// } |
| 588 |
|
| 589 |
// if (requiresAutomatGeneration) { |
| 590 |
// locUnfoldRoleSet.insert(superRole); |
| 591 |
// generateRoleChainAutomatConcept(role,superRole,subRoleChain,subRoleNegation,locUnfoldRoleSet,beginState,endState,transType); |
| 592 |
// } else { |
| 593 |
// ++mStatAutomateTransitiveSavedCount; |
| 594 |
// } |
| 595 |
// } |
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
// } else { |
| 600 |
// for (QList<CRoleSubRoleChainData>::const_iterator it = subRoleChainDataList.constBegin(), itEnd = subRoleChainDataList.constEnd(); it != itEnd; ++it) { |
| 601 |
// CRoleSubRoleChainData subRoleChainData(*it); |
| 602 |
// CRoleChain* subRoleChain = subRoleChainData.mRoleChain; |
| 603 |
// bool subRoleNegation = subRoleChainData.mInverse; |
| 604 |
// CRole* superRole = subRoleChainData.mRole; |
| 605 |
// CSortedNegLinker<CRole*>* superSuperLinkerIt = superRole->getIndirectSuperRoleList(); |
| 606 |
// QSet<CRole*> locUnfoldRoleSet; |
| 607 |
// locUnfoldRoleSet.insert(role); |
| 608 |
// while (superSuperLinkerIt) { |
| 609 |
// CRole* superSuperRole = superSuperLinkerIt->getData(); |
| 610 |
// locUnfoldRoleSet.insert(superSuperRole); |
| 611 |
// superSuperLinkerIt = superSuperLinkerIt->getNext(); |
| 612 |
// } |
| 613 |
// generateRoleChainAutomatConcept(role,superRole,subRoleChain,subRoleNegation,locUnfoldRoleSet,beginState,endState,transType); |
| 614 |
// } |
| 615 |
// } |
| 616 |
//} |
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
return this; |
| 621 |
} |
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
CConcept* CRoleChainAutomataTransformationPreProcess::createAutomatGeneratingConcept(CSortedNegLinker<CConcept*>* opLinker, bool negate, CRole* role) { |
| 626 |
CConcept* concept = nullptr; |
| 627 |
concept = CObjectAllocator<CConcept>::allocateAndConstruct(mMemMan); |
| 628 |
concept->initConcept(); |
| 629 |
cint64 conTag = mNextConceptTag++; |
| 630 |
concept->setConceptTag(conTag); |
| 631 |
mConVec->setData(conTag,concept); |
| 632 |
concept->setOperatorCode(CCAQSOME); |
| 633 |
concept->setRole(role); |
| 634 |
CSortedNegLinker<CConcept*>* opLinkerIt = opLinker; |
| 635 |
while (opLinkerIt) { |
| 636 |
CConcept* opConcept = opLinkerIt->getData(); |
| 637 |
bool opNegation = opLinkerIt->isNegated() ^ negate; |
| 638 |
appendTransitionOperandConceptLinker(concept,createTransitionOperandConceptLinker(opConcept,opNegation)); |
| 639 |
opLinkerIt = opLinkerIt->getNext(); |
| 640 |
} |
| 641 |
return concept; |
| 642 |
} |
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
CRoleChainAutomataTransformationPreProcess* CRoleChainAutomataTransformationPreProcess::createInverseRoleChainLinkers() { |
| 647 |
FOREACHIT (CRoleChain* roleChain, mInverseUpdateRoleChainSet) { |
| 648 |
if (!roleChain->getInverseRoleChainLinker()) { |
| 649 |
CXLinker<CRole*>* roleLinkerIt = roleChain->getRoleChainLinker(); |
| 650 |
while (roleLinkerIt) { |
| 651 |
CRole* chainedRole = roleLinkerIt->getData(); |
| 652 |
CXLinker<CRole*>* invRoleLinker = CObjectAllocator< CXLinker<CRole*> >::allocateAndConstruct(mMemMan); |
| 653 |
invRoleLinker->initLinker(chainedRole); |
| 654 |
roleChain->prependInverseRoleChainLinker(invRoleLinker); |
| 655 |
roleLinkerIt = roleLinkerIt->getNext(); |
| 656 |
} |
| 657 |
} |
| 658 |
} |
| 659 |
return this; |
| 660 |
} |
| 661 |
|
| 662 |
|
| 663 |
CRoleChainAutomataTransformationPreProcess* CRoleChainAutomataTransformationPreProcess::createMissingInverseChainedRoles() { |
| 664 |
|
| 665 |
// collect direct and indirect sub roles |
| 666 |
QHash<qint64, QPair<cint64,bool> > roleTagIndirectSubRoleTagNegationHash; |
| 667 |
QHash<qint64, QPair<cint64,bool> > roleTagSubRoleTagNegationHash; |
| 668 |
qint64 itemCounts = mRoleVec->getItemCount(); |
| 669 |
for (qint64 i = 0; i < itemCounts; ++i) { |
| 670 |
CRole *role = mRoleVec->getData(i); |
| 671 |
if (role) { |
| 672 |
cint64 roleTag = role->getRoleTag(); |
| 673 |
CSortedNegLinker<CRole*>* inSuperRoleLinkerIt = role->getIndirectSuperRoleList(); |
| 674 |
while (inSuperRoleLinkerIt) { |
| 675 |
CRole* superRole = inSuperRoleLinkerIt->getData(); |
| 676 |
cint64 superRoleTag = superRole->getRoleTag(); |
| 677 |
bool superRoleNeg = inSuperRoleLinkerIt->isNegated(); |
| 678 |
roleTagIndirectSubRoleTagNegationHash.insertMulti(superRoleTag,QPair<cint64,bool>(roleTag,superRoleNeg)); |
| 679 |
inSuperRoleLinkerIt = inSuperRoleLinkerIt->getNext(); |
| 680 |
} |
| 681 |
CSortedNegLinker<CRole*>* superRoleLinkerIt = role->getSuperRoleList(); |
| 682 |
while (superRoleLinkerIt) { |
| 683 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 684 |
cint64 superRoleTag = superRole->getRoleTag(); |
| 685 |
bool superRoleNeg = superRoleLinkerIt->isNegated(); |
| 686 |
roleTagSubRoleTagNegationHash.insertMulti(superRoleTag,QPair<cint64,bool>(roleTag,superRoleNeg)); |
| 687 |
superRoleLinkerIt = superRoleLinkerIt->getNext(); |
| 688 |
} |
| 689 |
} |
| 690 |
} |
| 691 |
|
| 692 |
// build missing inverse roles |
| 693 |
QSet<CRole*> needsInverseRoleSet; |
| 694 |
for (qint64 i = 0; i < itemCounts; ++i) { |
| 695 |
CRole *role = mRoleVec->getLocalData(i); |
| 696 |
if (role) { |
| 697 |
if (role->isComplexRole()) { |
| 698 |
|
| 699 |
if (role->getDomainConceptList()) { |
| 700 |
needsInverseRoleSet.insert(role); |
| 701 |
} |
| 702 |
|
| 703 |
if (hasInverseRole(role) || role->getDomainConceptList() || role->getRangeConceptList()) { |
| 704 |
// check whether it is necessary to build additional inverse roles |
| 705 |
QList<CRole*> subRoleInvSearchList; |
| 706 |
QSet<CRole*> subRoleInvSearchSet; |
| 707 |
subRoleInvSearchList.append(role); |
| 708 |
subRoleInvSearchSet.insert(role); |
| 709 |
while (!subRoleInvSearchList.isEmpty()) { |
| 710 |
CRole* subRoleInvSearchRole = subRoleInvSearchList.takeFirst(); |
| 711 |
QList<CRoleSubRoleChainData> subRoleChainDataList(mRoleSubRoleChainDataHash.values(subRoleInvSearchRole)); |
| 712 |
for (QList<CRoleSubRoleChainData>::const_iterator it = subRoleChainDataList.constBegin(), itEnd = subRoleChainDataList.constEnd(); it != itEnd; ++it) { |
| 713 |
CRoleSubRoleChainData subRoleChainData(*it); |
| 714 |
CRoleChain* subRoleChain = subRoleChainData.mRoleChain; |
| 715 |
bool subRoleNegation = subRoleChainData.mInverse; |
| 716 |
CRole* superRole = subRoleChainData.mRole; |
| 717 |
needsInverseRoleSet.insert(superRole); |
| 718 |
|
| 719 |
CXLinker<CRole*>* chainedSubRoleLinkerIt = subRoleChain->getRoleChainLinker(); |
| 720 |
while (chainedSubRoleLinkerIt) { |
| 721 |
CRole* subRole = chainedSubRoleLinkerIt->getData(); |
| 722 |
needsInverseRoleSet.insert(subRole); |
| 723 |
if (!subRoleInvSearchSet.contains(subRole)) { |
| 724 |
subRoleInvSearchSet.insert(subRole); |
| 725 |
subRoleInvSearchList.append(subRole); |
| 726 |
} |
| 727 |
chainedSubRoleLinkerIt = chainedSubRoleLinkerIt->getNext(); |
| 728 |
} |
| 729 |
} |
| 730 |
} |
| 731 |
} |
| 732 |
} |
| 733 |
} |
| 734 |
} |
| 735 |
|
| 736 |
bool updatedInverseRoles = false; |
| 737 |
FOREACHIT (CRole* role, needsInverseRoleSet) { |
| 738 |
if (!hasInverseRole(role)) { |
| 739 |
// build additional inverse role |
| 740 |
role = getLocalizedRole(role); |
| 741 |
|
| 742 |
updatedInverseRoles = true; |
| 743 |
CRole* inverseRole = CObjectAllocator< CRole >::allocateAndConstruct(mMemMan); |
| 744 |
inverseRole->initRole(); |
| 745 |
cint64 inverseRoleTag = mRoleVec->getItemCount(); |
| 746 |
inverseRole->setRoleTag(inverseRoleTag); |
| 747 |
inverseRole->setRoleComplexity(role->getRoleComplexity()); |
| 748 |
mRoleVec->setData(inverseRole->getRoleTag(),inverseRole); |
| 749 |
|
| 750 |
CSortedNegLinker<CRole*>* invRoleLinker1 = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemMan); |
| 751 |
invRoleLinker1->init(role,true); |
| 752 |
inverseRole->addSuperRoleLinker(invRoleLinker1); |
| 753 |
CSortedNegLinker<CRole*>* invRoleLinker2 = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemMan); |
| 754 |
invRoleLinker2->init(inverseRole,true); |
| 755 |
role->addSuperRoleLinker(invRoleLinker2); |
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
CObjectPropertyTermExpression* buildExpression = mRoleObjPropTermHash->value(role); |
| 761 |
CInverseObjectPropertyOfExpression* expression = nullptr; |
| 762 |
expression = new CInverseObjectPropertyOfExpression(buildExpression); |
| 763 |
mExpressionBuildHash->insert(CExpressionHasher(expression),expression); |
| 764 |
mInverseObjectPropertyHash->insert(buildExpression,expression); |
| 765 |
mInverseObjectPropertyHash->insert(expression,buildExpression); |
| 766 |
mExpressionBuildContainerList->append(expression); |
| 767 |
mRoleObjPropTermHash->insert(role,expression); |
| 768 |
mObjPropTermRoleHash->insert(expression,role); |
| 769 |
|
| 770 |
|
| 771 |
QList< QPair<cint64,bool> > subRoleTagList(roleTagSubRoleTagNegationHash.values(role->getRoleTag())); |
| 772 |
for (QList< QPair<cint64,bool> >::const_iterator it = subRoleTagList.constBegin(), itEnd = subRoleTagList.constEnd(); it != itEnd; ++it) { |
| 773 |
cint64 subRoleTag = it->first; |
| 774 |
CRole* subRole = getLocalizedRole(subRoleTag); |
| 775 |
// add new inverse super role |
| 776 |
CSortedNegLinker<CRole*>* superRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemMan); |
| 777 |
superRoleLinker->init(inverseRole,!it->second); |
| 778 |
subRole->addSuperRoleLinker(superRoleLinker); |
| 779 |
} |
| 780 |
|
| 781 |
QList< QPair<cint64,bool> > indSubRoleTagList(roleTagIndirectSubRoleTagNegationHash.values(role->getRoleTag())); |
| 782 |
for (QList< QPair<cint64,bool> >::const_iterator it = indSubRoleTagList.constBegin(), itEnd = indSubRoleTagList.constEnd(); it != itEnd; ++it) { |
| 783 |
cint64 subRoleTag = it->first; |
| 784 |
CRole* subRole = getLocalizedRole(subRoleTag); |
| 785 |
// add new inverse super role |
| 786 |
CSortedNegLinker<CRole*>* superRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemMan); |
| 787 |
superRoleLinker->init(inverseRole,!it->second); |
| 788 |
subRole->addIndirectSuperRoleLinker(superRoleLinker); |
| 789 |
} |
| 790 |
|
| 791 |
// copy indirect super role linker to new inverse role |
| 792 |
CSortedNegLinker<CRole*>* inSuperRoleLinkerIt = role->getIndirectSuperRoleList(); |
| 793 |
while (inSuperRoleLinkerIt) { |
| 794 |
CRole* superRole = inSuperRoleLinkerIt->getData(); |
| 795 |
cint64 superRoleTag = superRole->getRoleTag(); |
| 796 |
bool superRoleNeg = inSuperRoleLinkerIt->isNegated(); |
| 797 |
|
| 798 |
CSortedNegLinker<CRole*>* invSuperRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemMan); |
| 799 |
invSuperRoleLinker->init(superRole,!superRoleNeg); |
| 800 |
inverseRole->addIndirectSuperRoleLinker(invSuperRoleLinker); |
| 801 |
|
| 802 |
roleTagIndirectSubRoleTagNegationHash.insertMulti(superRoleTag,QPair<cint64,bool>(inverseRoleTag,!superRoleNeg)); |
| 803 |
inSuperRoleLinkerIt = inSuperRoleLinkerIt->getNext(); |
| 804 |
} |
| 805 |
// copy super role linker to new inverse role |
| 806 |
CSortedNegLinker<CRole*>* superRoleLinkerIt = role->getSuperRoleList(); |
| 807 |
while (superRoleLinkerIt) { |
| 808 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 809 |
cint64 superRoleTag = superRole->getRoleTag(); |
| 810 |
bool superRoleNeg = superRoleLinkerIt->isNegated(); |
| 811 |
|
| 812 |
CSortedNegLinker<CRole*>* invSuperRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(mMemMan); |
| 813 |
invSuperRoleLinker->init(superRole,!superRoleNeg); |
| 814 |
inverseRole->addSuperRoleLinker(invSuperRoleLinker); |
| 815 |
|
| 816 |
roleTagSubRoleTagNegationHash.insertMulti(superRoleTag,QPair<cint64,bool>(inverseRoleTag,!superRoleNeg)); |
| 817 |
superRoleLinkerIt = superRoleLinkerIt->getNext(); |
| 818 |
} |
| 819 |
} |
| 820 |
} |
| 821 |
|
| 822 |
if (updatedInverseRoles) { |
| 823 |
mRoleSubRoleChainDataHash.clear(); |
| 824 |
collectSubRoleChains(); |
| 825 |
} |
| 826 |
return this; |
| 827 |
} |
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
bool CRoleChainAutomataTransformationPreProcess::hasInverseRole(CRole* role, bool searchInverseEquivalent) { |
| 833 |
return getInverseRole(role,searchInverseEquivalent) != nullptr; |
| 834 |
} |
| 835 |
|
| 836 |
|
| 837 |
CRole* CRoleChainAutomataTransformationPreProcess::getInverseRole(CRole* role, bool searchInverseEquivalent) { |
| 838 |
CRole* inverseRole = role->getInverseRole(); |
| 839 |
if (inverseRole) { |
| 840 |
return inverseRole; |
| 841 |
} |
| 842 |
CSortedNegLinker< CRole* >* inEqRoleLinkerIt = role->getInverseEquivalentRoleList(); |
| 843 |
while (inEqRoleLinkerIt) { |
| 844 |
CRole* invEqRole = inEqRoleLinkerIt->getData(); |
| 845 |
bool invEqRoleNeg = inEqRoleLinkerIt->isNegated(); |
| 846 |
if (invEqRoleNeg) { |
| 847 |
return invEqRole; |
| 848 |
} |
| 849 |
inEqRoleLinkerIt = inEqRoleLinkerIt->getNext(); |
| 850 |
} |
| 851 |
CSortedNegLinker< CRole* >* suberRoleLinkerIt = role->getSuperRoleList(); |
| 852 |
while (suberRoleLinkerIt) { |
| 853 |
CRole* superRole = suberRoleLinkerIt->getData(); |
| 854 |
bool superRoleNeg = suberRoleLinkerIt->isNegated(); |
| 855 |
if (superRoleNeg) { |
| 856 |
if (!searchInverseEquivalent) { |
| 857 |
return superRole; |
| 858 |
} else { |
| 859 |
CSortedNegLinker< CRole* >* invSuberRoleLinkerIt = superRole->getSuperRoleList(); |
| 860 |
while (invSuberRoleLinkerIt) { |
| 861 |
if (invSuberRoleLinkerIt->getData()->getRoleTag() == role->getRoleTag()) { |
| 862 |
return superRole; |
| 863 |
} |
| 864 |
invSuberRoleLinkerIt = invSuberRoleLinkerIt->getNext(); |
| 865 |
} |
| 866 |
} |
| 867 |
} |
| 868 |
suberRoleLinkerIt = suberRoleLinkerIt->getNext(); |
| 869 |
} |
| 870 |
return nullptr; |
| 871 |
} |
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
bool CRoleChainAutomataTransformationPreProcess::hasInversedOrNonInversedSuperRole(CRole* role, CRole* testingSuperRole) { |
| 876 |
return hasSuperRole(role,testingSuperRole,false,false); |
| 877 |
} |
| 878 |
|
| 879 |
bool CRoleChainAutomataTransformationPreProcess::hasInversedSuperRole(CRole* role, CRole* testingSuperRole) { |
| 880 |
return hasSuperRole(role,testingSuperRole,true,true); |
| 881 |
} |
| 882 |
|
| 883 |
bool CRoleChainAutomataTransformationPreProcess::hasNonInversedSuperRole(CRole* role, CRole* testingSuperRole) { |
| 884 |
return hasSuperRole(role,testingSuperRole,true,false); |
| 885 |
} |
| 886 |
|
| 887 |
bool CRoleChainAutomataTransformationPreProcess::hasSuperRole(CRole* role, CRole* testingSuperRole, bool superRoleInversedRequired) { |
| 888 |
return hasSuperRole(role,testingSuperRole,true,superRoleInversedRequired); |
| 889 |
} |
| 890 |
|
| 891 |
bool CRoleChainAutomataTransformationPreProcess::hasSuperRole(CRole* role, CRole* testingSuperRole, bool testInversed, bool superRoleInversedRequired) { |
| 892 |
for (CSortedNegLinker<CRole*>* superRoleLinkerIt = role->getIndirectSuperRoleList(); superRoleLinkerIt; superRoleLinkerIt = superRoleLinkerIt->getNext()) { |
| 893 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 894 |
if (superRole == testingSuperRole) { |
| 895 |
if (testInversed) { |
| 896 |
if (superRoleLinkerIt->isNegated() == superRoleInversedRequired) { |
| 897 |
return true; |
| 898 |
} |
| 899 |
} else { |
| 900 |
return true; |
| 901 |
} |
| 902 |
} |
| 903 |
} |
| 904 |
return false; |
| 905 |
} |
| 906 |
|
| 907 |
|
| 908 |
bool CRoleChainAutomataTransformationPreProcess::isChainLinkerImplicit(CXLinker<CRole*>* testingImplicitChainLinker, CXLinker<CRole*>* chainLinker, bool inversedTesting) { |
| 909 |
CXLinker<CRole*>* testingChainLinkerIt = testingImplicitChainLinker; |
| 910 |
CXLinker<CRole*>* chainLinkerIt = chainLinker; |
| 911 |
for (; testingChainLinkerIt && chainLinkerIt; testingChainLinkerIt = testingChainLinkerIt->getNext(), chainLinkerIt = chainLinkerIt->getNext()) { |
| 912 |
|
| 913 |
CRole* testingChainRole = testingChainLinkerIt->getData(); |
| 914 |
CRole* chainRole = chainLinkerIt->getData(); |
| 915 |
|
| 916 |
if (!hasSuperRole(testingChainRole,chainRole,inversedTesting)) { |
| 917 |
return false; |
| 918 |
} |
| 919 |
} |
| 920 |
if (testingChainLinkerIt || chainLinkerIt) { |
| 921 |
return false; |
| 922 |
} |
| 923 |
return true; |
| 924 |
} |
| 925 |
|
| 926 |
|
| 927 |
bool CRoleChainAutomataTransformationPreProcess::isTransitiveChainData(const CRoleSubRoleChainData& chainData) { |
| 928 |
cint64 transChainedRoleCount = 0; |
| 929 |
CRole* chainSuperRole = chainData.mRole; |
| 930 |
for (CXLinker<CRole*>* chainLinkerIt = chainData.mRoleChain->getRoleChainLinker(); chainLinkerIt ; chainLinkerIt = chainLinkerIt->getNext()) { |
| 931 |
CRole* chainedRole = chainLinkerIt->getData(); |
| 932 |
if (chainedRole != chainSuperRole) { |
| 933 |
return false; |
| 934 |
} |
| 935 |
++transChainedRoleCount; |
| 936 |
} |
| 937 |
if (transChainedRoleCount == 2) { |
| 938 |
return true; |
| 939 |
} |
| 940 |
return false; |
| 941 |
} |
| 942 |
|
| 943 |
|
| 944 |
bool CRoleChainAutomataTransformationPreProcess::isChainDataImplicit(const CRoleSubRoleChainData& testingImplicitChainData, const CRoleSubRoleChainData& chainData) { |
| 945 |
// the testingImplicitChainData is implicit if every used role is a subrole of the corresponding role in chainData |
| 946 |
CRole* testingChainSuperRole = testingImplicitChainData.mRole; |
| 947 |
CRole* chainSuperRole = chainData.mRole; |
| 948 |
bool inversedTesting = chainData.mInverse ^ testingImplicitChainData.mInverse; |
| 949 |
if (hasInversedOrNonInversedSuperRole(testingChainSuperRole,chainSuperRole)) { |
| 950 |
|
| 951 |
if (!inversedTesting && hasNonInversedSuperRole(testingChainSuperRole,chainSuperRole)) { |
| 952 |
CXLinker<CRole*>* testingChainLinker = testingImplicitChainData.mRoleChain->getRoleChainLinker(); |
| 953 |
CXLinker<CRole*>* chainLinker = chainData.mRoleChain->getRoleChainLinker(); |
| 954 |
if (isChainLinkerImplicit(testingChainLinker,chainLinker,false)) { |
| 955 |
return true; |
| 956 |
} |
| 957 |
} |
| 958 |
|
| 959 |
if (inversedTesting && hasInversedSuperRole(testingChainSuperRole,chainSuperRole)) { |
| 960 |
CXLinker<CRole*>* testingChainLinker = testingImplicitChainData.mRoleChain->getRoleChainLinker(); |
| 961 |
CXLinker<CRole*>* chainLinker = chainData.mRoleChain->getInverseRoleChainLinker(); |
| 962 |
if (isChainLinkerImplicit(testingChainLinker,chainLinker,true)) { |
| 963 |
return true; |
| 964 |
} |
| 965 |
} |
| 966 |
} |
| 967 |
return false; |
| 968 |
} |
| 969 |
|
| 970 |
bool CRoleChainAutomataTransformationPreProcess::isChainDataRecursiveTraversalCritical(CRole* role, const CRoleSubRoleChainData& chainData) { |
| 971 |
// test first and last chain linker |
| 972 |
CRole* chainSuperRole = chainData.mRole; |
| 973 |
if (chainSuperRole != role) { |
| 974 |
if (!hasInversedOrNonInversedSuperRole(role,chainSuperRole)) { |
| 975 |
CXLinker<CRole*>* chainLinkerIt = chainData.mRoleChain->getRoleChainLinker(); |
| 976 |
if (chainLinkerIt->getData() == chainSuperRole) { |
| 977 |
return true; |
| 978 |
} |
| 979 |
if (chainLinkerIt->getLastListLink()->getData() == chainSuperRole) { |
| 980 |
return true; |
| 981 |
} |
| 982 |
} |
| 983 |
} |
| 984 |
return false; |
| 985 |
} |
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
QList<CRoleSubRoleChainData> CRoleChainAutomataTransformationPreProcess::getRelevantChainDataList(CRole* role, const QList<CRoleSubRoleChainData>& roleSubChainDataList) { |
| 992 |
QList<CRoleSubRoleChainData> relevantChainDataList; |
| 993 |
for (QList<CRoleSubRoleChainData>::const_iterator it = roleSubChainDataList.constBegin(), itEnd = roleSubChainDataList.constEnd(); it != itEnd; ++it) { |
| 994 |
const CRoleSubRoleChainData& roleChainData(*it); |
| 995 |
bool hasImplicitRoleChainData = false; |
| 996 |
QList<CRoleSubRoleChainData>::const_iterator it2 = it; |
| 997 |
for (++it2; it2 != itEnd && !hasImplicitRoleChainData; ++it2) { |
| 998 |
const CRoleSubRoleChainData& roleChainData2(*it2); |
| 999 |
if (isChainDataImplicit(roleChainData,roleChainData2)) { |
| 1000 |
hasImplicitRoleChainData = true; |
| 1001 |
} |
| 1002 |
} |
| 1003 |
for (QList<CRoleSubRoleChainData>::const_iterator it2 = relevantChainDataList.constBegin(), it2End = relevantChainDataList.constEnd(); it2 != it2End && !hasImplicitRoleChainData; ++it2) { |
| 1004 |
const CRoleSubRoleChainData& roleChainData2(*it2); |
| 1005 |
if (isChainDataImplicit(roleChainData,roleChainData2)) { |
| 1006 |
hasImplicitRoleChainData = true; |
| 1007 |
} |
| 1008 |
} |
| 1009 |
if (!hasImplicitRoleChainData) { |
| 1010 |
relevantChainDataList.append(roleChainData); |
| 1011 |
} |
| 1012 |
} |
| 1013 |
return relevantChainDataList; |
| 1014 |
} |
| 1015 |
|
| 1016 |
|
| 1017 |
QHash<CRole*,bool> CRoleChainAutomataTransformationPreProcess::getRelevantRecursiveTraversalCriticalRoles(QHash<CRole*,bool>* criticalRoleNegationHash) { |
| 1018 |
// return the most general roles |
| 1019 |
QHash<CRole*,bool> criticalGeneralRoleNegationHash; |
| 1020 |
for (QHash<CRole*,bool>::const_iterator it = criticalRoleNegationHash->constBegin(), itEnd = criticalRoleNegationHash->constEnd(); it != itEnd; ++it) { |
| 1021 |
CRole* role = it.key(); |
| 1022 |
bool roleInversed = it.value(); |
| 1023 |
bool hasCriticalSuperRole = false; |
| 1024 |
QHash<CRole*,bool>::const_iterator it2 = it; |
| 1025 |
for (++it2; it2 != itEnd && !hasCriticalSuperRole; ++it2) { |
| 1026 |
CRole* role2 = it2.key(); |
| 1027 |
bool role2Inversed = it2.value(); |
| 1028 |
if (role != role2) { |
| 1029 |
if (hasInversedOrNonInversedSuperRole(role,role2)) { |
| 1030 |
hasCriticalSuperRole = true; |
| 1031 |
} |
| 1032 |
} |
| 1033 |
} |
| 1034 |
for (QHash<CRole*,bool>::const_iterator it2 = criticalGeneralRoleNegationHash.constBegin(), it2End = criticalGeneralRoleNegationHash.constEnd(); it2 != it2End && !hasCriticalSuperRole; ++it2) { |
| 1035 |
CRole* role2 = it2.key(); |
| 1036 |
bool role2Inversed = it2.value(); |
| 1037 |
if (role != role2) { |
| 1038 |
if (hasInversedOrNonInversedSuperRole(role,role2)) { |
| 1039 |
hasCriticalSuperRole = true; |
| 1040 |
} |
| 1041 |
} |
| 1042 |
} |
| 1043 |
if (!hasCriticalSuperRole) { |
| 1044 |
criticalGeneralRoleNegationHash.insert(role,roleInversed); |
| 1045 |
} |
| 1046 |
} |
| 1047 |
return criticalGeneralRoleNegationHash; |
| 1048 |
} |
| 1049 |
|
| 1050 |
|
| 1051 |
bool CRoleChainAutomataTransformationPreProcess::collectRecursiveTraversalCriticalRoles(CRole* role, const CRoleSubRoleChainData& chainData, QHash<CRole*,bool>* criticalRoleNegationHash) { |
| 1052 |
if (isChainDataRecursiveTraversalCritical(role,chainData)) { |
| 1053 |
CRole* chainSuperRole = chainData.mRole; |
| 1054 |
bool negatedSuperRole = chainData.mInverse; |
| 1055 |
criticalRoleNegationHash->insert(chainSuperRole,negatedSuperRole); |
| 1056 |
return true; |
| 1057 |
} |
| 1058 |
return false; |
| 1059 |
} |
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
bool CRoleChainAutomataTransformationPreProcess::requiresRecursiveTraversalForRole(CRole* role, const CRoleSubRoleChainData& chainData, QHash<CRole*,bool>* criticalRoleNegationHash) { |
| 1064 |
CRole* chainSuperRole = chainData.mRole; |
| 1065 |
for (CSortedNegLinker<CRole*>* superRoleIt = chainSuperRole->getIndirectSuperRoleList(); superRoleIt; superRoleIt = superRoleIt->getNext()) { |
| 1066 |
CRole* superRole = superRoleIt->getData(); |
| 1067 |
bool superRoleNeg = superRoleIt->isNegated() ^ chainData.mInverse; |
| 1068 |
if (criticalRoleNegationHash->contains(superRole)) { |
| 1069 |
return true; |
| 1070 |
} |
| 1071 |
} |
| 1072 |
return false; |
| 1073 |
} |
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
CRoleChainAutomataTransformationPreProcess* CRoleChainAutomataTransformationPreProcess::collectSubRoleChains() { |
| 1079 |
qint64 itemCounts = mRoleVec->getItemCount(); |
| 1080 |
for (qint64 i = 0; i < itemCounts; ++i) { |
| 1081 |
CRole *role = mRoleVec->getData(i); |
| 1082 |
if (role) { |
| 1083 |
if (role->isComplexRole()) { |
| 1084 |
CXLinker<CRoleChain*>* roleChainLinkerIt = role->getRoleChainSuperSharingLinker(); |
| 1085 |
while (roleChainLinkerIt) { |
| 1086 |
CRoleChain* roleChain = roleChainLinkerIt->getData(); |
| 1087 |
if (!roleChain->getInverseRoleChainLinker()) { |
| 1088 |
mInverseUpdateRoleChainSet.insert(roleChain); |
| 1089 |
} |
| 1090 |
CSortedNegLinker< CRole* >* suberRoleLinkerIt = role->getIndirectSuperRoleList(); |
| 1091 |
while (suberRoleLinkerIt) { |
| 1092 |
CRole* superRole = suberRoleLinkerIt->getData(); |
| 1093 |
bool superRoleNeg = suberRoleLinkerIt->isNegated(); |
| 1094 |
superRole = mRoleVec->getData(superRole->getRoleTag()); |
| 1095 |
mRoleSubRoleChainDataHash.insertMulti(superRole,CRoleSubRoleChainData(role,roleChain,superRoleNeg)); |
| 1096 |
suberRoleLinkerIt = suberRoleLinkerIt->getNext(); |
| 1097 |
} |
| 1098 |
roleChainLinkerIt = roleChainLinkerIt->getNext(); |
| 1099 |
} |
| 1100 |
} |
| 1101 |
} |
| 1102 |
} |
| 1103 |
return this; |
| 1104 |
} |
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
CRoleChainAutomataTransformationPreProcess* CRoleChainAutomataTransformationPreProcess::createRecursiveTraversalData() { |
| 1111 |
CRole* currentRole = nullptr; |
| 1112 |
QList<CRoleSubRoleChainData> roleSubChainDataList; |
| 1113 |
for (QHash<CRole*,CRoleSubRoleChainData>::const_iterator it = mRoleSubRoleChainDataHash.constBegin(), itEnd = mRoleSubRoleChainDataHash.constEnd(); it != itEnd; ++it) { |
| 1114 |
CRole* role(it.key()); |
| 1115 |
const CRoleSubRoleChainData& roleSubChainData(it.value()); |
| 1116 |
if (currentRole != role) { |
| 1117 |
if (currentRole) { |
| 1118 |
addRecursiveTraversalData(currentRole,roleSubChainDataList); |
| 1119 |
currentRole = nullptr; |
| 1120 |
roleSubChainDataList.clear(); |
| 1121 |
} |
| 1122 |
currentRole = role; |
| 1123 |
} |
| 1124 |
roleSubChainDataList.append(roleSubChainData); |
| 1125 |
} |
| 1126 |
if (currentRole) { |
| 1127 |
addRecursiveTraversalData(currentRole,roleSubChainDataList); |
| 1128 |
} |
| 1129 |
return this; |
| 1130 |
} |
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
CRoleChainAutomataTransformationPreProcess* CRoleChainAutomataTransformationPreProcess::addRecursiveTraversalData(CRole* role, const QList<CRoleSubRoleChainData>& roleSubChainDataList) { |
| 1135 |
//if (CIRIName::getRecentIRIName(role->getPropertyNameLinker()) == "#isInLawOf") { |
| 1136 |
// bool debug = true; |
| 1137 |
//} |
| 1138 |
QList<CRoleSubRoleChainData> relevantChainDataList(getRelevantChainDataList(role,roleSubChainDataList)); |
| 1139 |
CRecTravSubRoleChainDataItem& recTravSubRoleChainData = mRoleRecTravSubRoleChainDataHash[role]; |
| 1140 |
recTravSubRoleChainData.mRole = role; |
| 1141 |
QHash<CRole*,bool> criticalRoleNegationHash; |
| 1142 |
bool criticalRecursiveTraversalRoles = false; |
| 1143 |
for (QList<CRoleSubRoleChainData>::const_iterator it = relevantChainDataList.constBegin(), itEnd = relevantChainDataList.constEnd(); it != itEnd; ++it) { |
| 1144 |
const CRoleSubRoleChainData& chainData(*it); |
| 1145 |
criticalRecursiveTraversalRoles |= collectRecursiveTraversalCriticalRoles(role,chainData,&criticalRoleNegationHash); |
| 1146 |
} |
| 1147 |
if (!criticalRecursiveTraversalRoles) { |
| 1148 |
recTravSubRoleChainData.mDirectSubRoleChainDataList = relevantChainDataList; |
| 1149 |
} else { |
| 1150 |
QHash<CRole*,bool> relevantCriticalRoleNegationHash(getRelevantRecursiveTraversalCriticalRoles(&criticalRoleNegationHash)); |
| 1151 |
for (QList<CRoleSubRoleChainData>::const_iterator it = relevantChainDataList.constBegin(), itEnd = relevantChainDataList.constEnd(); it != itEnd; ++it) { |
| 1152 |
const CRoleSubRoleChainData& chainData(*it); |
| 1153 |
if (!requiresRecursiveTraversalForRole(role,chainData,&relevantCriticalRoleNegationHash)) { |
| 1154 |
recTravSubRoleChainData.mDirectSubRoleChainDataList.append(chainData); |
| 1155 |
} |
| 1156 |
} |
| 1157 |
for (QHash<CRole*,bool>::const_iterator it = relevantCriticalRoleNegationHash.constBegin(), itEnd = relevantCriticalRoleNegationHash.constEnd(); it != itEnd; ++it) { |
| 1158 |
CRole* role(it.key()); |
| 1159 |
bool inversed(it.value()); |
| 1160 |
if (recTravSubRoleChainData.mRole->isSymmetric() && recTravSubRoleChainData.mRole->getInverseRole() == recTravSubRoleChainData.mRole) { |
| 1161 |
recTravSubRoleChainData.mRecTraversalSubRoleList.append(TRoleNegationPair(role,!inversed)); |
| 1162 |
} |
| 1163 |
recTravSubRoleChainData.mRecTraversalSubRoleList.append(TRoleNegationPair(role,inversed)); |
| 1164 |
} |
| 1165 |
} |
| 1166 |
return this; |
| 1167 |
} |
| 1168 |
|
| 1169 |
|
| 1170 |
CConcept* CRoleChainAutomataTransformationPreProcess::createTransitionConcept(CRole* role, TRANSLATIONTYPE transType) { |
| 1171 |
CConcept* concept = nullptr; |
| 1172 |
concept = CObjectAllocator<CConcept>::allocateAndConstruct(mMemMan); |
| 1173 |
concept->initConcept(); |
| 1174 |
cint64 conTag = mNextConceptTag++; |
| 1175 |
concept->setConceptTag(conTag); |
| 1176 |
mConVec->setData(conTag,concept); |
| 1177 |
concept->setRole(role); |
| 1178 |
cint64 opCode = CCAQALL; |
| 1179 |
if (transType == TTNORMAL) { |
| 1180 |
opCode = CCAQALL; |
| 1181 |
} else if (transType == TTIMPL) { |
| 1182 |
opCode = CCIMPLAQALL; |
| 1183 |
} else if (transType == TTBRANCH) { |
| 1184 |
opCode = CCBRANCHAQALL; |
| 1185 |
} else if (transType == TTPROPBIND) { |
| 1186 |
opCode = CCPBINDAQALL; |
| 1187 |
} else if (transType == TTBACKPROP) { |
| 1188 |
opCode = CCVARPBACKAQALL; |
| 1189 |
} else if (transType == TTVARBIND) { |
| 1190 |
opCode = CCVARBINDAQALL; |
| 1191 |
} |
| 1192 |
concept->setOperatorCode(opCode); |
| 1193 |
++mStatAutomateTransitionConceptCount; |
| 1194 |
return concept; |
| 1195 |
} |
| 1196 |
|
| 1197 |
|
| 1198 |
CConcept* CRoleChainAutomataTransformationPreProcess::createNominalConcept(CIndividual* individual) { |
| 1199 |
individual = CConceptRoleIndividualLocator::getLocatedIndividual(individual,mOntology); |
| 1200 |
CConcept* concept = individual->getIndividualNominalConcept(); |
| 1201 |
if (!concept) { |
| 1202 |
concept = CObjectAllocator<CConcept>::allocateAndConstruct(mMemMan); |
| 1203 |
concept->initConcept(); |
| 1204 |
cint64 conTag = mNextConceptTag++; |
| 1205 |
concept->setConceptTag(conTag); |
| 1206 |
mConVec->setData(conTag,concept); |
| 1207 |
concept->setOperatorCode(CCNOMINAL); |
| 1208 |
concept->setNominalIndividual(individual); |
| 1209 |
individual->setIndividualNominalConcept(concept); |
| 1210 |
} |
| 1211 |
return concept; |
| 1212 |
} |
| 1213 |
|
| 1214 |
|
| 1215 |
CConcept* CRoleChainAutomataTransformationPreProcess::createStateConcept(TRANSLATIONTYPE transType) { |
| 1216 |
CConcept* concept = nullptr; |
| 1217 |
concept = CObjectAllocator<CConcept>::allocateAndConstruct(mMemMan); |
| 1218 |
concept->initConcept(); |
| 1219 |
cint64 conTag = mNextConceptTag++; |
| 1220 |
concept->setConceptTag(conTag); |
| 1221 |
mConVec->setData(conTag,concept); |
| 1222 |
cint64 opCode = CCAQAND; |
| 1223 |
if (transType == TTNORMAL) { |
| 1224 |
opCode = CCAQAND; |
| 1225 |
} else if (transType == TTIMPL) { |
| 1226 |
opCode = CCIMPLAQAND; |
| 1227 |
} else if (transType == TTBRANCH) { |
| 1228 |
opCode = CCBRANCHAQAND; |
| 1229 |
} else if (transType == TTPROPBIND) { |
| 1230 |
opCode = CCPBINDAQAND; |
| 1231 |
} else if (transType == TTBACKPROP) { |
| 1232 |
opCode = CCVARPBACKAQAND; |
| 1233 |
} else if (transType == TTVARBIND) { |
| 1234 |
opCode = CCVARBINDAQAND; |
| 1235 |
} |
| 1236 |
concept->setOperatorCode(opCode); |
| 1237 |
++mStatAutomateStateConceptCount; |
| 1238 |
return concept; |
| 1239 |
} |
| 1240 |
|
| 1241 |
|
| 1242 |
CSortedNegLinker<CConcept*>* CRoleChainAutomataTransformationPreProcess::createTransitionOperandConceptLinker(CConcept* operandConcept, bool negation) { |
| 1243 |
CSortedNegLinker<CConcept*>* opConceptLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemMan); |
| 1244 |
opConceptLinker->init(operandConcept,negation); |
| 1245 |
return opConceptLinker; |
| 1246 |
} |
| 1247 |
|
| 1248 |
CConcept* CRoleChainAutomataTransformationPreProcess::appendTransitionOperandConceptLinker(CConcept* concept, CSortedNegLinker<CConcept*>* opLinker) { |
| 1249 |
|
| 1250 |
//for (CSortedNegLinker<CConcept*>* opLinkerIt = concept->getOperandList(); opLinkerIt; opLinkerIt = opLinkerIt->getNext()) { |
| 1251 |
// CConcept* opCon = opLinkerIt->getData(); |
| 1252 |
// if (opCon == opLinker->getData()) { |
| 1253 |
// if (opLinkerIt->isNegated() == opLinker->isNegated()) { |
| 1254 |
// bool bug = true; |
| 1255 |
// } |
| 1256 |
// } |
| 1257 |
//} |
| 1258 |
|
| 1259 |
concept->addOperandLinker(opLinker); |
| 1260 |
concept->incOperandCount(); |
| 1261 |
return concept; |
| 1262 |
} |
| 1263 |
|
| 1264 |
bool CRoleChainAutomataTransformationPreProcess::generateRoleChainAutomatConcept(CRole* lastRole, const CRecTravSubRoleChainDataItem& recTravSubRoleChainDataItem, QSet<CRole*>& alreadyUnfoldRoleSet, CConcept* beginConcept, CConcept* endConcept, TRANSLATIONTYPE transType) { |
| 1265 |
const QList<CRoleSubRoleChainData>& subRoleChainDataList(recTravSubRoleChainDataItem.mDirectSubRoleChainDataList); |
| 1266 |
generateRoleChainAutomatConcept(lastRole,subRoleChainDataList,alreadyUnfoldRoleSet,beginConcept,endConcept,transType); |
| 1267 |
|
| 1268 |
const QList<TRoleNegationPair>& recTravSubRoleList(recTravSubRoleChainDataItem.mRecTraversalSubRoleList); |
| 1269 |
for (QList<TRoleNegationPair>::const_iterator it = recTravSubRoleList.constBegin(), itEnd = recTravSubRoleList.constEnd(); it != itEnd; ++it) { |
| 1270 |
TRoleNegationPair recTravSubRoleNegPair(*it); |
| 1271 |
CRole* recTravSubRole(recTravSubRoleNegPair.first); |
| 1272 |
|
| 1273 |
if (!alreadyUnfoldRoleSet.contains(recTravSubRole)) { |
| 1274 |
bool recTravSubRoleInversed(recTravSubRoleNegPair.second); |
| 1275 |
if (recTravSubRoleInversed) { |
| 1276 |
recTravSubRole = getInverseRole(recTravSubRole); |
| 1277 |
} |
| 1278 |
|
| 1279 |
QSet<CRole*> locUnfoldRoleSet(alreadyUnfoldRoleSet); |
| 1280 |
locUnfoldRoleSet.insert(recTravSubRole); |
| 1281 |
CSortedNegLinker<CRole*>* superSuperLinkerIt = recTravSubRole->getIndirectSuperRoleList(); |
| 1282 |
while (superSuperLinkerIt) { |
| 1283 |
CRole* superSuperRole = superSuperLinkerIt->getData(); |
| 1284 |
locUnfoldRoleSet.insert(superSuperRole); |
| 1285 |
superSuperLinkerIt = superSuperLinkerIt->getNext(); |
| 1286 |
} |
| 1287 |
|
| 1288 |
CConcept* recTravSubBeginConcept = createStateConcept(transType); |
| 1289 |
CConcept* recTravSubEndConcept = createStateConcept(transType); |
| 1290 |
appendTransitionOperandConceptLinker(beginConcept,createTransitionOperandConceptLinker(recTravSubBeginConcept,false)); |
| 1291 |
appendTransitionOperandConceptLinker(recTravSubEndConcept,createTransitionOperandConceptLinker(endConcept,false)); |
| 1292 |
CConcept* recTravPropCon = createTransitionConcept(recTravSubRole,transType); |
| 1293 |
appendTransitionOperandConceptLinker(recTravSubBeginConcept,createTransitionOperandConceptLinker(recTravPropCon,false)); |
| 1294 |
appendTransitionOperandConceptLinker(recTravPropCon,createTransitionOperandConceptLinker(recTravSubEndConcept,false)); |
| 1295 |
const CRecTravSubRoleChainDataItem& nextRecTravSubRoleChainDataItem(mRoleRecTravSubRoleChainDataHash.value(recTravSubRole)); |
| 1296 |
generateRoleChainAutomatConcept(recTravSubRole,nextRecTravSubRoleChainDataItem,locUnfoldRoleSet,recTravSubBeginConcept,recTravSubEndConcept,transType); |
| 1297 |
} |
| 1298 |
} |
| 1299 |
return true; |
| 1300 |
} |
| 1301 |
|
| 1302 |
bool CRoleChainAutomataTransformationPreProcess::generateRoleChainAutomatConcept(CRole* lastRole, const QList<CRoleSubRoleChainData>& subRoleChainDataList, QSet<CRole*>& alreadyUnfoldRoleSet, CConcept* beginConcept, CConcept* endConcept, TRANSLATIONTYPE transType) { |
| 1303 |
for (QList<CRoleSubRoleChainData>::const_iterator it = subRoleChainDataList.constBegin(), itEnd = subRoleChainDataList.constEnd(); it != itEnd; ++it) { |
| 1304 |
CRoleSubRoleChainData subRoleChainData(*it); |
| 1305 |
CRoleChain* subRoleChain = subRoleChainData.mRoleChain; |
| 1306 |
bool subRoleNegation = subRoleChainData.mInverse; |
| 1307 |
CRole* superRoleChain = subRoleChainData.mRole; |
| 1308 |
|
| 1309 |
QSet<CRole*> locUnfoldRoleSet(alreadyUnfoldRoleSet); |
| 1310 |
locUnfoldRoleSet.insert(lastRole); |
| 1311 |
CSortedNegLinker<CRole*>* superSuperLinkerIt = superRoleChain->getIndirectSuperRoleList(); |
| 1312 |
while (superSuperLinkerIt) { |
| 1313 |
CRole* superSuperRole = superSuperLinkerIt->getData(); |
| 1314 |
locUnfoldRoleSet.insert(superSuperRole); |
| 1315 |
superSuperLinkerIt = superSuperLinkerIt->getNext(); |
| 1316 |
} |
| 1317 |
|
| 1318 |
generateRoleChainAutomatConcept(lastRole,superRoleChain,subRoleChain,subRoleNegation,locUnfoldRoleSet,beginConcept,endConcept,transType); |
| 1319 |
} |
| 1320 |
return true; |
| 1321 |
} |
| 1322 |
|
| 1323 |
|
| 1324 |
bool CRoleChainAutomataTransformationPreProcess::generateRoleChainAutomatConcept(CRole* lastRole, CRole* superRole, CRoleChain* descendingRoleChain, bool negatedChain, QSet<CRole*>& alreadyUnfoldRoleSet, CConcept* beginConcept, CConcept* endConcept, TRANSLATIONTYPE transType) { |
| 1325 |
// TODO: |
| 1326 |
// generate for each role in the role chain a concept |
| 1327 |
// connect all concepts with each other, |
| 1328 |
// append the first connected concept to the appending list |
| 1329 |
// return later the last connected concept |
| 1330 |
// for each generated concept in the role chain |
| 1331 |
// check whether related role is complex and is not already used above (hash) |
| 1332 |
// recursive call to generate concepts for each role chain and sub role |
| 1333 |
|
| 1334 |
CXLinker<CRole*>* chainedRoleLinker = nullptr; |
| 1335 |
CXLinker<CRole*>* inverseChainedRoleLinker = nullptr; |
| 1336 |
bool useInverseRoles = negatedChain; |
| 1337 |
if (!negatedChain) { |
| 1338 |
chainedRoleLinker = descendingRoleChain->getRoleChainLinker(); |
| 1339 |
inverseChainedRoleLinker = descendingRoleChain->getInverseRoleChainLinker(); |
| 1340 |
} else { |
| 1341 |
chainedRoleLinker = descendingRoleChain->getInverseRoleChainLinker(); |
| 1342 |
inverseChainedRoleLinker = descendingRoleChain->getRoleChainLinker(); |
| 1343 |
} |
| 1344 |
CConcept* connectBeginCon = nullptr; |
| 1345 |
CConcept* connectEndCon = nullptr; |
| 1346 |
CConcept* firstConcept = nullptr; |
| 1347 |
CConcept* lastConcept = nullptr; |
| 1348 |
bool transStart = false; |
| 1349 |
bool transEnd = false; |
| 1350 |
|
| 1351 |
CRole* testRole = superRole; |
| 1352 |
if (useInverseRoles && lastRole != superRole) { |
| 1353 |
testRole = getInverseRole(superRole); |
| 1354 |
} |
| 1355 |
|
| 1356 |
|
| 1357 |
while (chainedRoleLinker) { |
| 1358 |
CRole* subRole = chainedRoleLinker->getData(); |
| 1359 |
if (useInverseRoles) { |
| 1360 |
// search inverse role |
| 1361 |
subRole = getInverseRole(subRole); |
| 1362 |
} |
| 1363 |
|
| 1364 |
subRole = mRoleVec->getData(subRole->getRoleTag()); |
| 1365 |
if (!firstConcept && subRole == testRole && !transStart) { |
| 1366 |
// transitive start |
| 1367 |
transStart = true; |
| 1368 |
} else if (!chainedRoleLinker->hasNext() && subRole == testRole) { |
| 1369 |
// transitive end |
| 1370 |
transEnd = true; |
| 1371 |
} else if (!alreadyUnfoldRoleSet.contains(subRole)) { |
| 1372 |
// test recursive call |
| 1373 |
|
| 1374 |
CConcept* subBeginConcept = createStateConcept(transType); |
| 1375 |
CConcept* propCon = createTransitionConcept(subRole,transType); |
| 1376 |
CConcept* subEndConcept = createStateConcept(transType); |
| 1377 |
if (!connectBeginCon) { |
| 1378 |
connectBeginCon = subBeginConcept; |
| 1379 |
} |
| 1380 |
if (connectEndCon) { |
| 1381 |
appendTransitionOperandConceptLinker(connectEndCon,createTransitionOperandConceptLinker(subBeginConcept,false)); |
| 1382 |
} |
| 1383 |
connectEndCon = subEndConcept; |
| 1384 |
|
| 1385 |
if (!firstConcept) { |
| 1386 |
firstConcept = propCon; |
| 1387 |
} |
| 1388 |
appendTransitionOperandConceptLinker(subBeginConcept,createTransitionOperandConceptLinker(propCon,false)); |
| 1389 |
appendTransitionOperandConceptLinker(propCon,createTransitionOperandConceptLinker(subEndConcept,false)); |
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
const CRecTravSubRoleChainDataItem& recTravSubRoleChainDataItem(mRoleRecTravSubRoleChainDataHash.value(subRole)); |
| 1394 |
generateRoleChainAutomatConcept(subRole,recTravSubRoleChainDataItem,alreadyUnfoldRoleSet,subBeginConcept,subEndConcept,transType); |
| 1395 |
|
| 1396 |
//const QList<CRoleSubRoleChainData>& subRoleChainDataList(recTravSubRoleChainDataItem.mDirectSubRoleChainDataList); |
| 1397 |
//generateRoleChainAutomatConcept(subRole,subRoleChainDataList,alreadyUnfoldRoleSet,subBeginConcept,subEndConcept,transType); |
| 1398 |
|
| 1399 |
////for (QList<CRoleSubRoleChainData>::const_iterator it = subRoleChainDataList.constBegin(), itEnd = subRoleChainDataList.constEnd(); it != itEnd; ++it) { |
| 1400 |
//// CRoleSubRoleChainData subRoleChainData(*it); |
| 1401 |
//// CRoleChain* subRoleChain = subRoleChainData.mRoleChain; |
| 1402 |
//// bool subRoleNegation = subRoleChainData.mInverse; |
| 1403 |
//// CRole* superRoleChain = subRoleChainData.mRole; |
| 1404 |
|
| 1405 |
//// QSet<CRole*> locUnfoldRoleSet(alreadyUnfoldRoleSet); |
| 1406 |
//// locUnfoldRoleSet.insert(subRole); |
| 1407 |
//// CSortedNegLinker<CRole*>* superSuperLinkerIt = superRoleChain->getIndirectSuperRoleList(); |
| 1408 |
//// while (superSuperLinkerIt) { |
| 1409 |
//// CRole* superSuperRole = superSuperLinkerIt->getData(); |
| 1410 |
//// locUnfoldRoleSet.insert(superSuperRole); |
| 1411 |
//// superSuperLinkerIt = superSuperLinkerIt->getNext(); |
| 1412 |
//// } |
| 1413 |
|
| 1414 |
//// generateRoleChainAutomatConcept(subRole,superRoleChain,subRoleChain,subRoleNegation,locUnfoldRoleSet,subBeginConcept,subEndConcept,transType); |
| 1415 |
////} |
| 1416 |
|
| 1417 |
//const QList<TRoleNegationPair>& recTravSubRoleList(recTravSubRoleChainDataItem.mRecTraversalSubRoleList); |
| 1418 |
//for (QList<TRoleNegationPair>::const_iterator it = recTravSubRoleList.constBegin(), itEnd = recTravSubRoleList.constEnd(); it != itEnd; ++it) { |
| 1419 |
// TRoleNegationPair recTravSubRoleNegPair(*it); |
| 1420 |
// CRole* recTravSubRole(recTravSubRoleNegPair.first); |
| 1421 |
// bool recTravSubRoleInversed(recTravSubRoleNegPair.second); |
| 1422 |
// if (recTravSubRoleInversed) { |
| 1423 |
// recTravSubRole = getInverseRole(recTravSubRole); |
| 1424 |
// } |
| 1425 |
// CConcept* recTravSubBeginConcept = createStateConcept(transType); |
| 1426 |
// CConcept* recTravSubEndConcept = createStateConcept(transType); |
| 1427 |
// appendTransitionOperandConceptLinker(subBeginConcept,createTransitionOperandConceptLinker(recTravSubBeginConcept,false)); |
| 1428 |
// appendTransitionOperandConceptLinker(recTravSubEndConcept,createTransitionOperandConceptLinker(subEndConcept,false)); |
| 1429 |
// CConcept* recTravPropCon = createTransitionConcept(recTravSubRole,transType); |
| 1430 |
// appendTransitionOperandConceptLinker(recTravSubBeginConcept,createTransitionOperandConceptLinker(recTravPropCon,false)); |
| 1431 |
// appendTransitionOperandConceptLinker(recTravPropCon,createTransitionOperandConceptLinker(recTravSubEndConcept,false)); |
| 1432 |
// generateRoleChainAutomatConcept(recTravSubRole,subRoleChainDataList,alreadyUnfoldRoleSet,recTravSubBeginConcept,recTravSubEndConcept,transType); |
| 1433 |
//} |
| 1434 |
|
| 1435 |
//// search fitting sub role chains |
| 1436 |
////bool hasFittingSubRole = false; |
| 1437 |
////QList<CRoleSubRoleChainData> subRoleChainDataList(mRoleSubRoleChainDataHash.values(subRole)); |
| 1438 |
////hasFittingSubRole = !subRoleChainDataList.isEmpty(); |
| 1439 |
////if (hasFittingSubRole) { |
| 1440 |
//// for (QList<CRoleSubRoleChainData>::const_iterator it = subRoleChainDataList.constBegin(), itEnd = subRoleChainDataList.constEnd(); it != itEnd; ++it) { |
| 1441 |
//// CRoleSubRoleChainData subRoleChainData(*it); |
| 1442 |
//// CRoleChain* subRoleChain = subRoleChainData.mRoleChain; |
| 1443 |
//// bool subRoleNegation = subRoleChainData.mInverse; |
| 1444 |
//// CRole* superRoleChain = subRoleChainData.mRole; |
| 1445 |
|
| 1446 |
//// QSet<CRole*> locUnfoldRoleSet(alreadyUnfoldRoleSet); |
| 1447 |
//// locUnfoldRoleSet.insert(subRole); |
| 1448 |
//// CSortedNegLinker<CRole*>* superSuperLinkerIt = superRoleChain->getIndirectSuperRoleList(); |
| 1449 |
//// while (superSuperLinkerIt) { |
| 1450 |
//// CRole* superSuperRole = superSuperLinkerIt->getData(); |
| 1451 |
//// locUnfoldRoleSet.insert(superSuperRole); |
| 1452 |
//// superSuperLinkerIt = superSuperLinkerIt->getNext(); |
| 1453 |
//// } |
| 1454 |
|
| 1455 |
//// generateRoleChainAutomatConcept(subRole,superRoleChain,subRoleChain,subRoleNegation,locUnfoldRoleSet,subBeginConcept,subEndConcept,transType); |
| 1456 |
//// } |
| 1457 |
////} |
| 1458 |
lastConcept = propCon; |
| 1459 |
} else { |
| 1460 |
// error, not allowed construct |
| 1461 |
bool bug = true; |
| 1462 |
} |
| 1463 |
|
| 1464 |
chainedRoleLinker = chainedRoleLinker->getNext(); |
| 1465 |
} |
| 1466 |
if (transStart && !transEnd) { |
| 1467 |
//if (lastRole != testRole) { |
| 1468 |
// CConcept* tmpEndConcept = createStateConcept(transType); |
| 1469 |
// appendTransitionOperandConceptLinker(tmpEndConcept,createTransitionOperandConceptLinker(endConcept,false)); |
| 1470 |
// endConcept = tmpEndConcept; |
| 1471 |
//} |
| 1472 |
appendTransitionOperandConceptLinker(endConcept,createTransitionOperandConceptLinker(connectBeginCon,false)); |
| 1473 |
appendTransitionOperandConceptLinker(connectEndCon,createTransitionOperandConceptLinker(endConcept,false)); |
| 1474 |
} else if (transEnd && !transStart) { |
| 1475 |
//if (lastRole != testRole) { |
| 1476 |
// CConcept* tmpBeginConcept = createStateConcept(transType); |
| 1477 |
// appendTransitionOperandConceptLinker(beginConcept,createTransitionOperandConceptLinker(tmpBeginConcept,false)); |
| 1478 |
// beginConcept = tmpBeginConcept; |
| 1479 |
//} |
| 1480 |
appendTransitionOperandConceptLinker(connectEndCon,createTransitionOperandConceptLinker(beginConcept,false)); |
| 1481 |
appendTransitionOperandConceptLinker(beginConcept,createTransitionOperandConceptLinker(connectBeginCon,false)); |
| 1482 |
} else if (transStart && transEnd && !firstConcept) { |
| 1483 |
//if (lastRole != testRole) { |
| 1484 |
// CConcept* tmpBeginConcept = createStateConcept(transType); |
| 1485 |
// appendTransitionOperandConceptLinker(beginConcept,createTransitionOperandConceptLinker(tmpBeginConcept,false)); |
| 1486 |
// beginConcept = tmpBeginConcept; |
| 1487 |
// CConcept* tmpEndConcept = createStateConcept(transType); |
| 1488 |
// appendTransitionOperandConceptLinker(tmpEndConcept,createTransitionOperandConceptLinker(endConcept,false)); |
| 1489 |
// endConcept = tmpEndConcept; |
| 1490 |
// CConcept* propCon = createTransitionConcept(testRole,transType); |
| 1491 |
// appendTransitionOperandConceptLinker(tmpBeginConcept,createTransitionOperandConceptLinker(propCon,false)); |
| 1492 |
// appendTransitionOperandConceptLinker(propCon,createTransitionOperandConceptLinker(tmpEndConcept,false)); |
| 1493 |
//} |
| 1494 |
appendTransitionOperandConceptLinker(endConcept,createTransitionOperandConceptLinker(beginConcept,false)); |
| 1495 |
} else if (!transStart && !transEnd) { |
| 1496 |
if (connectBeginCon && connectEndCon) { |
| 1497 |
appendTransitionOperandConceptLinker(beginConcept,createTransitionOperandConceptLinker(connectBeginCon,false)); |
| 1498 |
appendTransitionOperandConceptLinker(connectEndCon,createTransitionOperandConceptLinker(endConcept,false)); |
| 1499 |
} |
| 1500 |
} else { |
| 1501 |
// error, not allowed construct |
| 1502 |
} |
| 1503 |
|
| 1504 |
return true; |
| 1505 |
} |
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
CRole* CRoleChainAutomataTransformationPreProcess::getLocalizedRole(CRole* role) { |
| 1510 |
return getLocalizedRole(role->getRoleTag()); |
| 1511 |
} |
| 1512 |
|
| 1513 |
|
| 1514 |
CRole* CRoleChainAutomataTransformationPreProcess::getLocalizedRole(cint64 roleTag) { |
| 1515 |
CRole* role = mRoleVec->getData(roleTag); |
| 1516 |
if (!mRoleVec->hasLocalData(roleTag)) { |
| 1517 |
role = CConceptRoleIndividualLocator::getLocatedRole(role,mOntology); |
| 1518 |
} |
| 1519 |
return role; |
| 1520 |
} |
| 1521 |
|
| 1522 |
|
| 1523 |
}; // end namespace Preprocess |
| 1524 |
|
| 1525 |
}; // end namespace Reasoner |
| 1526 |
|
| 1527 |
}; // end namespace Konclude |