Debian Codegraph @

Source/Reasoner/Triples/CRedlandStoredTriplesIndividualAssertionConvertionIndexer.h

raw
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 #ifdef KONCLUDE_REDLAND_INTEGRATION
21
22 #ifndef KONCLUDE_REASONER_GENERATOR_CREDLANDSTOREDTRIPLESINDIVIDUALASSERTIONCONVERTIONINDEXER_H
23 #define KONCLUDE_REASONER_GENERATOR_CREDLANDSTOREDTRIPLESINDIVIDUALASSERTIONCONVERTIONINDEXER_H
24
25
26 // Libraries includes
27 #include <QHash>
28 #include <QCache>
29
30
31 // Namespace includes
32 #include "TriplesSettings.h"
33 #include "CRedlandNodeHasher.h"
34 #include "CRedlandStoredTriplesData.h"
35 #include "CRedlandStoredTriplesIndividualAssertionIndexCache.h"
36 #include "CRedlandStoredTriplesSimpleABoxAssertionsAccessor.h"
37
38
39 // Other includes
40 #include "Reasoner/Ontology/CConcreteOntology.h"
41 #include "Reasoner/Ontology/CIndividualProcessData.h"
42
43 #include "Reasoner/Preprocess/CDataLiteralNormalizerPreProcess.h"
44 #include "Reasoner/Preprocess/CPreProcessContextBase.h"
45 #include "Reasoner/Preprocess/CPreProcessContext.h"
46
47 #include "Utilities/Container/CLinker.h"
48
49
50 // Logger includes
51 #include "Logger/CLogger.h"
52
53
54
55
56
57 namespace Konclude {
58
59 using namespace Utilities;
60 using namespace Utilities::Memory;
61 using namespace Utilities::Container;
62
63 namespace Reasoner {
64
65 using namespace Ontology;
66 using namespace Preprocess;
67
68 namespace Triples {
69
70
71 /*!
72 *
73 * \class CRedlandStoredTriplesIndividualAssertionConvertionIndexer
74 * \author Andreas Steigmiller
75 * \version 0.1
76 * \brief TODO
77 *
78 */
79 class CRedlandStoredTriplesIndividualAssertionConvertionIndexer {
80 // public methods
81 public:
82 CRedlandStoredTriplesIndividualAssertionConvertionIndexer();
83 virtual ~CRedlandStoredTriplesIndividualAssertionConvertionIndexer();
84
85
86 virtual bool indexABoxIndividuals(CConcreteOntology* updateConcreteOntology, COntologyTriplesData* ontologyTripleData);
87
88
89
90
91
92
93 // protected functions
94 protected:
95
96 class CIndividualNodeData {
97 public:
98 CIndividualNodeData(librdf_node* individualNode, CIndividual* individual) {
99 mIndividual = individual;
100 mIndividualNode = individualNode;
101 }
102
103 librdf_node* mIndividualNode;
104 CIndividual* mIndividual;
105 };
106
107 CIndividualNodeData* getIndividualData(librdf_node* subjectNode, CIndividualNodeData*& lastIndiData, librdf_node*& lastSubjectNode, CConcreteOntology* ontology);
108 CIndividualNodeData* getIndividualData(librdf_node* nodeNode, CConcreteOntology* ontology);
109
110 CDatatype* getDatatypeFromDatatypeUri(librdf_uri* uri, CConcreteOntology* ontology, CRedlandStoredTriplesData* ontologyTripleData);
111
112 void ensureDatatypeHashInitialized(CConcreteOntology* ontology, CRedlandStoredTriplesData* ontologyTripleData);
113
114 CDataLiteralValue* createDataLiteralValue(CDataLiteral* dataLiteral, CConcreteOntology* ontology);
115
116 void identifyIndividuals(librdf_statement* statement, librdf_node* rdfTypePredicate, librdf_node* namedIndividualObject, CIndividualNodeData* &lastIndiData, librdf_node* lastSubjectNode, CConcreteOntology* updateConcreteOntology, CRedlandStoredTriplesData* redlandTriplesData);
117
118 virtual void indexTriples(CRedlandStoredTriplesData* redlandTriplesData, librdf_node* rdfTypePredicate, librdf_node* namedIndividualObject, CConcreteOntology* updateConcreteOntology);
119
120 // protected variables
121 protected:
122
123
124 class CRoleNodeData {
125 public:
126 CRoleNodeData(librdf_node* roleNode, CRole* role, bool dataRole) {
127 mRole = role;
128 mDataRole = dataRole;
129 mRoleNode = roleNode;
130 }
131
132 librdf_node* mRoleNode;
133 CRole* mRole;
134 bool mDataRole;
135 };
136
137
138 class CConceptNodeData {
139 public:
140 CConceptNodeData(librdf_node* conceptNode, CConcept* concept) {
141 mConcept = concept;
142 mConceptNode = conceptNode;
143 }
144
145 librdf_node* mConceptNode;
146 CConcept* mConcept;
147 };
148
149
150 QHash<CRedlandNodeHasher, CRoleNodeData*> mRoleNodeDataHash;
151 QHash<CRedlandNodeHasher, CConceptNodeData*> mConceptNodeDataHash;
152 QHash<CRedlandNodeHasher, CIndividualNodeData*> mIndividualNodeDataHash;
153
154 cint64 mNextIndiId;
155 CMemoryAllocationManager* mMemMan;
156
157 QHash<CRedlandUriHasher, CDatatype*> mDatatypeIriDatatypeHash;
158 bool mDatatypeHashInitialized = false;
159 QString mAnonymousOntologyIdentifier;
160
161 CDatatype* mDefaultDatatype;
162 CDataLiteralNormalizerPreProcess mDataLiteralNormalizer;
163 CPreProcessContext* mPreprocessContext;
164 CConcreteOntology* mUupdatingOntology;
165
166 cint64 mConceptAssertionCount = 0;
167 cint64 mObjectPropertyAssertionCount = 0;
168 cint64 mDataPropertyAssertionCount = 0;
169
170 QTime mIndexingTime;
171 };
172
173
174
175
176
177 }; // end namespace Triples
178
179 }; // end namespace Reasoner
180
181 }; // end namespace Konclude
182
183 #endif // end KONCLUDE_REASONER_GENERATOR_CREDLANDSTOREDTRIPLESINDIVIDUALASSERTIONCONVERTIONINDEXER_H
184
185 #endif // !KONCLUDE_REDLAND_INTEGRATION