| 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 "CIsPropertySatisfiableQuery.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Query { |
| 29 |
|
| 30 |
|
| 31 |
CIsPropertySatisfiableQuery::CIsPropertySatisfiableQuery(CConcreteOntology* ontology, CConfigurationBase* configuration, CRole* role, const QString& propertyName, bool dataProperty, const QString& queryName) |
| 32 |
: CObjectDataPropertyClassificationPremisingQuery(ontology,configuration,dataProperty) { |
| 33 |
|
| 34 |
mPropertyName = propertyName; |
| 35 |
mRole = role; |
| 36 |
mQueryName = queryName; |
| 37 |
if (mQueryName.isEmpty()) { |
| 38 |
mQueryString = QString("Is property %1 satisfiable").arg(mPropertyName); |
| 39 |
} |
| 40 |
mResult = nullptr; |
| 41 |
|
| 42 |
mUseAbbreviatedIRIs = CConfigDataReader::readConfigBoolean(configuration,"Konclude.OWLlink.AbbreviatedIRIs",false); |
| 43 |
|
| 44 |
mClassificationCalcError = false; |
| 45 |
mQueryConstructError = false; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
CIsPropertySatisfiableQuery::~CIsPropertySatisfiableQuery() { |
| 50 |
delete mResult; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
CQueryResult* CIsPropertySatisfiableQuery::getQueryResult() { |
| 55 |
return mResult; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
CQueryResult *CIsPropertySatisfiableQuery::constructResult(CClassification* classification) { |
| 60 |
CPropertyRoleClassification* roleClassification = nullptr; |
| 61 |
if (isDataPropertyQuery()) { |
| 62 |
roleClassification = classification->getDataPropertyRoleClassification(); |
| 63 |
} else { |
| 64 |
roleClassification = classification->getObjectPropertyRoleClassification(); |
| 65 |
} |
| 66 |
if (roleClassification) { |
| 67 |
return constructPropertySynsetsResult(roleClassification->getRolePropertiesHierarchy()); |
| 68 |
} |
| 69 |
return nullptr; |
| 70 |
} |
| 71 |
|
| 72 |
CBooleanQueryResult *CIsPropertySatisfiableQuery::constructPropertySynsetsResult(CRolePropertiesHierarchy *hierarchy) { |
| 73 |
if (mResult) { |
| 74 |
delete mResult; |
| 75 |
mResult = 0; |
| 76 |
} |
| 77 |
if (hierarchy) { |
| 78 |
CRolePropertiesHierarchyNode* bottomNode = hierarchy->getBottomHierarchyNode(); |
| 79 |
CRolePropertiesHierarchyNode* node = hierarchy->getHierarchyNode(mRole); |
| 80 |
mResult = new CBooleanQueryResult(bottomNode != node); |
| 81 |
} |
| 82 |
return mResult; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
QString CIsPropertySatisfiableQuery::getQueryName() { |
| 87 |
return mQueryName; |
| 88 |
} |
| 89 |
|
| 90 |
QString CIsPropertySatisfiableQuery::getQueryString() { |
| 91 |
return mQueryString; |
| 92 |
} |
| 93 |
|
| 94 |
bool CIsPropertySatisfiableQuery::hasAnswer() { |
| 95 |
return mResult != 0; |
| 96 |
} |
| 97 |
|
| 98 |
QString CIsPropertySatisfiableQuery::getAnswerString() { |
| 99 |
if (!mResult) { |
| 100 |
return QString("Unknown"); |
| 101 |
} else { |
| 102 |
return mResult->getQueryResultString(); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
bool CIsPropertySatisfiableQuery::hasError() { |
| 107 |
return mClassificationCalcError || mQueryConstructError || CQuery::hasError(); |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
}; // end namespace Query |
| 112 |
|
| 113 |
}; // end namespace Reasoner |
| 114 |
|
| 115 |
}; // end namespace Konclude |