| 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_CRDFSIMPLETURTLEPARSER_H |
| 22 |
#define KONCLUDE_PARSER_CRDFSIMPLETURTLEPARSER_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
|
| 26 |
|
| 27 |
// Namespace includes |
| 28 |
#include "CParsingUtilities.h" |
| 29 |
|
| 30 |
|
| 31 |
// Other includes |
| 32 |
#include "Utilities/UtilitiesSettings.h" |
| 33 |
|
| 34 |
|
| 35 |
// Logger includes |
| 36 |
#include "Logger/CLogger.h" |
| 37 |
|
| 38 |
using namespace Konclude::Logger; |
| 39 |
|
| 40 |
|
| 41 |
namespace Konclude { |
| 42 |
|
| 43 |
using namespace Utilities; |
| 44 |
|
| 45 |
namespace Parser { |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
class CRDFStringTriple { |
| 50 |
public: |
| 51 |
QString string[3]; |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
class CRDFHahsedSubjectData { |
| 56 |
public: |
| 57 |
QString string[2]; |
| 58 |
CRDFHahsedSubjectData(CRDFStringTriple& rdfStringTriple) { |
| 59 |
string[0] = rdfStringTriple.string[1]; |
| 60 |
string[1] = rdfStringTriple.string[2]; |
| 61 |
} |
| 62 |
}; |
| 63 |
|
| 64 |
/*! |
| 65 |
* |
| 66 |
* \class CRDFSimpleTurtleParser |
| 67 |
* \author Andreas Steigmiller |
| 68 |
* \version 0.1 |
| 69 |
* \brief TODO |
| 70 |
* |
| 71 |
*/ |
| 72 |
class CRDFSimpleTurtleParser { |
| 73 |
// public methods |
| 74 |
public: |
| 75 |
//! Constructor |
| 76 |
CRDFSimpleTurtleParser(); |
| 77 |
|
| 78 |
//! Destructor |
| 79 |
virtual ~CRDFSimpleTurtleParser(); |
| 80 |
|
| 81 |
|
| 82 |
// protected methods |
| 83 |
protected: |
| 84 |
QString getNextPart(const QString& text, cint64& pos); |
| 85 |
QString getIRI(const QString& iriString); |
| 86 |
QString getBlankNode(const QString& blankNodeString); |
| 87 |
|
| 88 |
QString getNextAnonymousNode(); |
| 89 |
|
| 90 |
QList<CRDFStringTriple>* getRDFStringTriples(QStringList& partList); |
| 91 |
QHash<QString, CRDFHahsedSubjectData>* getRDFSubjectHash(QStringList& partList); |
| 92 |
|
| 93 |
QStringList getBracketContent(QStringList& partList, QChar openingBracket, QChar closingBracket, bool bracketOpened = false, bool includeOthers = false); |
| 94 |
|
| 95 |
bool getNextRDFStringTriple(QStringList& partList, CRDFStringTriple& lastNextTriple, QList<CRDFStringTriple>& nextTripleList, int startingSopPos = 0); |
| 96 |
|
| 97 |
QPair<QString,QString> extractDataLiteral(const QString& string); |
| 98 |
|
| 99 |
|
| 100 |
// protected variables |
| 101 |
protected: |
| 102 |
QString mBaseIRI; |
| 103 |
QHash<QString, QString> mPrefixHash; |
| 104 |
cint64 nextAnonymousNodeId; |
| 105 |
|
| 106 |
bool mParsingError = false; |
| 107 |
QString mLastParsingError; |
| 108 |
|
| 109 |
|
| 110 |
CParsingUtilities mParsingUtilities; |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
// private methods |
| 115 |
private: |
| 116 |
|
| 117 |
|
| 118 |
// private variables |
| 119 |
private: |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
}; |
| 124 |
|
| 125 |
}; // end namespace Parser |
| 126 |
|
| 127 |
}; // end namespace Konclude |
| 128 |
|
| 129 |
#endif // KONCLUDE_PARSER_CRDFSIMPLETURTLEPARSER_H |