| 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_PARSER_COWL2QTXMLONTOLOGYPARSER_H |
| 22 |
#define KONCLUDE_PARSER_COWL2QTXMLONTOLOGYPARSER_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
#include <QDomDocument> |
| 26 |
#include <QDomElement> |
| 27 |
#include <QMap> |
| 28 |
|
| 29 |
// Namespace includes |
| 30 |
#include "COntologyQtXMLDocumentParser.h" |
| 31 |
#include "COntologyBuilder.h" |
| 32 |
#include "CParseRuleAtom.h" |
| 33 |
|
| 34 |
|
| 35 |
// Other includes |
| 36 |
#include "Control/Command/CCommandRecordRouter.h" |
| 37 |
#include "Control/Command/Records/CNotSupportedNodeErrorRecord.h" |
| 38 |
#include "Control/Command/Records/CUnspecifiedMessageErrorRecord.h" |
| 39 |
|
| 40 |
#include "Logger/CLogIdentifier.h" |
| 41 |
|
| 42 |
#include "Utilities/Container/CQtHash.h" |
| 43 |
|
| 44 |
|
| 45 |
// Logger includes |
| 46 |
#include "Logger/CLogger.h" |
| 47 |
|
| 48 |
using namespace Konclude::Logger; |
| 49 |
|
| 50 |
using namespace std; |
| 51 |
|
| 52 |
|
| 53 |
namespace Konclude { |
| 54 |
|
| 55 |
using namespace Utilities::Container; |
| 56 |
using namespace Control::Command; |
| 57 |
using namespace Control::Command::Records; |
| 58 |
|
| 59 |
namespace Parser { |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
#define KONCLUDE_PARSER_USEPARSEJUMPFUNCTIONHASH |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
/*! |
| 69 |
* |
| 70 |
* \class COWL2QtXMLOntologyParser |
| 71 |
* \author Andreas Steigmiller |
| 72 |
* \version 0.1 |
| 73 |
* \brief Parser for OWL/XML Files |
| 74 |
* |
| 75 |
*/ |
| 76 |
class COWL2QtXMLOntologyParser : public COntologyQtXMLDocumentParser, public CLogIdentifier { |
| 77 |
// public methods |
| 78 |
public: |
| 79 |
//! Constructor |
| 80 |
COWL2QtXMLOntologyParser(COntologyBuilder* ontoBuilder); |
| 81 |
COWL2QtXMLOntologyParser(COntologyBuilder* ontoBuilder, CCommandRecordRouter* commandRecordRouter); |
| 82 |
|
| 83 |
//! Destructor |
| 84 |
virtual ~COWL2QtXMLOntologyParser(); |
| 85 |
|
| 86 |
virtual bool parseOntologyFile(const QString& filename); |
| 87 |
virtual bool parseOntologyNode(QDomElement* ontologyNode); |
| 88 |
virtual bool parseTellOntologyAxiomNode(QDomElement* ontologyNode); |
| 89 |
virtual bool parseRetractOntologyAxiomNode(QDomElement* ontologyNode); |
| 90 |
|
| 91 |
virtual CBuildExpression* getParsedBuildNode(QDomElement* node); |
| 92 |
|
| 93 |
// protected methods |
| 94 |
protected: |
| 95 |
bool initializeParseFunctionJumpHash(); |
| 96 |
QString getEntityName(QDomElement* node); |
| 97 |
|
| 98 |
cint64 parseCardinality(QDomElement* node); |
| 99 |
|
| 100 |
CBuildExpression* parseBuildNode(QDomElement* node); |
| 101 |
QList<CBuildExpression* > parseChildNodes(QDomElement* node); |
| 102 |
|
| 103 |
CClassExpression* parseClassNode(QDomElement* node); |
| 104 |
CObjectPropertyExpression* parseObjectPropertyNode(QDomElement* node); |
| 105 |
CObjectIndividualVariableExpression* parseIndividualVariableNode(QDomElement* node); |
| 106 |
|
| 107 |
CDeclarationAxiomExpression* parseDeclarationNode(QDomElement* node); |
| 108 |
|
| 109 |
CEquivalentClassesExpression* parseEquivalentClassesNode(QDomElement* node); |
| 110 |
CSubClassOfExpression* parseSubClassOfNode(QDomElement* node); |
| 111 |
CDisjointClassesExpression* parseDisjontClassesNode(QDomElement* node); |
| 112 |
CDisjointUnionExpression* parseDisjontUnionNode(QDomElement* node); |
| 113 |
|
| 114 |
CSubObjectPropertyOfExpression* parseSubObjectPropertyOfNode(QDomElement* node); |
| 115 |
CObjectPropertyChainExpression* parseObjectPropertyChainNode(QDomElement* node); |
| 116 |
CEquivalentObjectPropertiesExpression* parseEquivalentObjectPropertiesNode(QDomElement* node); |
| 117 |
CDisjointObjectPropertiesExpression* parseDisjointObjectPropertiesNode(QDomElement* node); |
| 118 |
|
| 119 |
CObjectIntersectionOfExpression* parseObjectIntersectionOfNode(QDomElement* node); |
| 120 |
CObjectUnionOfExpression* parseObjectUnionOfNode(QDomElement* node); |
| 121 |
CObjectMaxCardinalityExpression* parseObjectMaxCardinalityNode(QDomElement* node); |
| 122 |
CObjectMinCardinalityExpression* parseObjectMinCardinalityNode(QDomElement* node); |
| 123 |
CObjectExactlyCardinalityExpression* parseObjectExactlyCardinalityNode(QDomElement* node); |
| 124 |
CObjectSomeValuesFromExpression* parseObjectSomeValuesFromNode(QDomElement* node); |
| 125 |
CObjectAllValuesFromExpression* parseObjectAllValuesFromNode(QDomElement* node); |
| 126 |
CObjectComplementOfExpression* parseObjectComplementOfNode(QDomElement* node); |
| 127 |
CObjectOneOfExpression* parseObjectOneOfNode(QDomElement* node); |
| 128 |
CObjectHasValueExpression* parseObjectHasValueNode(QDomElement* node); |
| 129 |
CObjectHasSelfExpression* parseObjectHasSelfNode(QDomElement* node); |
| 130 |
|
| 131 |
|
| 132 |
CClassAssertionExpression* parseClassAssertionNode(QDomElement* node); |
| 133 |
CNamedIndividualExpression* parseNamedIndividualNode(QDomElement* node); |
| 134 |
CAnonymousIndividualExpression* parseAnonymousIndividualNode(QDomElement* node); |
| 135 |
CObjectPropertyAssertionExpression* parseObjectPropertyAssertionNode(QDomElement* node); |
| 136 |
CNegativeObjectPropertyAssertionExpression* parseNegativeObjectPropertyAssertionNode(QDomElement* node); |
| 137 |
CSameIndividualExpression* parseSameIndividualNode(QDomElement* node); |
| 138 |
CDifferentIndividualsExpression* parseDifferentIndividualsNode(QDomElement* node); |
| 139 |
|
| 140 |
|
| 141 |
CObjectPropertyDomainExpression* parseObjectPropertyDomainNode(QDomElement* node); |
| 142 |
CObjectPropertyRangeExpression* parseObjectPropertyRangeNode(QDomElement* node); |
| 143 |
CInverseObjectPropertyOfExpression* parseInverseObjectPropertyOfNode(QDomElement* node); |
| 144 |
CInverseObjectPropertiesExpression* parseInverseObjectPropertiesNode(QDomElement* node); |
| 145 |
CTransetiveObjectPropertyExpression* parseTransetiveObjectPropertyNode(QDomElement* node); |
| 146 |
CFunctionalObjectPropertyExpression* parseFunctionalObjectPropertyNode(QDomElement* node); |
| 147 |
CSymmetricObjectPropertyExpression* parseSymmetricObjectPropertyNode(QDomElement* node); |
| 148 |
CAsymmetricObjectPropertyExpression* parseAsymmetricObjectPropertyNode(QDomElement* node); |
| 149 |
CReflexiveObjectPropertyExpression* parseReflexiveObjectPropertyNode(QDomElement* node); |
| 150 |
CIrreflexiveObjectPropertyExpression* parseIrreflexiveObjectPropertyNode(QDomElement* node); |
| 151 |
CInverseFunctionalObjectPropertyExpression* parseInverseFunctionalObjectPropertyNode(QDomElement* node); |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
QList<CBuildExpression*> parseRuleNode(QDomElement* node); |
| 156 |
QHash<QString,CParseRuleAtom*> createVariableAtomHash(const QList<CParseRuleAtom*>& atomList); |
| 157 |
QMap<cint64,QString> createVariableCountMap(const QList<CParseRuleAtom*>& atomList); |
| 158 |
CBuildExpression* createBodyExpresions(const QString& varString, QHash<QString,CParseRuleAtom*>& bodyVariableAtomHash, QHash<QString,CParseRuleAtom*>& headVariableAtomHash); |
| 159 |
|
| 160 |
bool hasBackExpressionLinks(const QString& varString, CParseRuleAtom* notRuleAtom, QHash<QString,CParseRuleAtom*>& bodyVariableAtomHash, QSet<QString>& processedVarSet, |
| 161 |
QSet<CParseRuleAtom*>& processedAtomSet, QHash<QString,CParseRuleAtom*>& headVariableAtomHash, QSet<QString>& backTestProcessedVarSet, QSet<CParseRuleAtom*>& backTestProcessedAtomSet); |
| 162 |
|
| 163 |
bool hasBackExpressionLinks(const QString& varString, CParseRuleAtom* notRuleAtom, QHash<QString,CParseRuleAtom*>& bodyVariableAtomHash, QSet<QString>& processedVarSet, |
| 164 |
QSet<CParseRuleAtom*>& processedAtomSet, QHash<QString,CParseRuleAtom*>& headVariableAtomHash); |
| 165 |
|
| 166 |
CBuildExpression* createBodyExpresions(const QString& varString, bool direct, QHash<QString,CParseRuleAtom*>& bodyVariableAtomHash, QSet<QString>& processedVarSet, QSet<CParseRuleAtom*>& processedAtomSet, QHash<QString,CParseRuleAtom*>& headVariableAtomHash); |
| 167 |
CBuildExpression* getNeighbourAtomObjectPropertyExpression(CParseRuleAtom* ruleAtom, bool inversed); |
| 168 |
|
| 169 |
QList<CParseRuleAtom*> parseRuleAtomNodes(const QString& ruleNodePrefix, const QDomElement& node); |
| 170 |
|
| 171 |
|
| 172 |
bool parsePrefixNode(QDomElement* node); |
| 173 |
|
| 174 |
|
| 175 |
CBuildExpression* jumpFunctionOntologyNode(QDomElement* node); |
| 176 |
|
| 177 |
CBuildExpression* jumpFunctionTellOntologyAxiomNode(QDomElement* node); |
| 178 |
CBuildExpression* jumpFunctionRetractOntologyAxiomNode(QDomElement* node); |
| 179 |
|
| 180 |
CBuildExpression* jumpFunctionParsePrefixNode(QDomElement* node); |
| 181 |
|
| 182 |
CBuildExpression* jumpFunctionParseClassNode(QDomElement* node); |
| 183 |
CBuildExpression* jumpFunctionParseObjectPropertyNode(QDomElement* node); |
| 184 |
CBuildExpression* jumpFunctionParseIndividualVariable(QDomElement* node); |
| 185 |
|
| 186 |
CBuildExpression* jumpFunctionParseDeclarationNode(QDomElement* node); |
| 187 |
|
| 188 |
CBuildExpression* jumpFunctionParseSubClassOfNode(QDomElement* node); |
| 189 |
CBuildExpression* jumpFunctionParseEquivalentClassesNode(QDomElement* node); |
| 190 |
CBuildExpression* jumpFunctionParseDisjontClassesNode(QDomElement* node); |
| 191 |
CBuildExpression* jumpFunctionParseDisjontUnionNode(QDomElement* node); |
| 192 |
|
| 193 |
CBuildExpression* jumpFunctionParseSubObjectPropertyOfNode(QDomElement* node); |
| 194 |
CBuildExpression* jumpFunctionParseObjectPropertyChainNode(QDomElement* node); |
| 195 |
CBuildExpression* jumpFunctionParseEquivalentObjectPropertiesNode(QDomElement* node); |
| 196 |
CBuildExpression* jumpFunctionParseDisjointObjectPropertiesNode(QDomElement* node); |
| 197 |
|
| 198 |
CBuildExpression* jumpFunctionParseObjectIntersectionOfNode(QDomElement* node); |
| 199 |
CBuildExpression* jumpFunctionParseObjectUnionOfNode(QDomElement* node); |
| 200 |
CBuildExpression* jumpFunctionParseObjectMaxCardinalityNode(QDomElement* node); |
| 201 |
CBuildExpression* jumpFunctionParseObjectMinCardinalityNode(QDomElement* node); |
| 202 |
CBuildExpression* jumpFunctionParseObjectExactlyCardinalityNode(QDomElement* node); |
| 203 |
CBuildExpression* jumpFunctionParseObjectSomeValuesFromNode(QDomElement* node); |
| 204 |
CBuildExpression* jumpFunctionParseObjectAllValuesFromNode(QDomElement* node); |
| 205 |
CBuildExpression* jumpFunctionParseObjectComplementOfNode(QDomElement* node); |
| 206 |
CBuildExpression* jumpFunctionParseObjectOneOfNode(QDomElement* node); |
| 207 |
CBuildExpression* jumpFunctionParseObjectHasValueNode(QDomElement* node); |
| 208 |
CBuildExpression* jumpFunctionParseObjectHasSelfNode(QDomElement* node); |
| 209 |
|
| 210 |
CBuildExpression* jumpFunctionParseClassAssertionNode(QDomElement* node); |
| 211 |
CBuildExpression* jumpFunctionParseNamedIndividualNode(QDomElement* node); |
| 212 |
CBuildExpression* jumpFunctionParseAnonymousIndividualNode(QDomElement* node); |
| 213 |
CBuildExpression* jumpFunctionParseObjectPropertyAssertionNode(QDomElement* node); |
| 214 |
CBuildExpression* jumpFunctionParseNegativeObjectPropertyAssertionNode(QDomElement* node); |
| 215 |
CBuildExpression* jumpFunctionParseSameIndividualNode(QDomElement* node); |
| 216 |
CBuildExpression* jumpFunctionParseDifferentIndividualsNode(QDomElement* node); |
| 217 |
|
| 218 |
CBuildExpression* jumpFunctionParseObjectPropertyDomainNode(QDomElement* node); |
| 219 |
CBuildExpression* jumpFunctionParseObjectPropertyRangeNode(QDomElement* node); |
| 220 |
CBuildExpression* jumpFunctionParseInverseObjectPropertyOfNode(QDomElement* node); |
| 221 |
CBuildExpression* jumpFunctionParseInverseObjectPropertiesNode(QDomElement* node); |
| 222 |
CBuildExpression* jumpFunctionParseTransetiveObjectPropertyNode(QDomElement* node); |
| 223 |
CBuildExpression* jumpFunctionParseFunctionalObjectPropertyNode(QDomElement* node); |
| 224 |
CBuildExpression* jumpFunctionParseSymmetricObjectPropertyNode(QDomElement* node); |
| 225 |
CBuildExpression* jumpFunctionParseAsymmetricObjectPropertyNode(QDomElement* node); |
| 226 |
CBuildExpression* jumpFunctionParseReflexiveObjectPropertyNode(QDomElement* node); |
| 227 |
CBuildExpression* jumpFunctionParseIrreflexiveObjectPropertyNode(QDomElement* node); |
| 228 |
CBuildExpression* jumpFunctionParseInverseFunctionalObjectPropertyNode(QDomElement* node); |
| 229 |
|
| 230 |
CBuildExpression* jumpFunctionParseIgnoredNode(QDomElement* node); |
| 231 |
CBuildExpression* jumpFunctionParseImportNode(QDomElement* node); |
| 232 |
|
| 233 |
|
| 234 |
CBuildExpression* jumpFunctionParseDatatypeNode(QDomElement* node); |
| 235 |
CBuildExpression* jumpFunctionParseDataPropertyNode(QDomElement* node); |
| 236 |
CBuildExpression* jumpFunctionParseDataSomeValuesFromNode(QDomElement* node); |
| 237 |
CBuildExpression* jumpFunctionParseDataLiteralNode(QDomElement* node); |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
CBuildExpression* jumpFunctionParseDataAllValuesFromNode(QDomElement* node); |
| 243 |
CBuildExpression* jumpFunctionParseDataHasValueNode(QDomElement* node); |
| 244 |
CBuildExpression* jumpFunctionParseDataIntersectionOfNode(QDomElement* node); |
| 245 |
CBuildExpression* jumpFunctionParseDataOneOfNode(QDomElement* node); |
| 246 |
CBuildExpression* jumpFunctionParseDataUnionOfNode(QDomElement* node); |
| 247 |
CBuildExpression* jumpFunctionParseDataComplementOfNode(QDomElement* node); |
| 248 |
CBuildExpression* jumpFunctionParseDatatypeRestrictionNode(QDomElement* node); |
| 249 |
CBuildExpression* jumpFunctionParseDataMaxCardinalityNode(QDomElement* node); |
| 250 |
CBuildExpression* jumpFunctionParseDataMinCardinalityNode(QDomElement* node); |
| 251 |
CBuildExpression* jumpFunctionParseDataExactCardinalityNode(QDomElement* node); |
| 252 |
|
| 253 |
CBuildExpression* jumpFunctionParseDataPropertyAssertionNode(QDomElement* node); |
| 254 |
CBuildExpression* jumpFunctionParseNegativeDataPropertyAssertionNode(QDomElement* node); |
| 255 |
|
| 256 |
CBuildExpression* jumpFunctionParseSubDataPropertyOfNode(QDomElement* node); |
| 257 |
CBuildExpression* jumpFunctionParseEquivalentDataPropertiesNode(QDomElement* node); |
| 258 |
CBuildExpression* jumpFunctionParseDisjointDataPropertiesNode(QDomElement* node); |
| 259 |
CBuildExpression* jumpFunctionParseDataPropertyDomainNode(QDomElement* node); |
| 260 |
CBuildExpression* jumpFunctionParseDataPropertyRangeNode(QDomElement* node); |
| 261 |
CBuildExpression* jumpFunctionParseFunctionalDataPropertyNode(QDomElement* node); |
| 262 |
|
| 263 |
CBuildExpression* jumpFunctionParseDataFacetRestrictionNode(QDomElement* node); |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
CDatatypeExpression* parseDatatypeNode(QDomElement* node); |
| 270 |
CDataPropertyExpression* parseDataPropertyNode(QDomElement* node); |
| 271 |
CDataSomeValuesFromExpression* parseDataSomeValuesFromNode(QDomElement* node); |
| 272 |
CDataLiteralExpression* parseDataLiteralNode(QDomElement* node); |
| 273 |
|
| 274 |
CDataFacetRestrictionExpression* parseDataFacetRestrictionNode(QDomElement* node); |
| 275 |
|
| 276 |
|
| 277 |
CDataAllValuesFromExpression* parseDataAllValuesFromNode(QDomElement* node); |
| 278 |
CDataHasValueExpression* parseDataHasValueNode(QDomElement* node); |
| 279 |
CDataIntersectionOfExpression* parseDataIntersectionOfNode(QDomElement* node); |
| 280 |
CDataOneOfExpression* parseDataOneOfNode(QDomElement* node); |
| 281 |
CDataUnionOfExpression* parseDataUnionOfNode(QDomElement* node); |
| 282 |
CDataComplementOfExpression* parseDataComplementOfNode(QDomElement* node); |
| 283 |
CDatatypeRestrictionExpression* parseDatatypeRestrictionNode(QDomElement* node); |
| 284 |
CDataMaxCardinalityExpression* parseDataMaxCardinalityNode(QDomElement* node); |
| 285 |
CDataMinCardinalityExpression* parseDataMinCardinalityNode(QDomElement* node); |
| 286 |
CDataExactCardinalityExpression* parseDataExactCardinalityNode(QDomElement* node); |
| 287 |
|
| 288 |
CDataPropertyAssertionExpression* parseDataPropertyAssertionNode(QDomElement* node); |
| 289 |
CNegativeDataPropertyAssertionExpression* parseNegativeDataPropertyAssertionNode(QDomElement* node); |
| 290 |
|
| 291 |
CSubDataPropertyOfExpression* parseSubDataPropertyOfNode(QDomElement* node); |
| 292 |
CEquivalentDataPropertiesExpression* parseEquivalentDataPropertiesNode(QDomElement* node); |
| 293 |
CDisjointDataPropertiesExpression* parseDisjointDataPropertiesNode(QDomElement* node); |
| 294 |
CDataPropertyDomainExpression* parseDataPropertyDomainNode(QDomElement* node); |
| 295 |
CDataPropertyRangeExpression* parseDataPropertyRangeNode(QDomElement* node); |
| 296 |
CFunctionalDataPropertyExpression* parseFunctionalDataPropertyNode(QDomElement* node); |
| 297 |
|
| 298 |
// protected variables |
| 299 |
protected: |
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
cint64 mReportErrorCount; |
| 304 |
|
| 305 |
|
| 306 |
CCommandRecordRouter recordRouter; |
| 307 |
COntologyBuilder* mOntoBuilder; |
| 308 |
QString mOntologyIdentifier; |
| 309 |
cint64 mAxiomNumber; |
| 310 |
|
| 311 |
typedef CBuildExpression* (COWL2QtXMLOntologyParser::*ParseFunction) (QDomElement* node); |
| 312 |
|
| 313 |
CQtHash<QString,ParseFunction> mParseFunctionJumpHash; |
| 314 |
|
| 315 |
|
| 316 |
// private methods |
| 317 |
private: |
| 318 |
|
| 319 |
|
| 320 |
// private variables |
| 321 |
private: |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
}; |
| 326 |
|
| 327 |
}; // end namespace Parser |
| 328 |
|
| 329 |
}; // end namespace Konclude |
| 330 |
|
| 331 |
#endif // KONCLUDE_PARSER_COWL2QTXMLONTOLOGYPARSER_H |