| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef KONCLUDE_REASONER_ANSWERER_COPTIMIZEDCOMPLEXVARIABLEABSTRACTNONDISCONNECTINGABSORPTIONBASEDQUERYPARTHANDLER_H |
| 22 |
#define KONCLUDE_REASONER_ANSWERER_COPTIMIZEDCOMPLEXVARIABLEABSTRACTNONDISCONNECTINGABSORPTIONBASEDQUERYPARTHANDLER_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
|
| 26 |
|
| 27 |
// Namespace includes |
| 28 |
#include "AnswererSettings.h" |
| 29 |
#include "COptimizedComplexVariableAbsorptionBasedHandlingNeighbouringData.h" |
| 30 |
#include "COptimizedComplexVariableAbsorptionBasedHandlingQueryPartData.h" |
| 31 |
#include "COptimizedComplexExpressionOntologyAnsweringItem.h" |
| 32 |
#include "COptimizedComplexVariableAbstractAbsorptionBasedQueryPartHandler.h" |
| 33 |
|
| 34 |
|
| 35 |
// Other includes |
| 36 |
#include "Parser/Expressions/CExpressionVariable.h" |
| 37 |
#include "Parser/Expressions/CObjectPropertyTermExpression.h" |
| 38 |
#include "Parser/Expressions/CClassAssertionExpression.h" |
| 39 |
|
| 40 |
#include "Reasoner/Kernel/Cache/COccurrenceStatisticsCacheReader.h" |
| 41 |
|
| 42 |
// Logger includes |
| 43 |
#include "Logger/CLogger.h" |
| 44 |
|
| 45 |
|
| 46 |
namespace Konclude { |
| 47 |
|
| 48 |
using namespace Parser::Expression; |
| 49 |
|
| 50 |
namespace Reasoner { |
| 51 |
|
| 52 |
using namespace Kernel::Cache; |
| 53 |
|
| 54 |
namespace Answerer { |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
typedef QPair<CObjectPropertyAssertionExpression*, double> TObjectPropertyOccurrenceScoreSortingItem; |
| 59 |
typedef QPair<CExpressionVariable*, double> TVariableTermsOccurrenceScoreSortingItem; |
| 60 |
|
| 61 |
|
| 62 |
/*! |
| 63 |
* |
| 64 |
* \class COptimizedComplexVariableAbstractNonDisconnectingAbsorptionBasedQueryPartHandler |
| 65 |
* \author Andreas Steigmiller |
| 66 |
* \version 0.1 |
| 67 |
* \brief TODO |
| 68 |
* |
| 69 |
*/ |
| 70 |
class COptimizedComplexVariableAbstractNonDisconnectingAbsorptionBasedQueryPartHandler : public COptimizedComplexVariableAbstractAbsorptionBasedQueryPartHandler { |
| 71 |
// public methods |
| 72 |
public: |
| 73 |
//! Constructor |
| 74 |
COptimizedComplexVariableAbstractNonDisconnectingAbsorptionBasedQueryPartHandler(COptimizedComplexVariableAbsorptionBasedHandlingQueryPartData* queryPart, COptimizedComplexExpressionOntologyAnsweringItem* ontoAnsweringItem, COccurrenceStatisticsCacheReader* occStatsCacheReader); |
| 75 |
|
| 76 |
COptimizedComplexVariableAbstractNonDisconnectingAbsorptionBasedQueryPartHandler* absorbQueryPart(); |
| 77 |
|
| 78 |
COptimizedComplexVariableAbstractNonDisconnectingAbsorptionBasedQueryPartHandler* readConfig(CCalculationConfigurationExtension* config); |
| 79 |
|
| 80 |
// protected methods |
| 81 |
protected: |
| 82 |
virtual CExpressionVariable* findNextAbsorptionVariable(CExpressionVariable* currentVariable, QList<CExpressionVariable*>& absorbedPropagatedVariables, QList<CObjectPropertyAssertionExpression*>& objectPropertyPath); |
| 83 |
virtual bool checkVariableCompletelyHandled(CExpressionVariable* currentVariable); |
| 84 |
|
| 85 |
virtual CExpressionVariable* absorbStraightObjectPropertyAssertionPath(CExpressionVariable* currentVariable, CObjectPropertyAssertionExpression* startingProperty); |
| 86 |
virtual CExpressionVariable* absorbObjectPropertyAssertion(CExpressionVariable* currentVariable, CObjectPropertyAssertionExpression* startingProperty); |
| 87 |
|
| 88 |
|
| 89 |
virtual CExpressionVariable* propagateAbsorptionOverObjectPropertyAssertionPath(CExpressionVariable* currentVariable, const QList<CObjectPropertyAssertionExpression*>& objectPropertyPath); |
| 90 |
virtual CExpressionVariable* propagateAbsorptionOverObjectPropertyAssertion(CExpressionVariable* currentVariable, CObjectPropertyAssertionExpression* objectProperty) = 0; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
virtual QList<CExpressionVariable*> getAbsorptionVariableList(); |
| 96 |
|
| 97 |
virtual COptimizedComplexVariableAbstractNonDisconnectingAbsorptionBasedQueryPartHandler* handleCurrentVariableSwitch(CExpressionVariable* newCurrentVariable) = 0; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
virtual CVariable* getPropagationVariableForVariableExpression(CExpressionVariable* expVar); |
| 103 |
|
| 104 |
|
| 105 |
QList<CObjectPropertyAssertionExpression*> getOrderedObjectPropertyAbsorptionList(CExpressionVariable* currentVariable, QList<CObjectPropertyAssertionExpression*> objectPropertyList, double* totalOccScore = nullptr); |
| 106 |
QList<CExpressionVariable*> getOrderedVariableAbsorptionList(QList<CExpressionVariable*> varExpList); |
| 107 |
virtual QList<CExpressionVariable*> getFilteredOrderedVariableAbsorptionList(QList<CExpressionVariable*> varExpList); |
| 108 |
|
| 109 |
CConcept* createNewConcept(); |
| 110 |
|
| 111 |
// protected variables |
| 112 |
protected: |
| 113 |
|
| 114 |
CConcreteOntology* mOntology; |
| 115 |
COccurrenceStatisticsCacheReader* mOccStatsCacheReader; |
| 116 |
|
| 117 |
bool mConfOccurrenceStatisticsBasedAbsorptionOrder; |
| 118 |
bool mConfOccurrenceStatisticsCollection; |
| 119 |
bool mConfPrioritizePrepareVariables; |
| 120 |
|
| 121 |
// private methods |
| 122 |
private: |
| 123 |
|
| 124 |
// private variables |
| 125 |
private: |
| 126 |
|
| 127 |
}; |
| 128 |
|
| 129 |
}; // end namespace Answerer |
| 130 |
|
| 131 |
}; // end namespace Reasoner |
| 132 |
|
| 133 |
}; // end namespace Konclude |
| 134 |
|
| 135 |
#endif // KONCLUDE_REASONER_ANSWERER_COPTIMIZEDCOMPLEXVARIABLEABSTRACTNONDISCONNECTINGABSORPTIONBASEDQUERYPARTHANDLER_H |