Debian Codegraph @

Kernel/DLConceptTaxonomy.cpp

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester
3 Copyright (C) 2015-2017 Dmitry Tsarkov
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 /*******************************************************\
21 |* Implementation of taxonomy building for the FaCT++ *|
22 \*******************************************************/
23
24 #include <queue>
25 #include <iostream>
26 #include <fstream>
27
28 #include "Reasoner.h"cxx . . $ `<file>/Kernel/Reasoner.h`/
29 #include "DLConceptTaxonomy.h"cxx . . $ `<file>/Kernel/DLConceptTaxonomy.h`/
30 #include "globaldef.h"cxx . . $ `<file>/Kernel/globaldef.h`/
31 #include "logging.h"cxx . . $ `<file>/Kernel/logging.h`/
32
33 /********************************************************\
34 |* Implementation of class Taxonomy *|
35 \********************************************************/
36
37 bool DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: testSubcxx . . $ DLConceptTaxonomy#testSub(7e9f35c32394b4f5). ( const TConceptcxx . . $ TConcept#* p, const TConceptcxx . . $ TConcept#* q )
38 {
39 fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( p != nullptr );
40 fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( q != nullptr );
41
42 // std::cout << "Testing sub " << p->getName() << " [= " << q->getName() << std::endl;
43 if ( q->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() // singleton on the RHS is useless iff...
44 && q->isPrimitivecxx . . $ TConcept#isPrimitive(50ce9a9e25b4a850).() // it is primitive
45 && !q->isNominalcxx . . $ TConcept#isNominal(50ce9a9e25b4a850).() ) // nominals should be classified as usual concepts
46 return false;
47
48 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llTaxTryingcxx . . $ llTaxTrying.) )
49 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nTAX: trying '" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). p->getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "' [= '" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). q->getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'... ";
50
51 if ( tBoxcxx . . $ DLConceptTaxonomy#tBox..testSortedNonSubsumptioncxx . . $ TBox#testSortedNonSubsumption(7e9f35c32394b4f5). ( p, q ) )
52 {
53 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llTaxTryingcxx . . $ llTaxTrying.) )
54 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NOT holds (sorted result)";
55
56 ++nSortedNegativecxx . . $ DLConceptTaxonomy#nSortedNegative.;
57 return false;
58 }
59
60 if ( isNotInModulecxx . . $ DLConceptTaxonomy#isNotInModule(d552066cd41c9e94).(q->getEntitycxx . . $ TNamedEntry#getEntity(1a59bfca6295ee56).()) )
61 {
62 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llTaxTryingcxx . . $ llTaxTrying.) )
63 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NOT holds (module result)";
64
65 ++nModuleNegativecxx . . $ DLConceptTaxonomy#nModuleNegative.;
66 return false;
67 }
68
69 switch ( tBoxcxx . . $ DLConceptTaxonomy#tBox..testCachedNonSubsumptioncxx . . $ TBox#testCachedNonSubsumption(88faddbc21e41e4b). ( p, q ) )
70 {
71 case csValidcxx . . $ csValid.: // cached result: satisfiable => non-subsumption
72 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llTaxTryingcxx . . $ llTaxTrying.) )
73 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NOT holds (cached result)";
74
75 ++nCachedNegativecxx . . $ DLConceptTaxonomy#nCachedNegative.;
76 return false;
77
78 case csInvalidcxx . . $ csInvalid.: // cached result: unsatisfiable => subsumption holds
79 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llTaxTryingcxx . . $ llTaxTrying.) )
80 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "holds (cached result)";
81
82 ++nCachedPositivecxx . . $ DLConceptTaxonomy#nCachedPositive.;
83 return true;
84
85 default: // need extra tests
86 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llTaxTryingcxx . . $ llTaxTrying.) )
87 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "wasted cache test";
88
89 break;
90 }
91
92 return testSubTBoxcxx . . $ DLConceptTaxonomy#testSubTBox(7e9f35c32394b4f5). ( p, q );
93 }
94
95 bool
96 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: isNotInModulecxx . . $ DLConceptTaxonomy#isNotInModule(d552066cd41c9e94). ( const TNamedEntitycxx . . $ TNamedEntity#* entity ) const
97 {
98 if ( upDirectioncxx . . $ TaxonomyCreator#upDirection. ) // bottom-up phase
99 return false;
100 const TSignaturecxx . . $ TSignature#* sig = sigStackcxx . . $ TaxonomyCreator#sigStack..topcxx . . $ SearchableStack#top(535908e0c00a99ac).();
101 if ( sig && entity && !sig->containscxx . . $ TSignature#contains(d552066cd41c9e94).(entity) )
102 return true;
103 return false;
104 }
105
106 TaxonomyCreatorcxx . . $ TaxonomyCreator#::KnownSubsumerscxx . . $ TaxonomyCreator#KnownSubsumers#*
107 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: buildKnownSubsumerscxx . . $ DLConceptTaxonomy#buildKnownSubsumers(29a29a73a651901d). ( ClassifiableEntrycxx . . $ ClassifiableEntry#* ce )
108 {
109 return TaxonomyCreatorcxx . . $ TaxonomyCreator#::buildKnownSubsumerscxx . . $ TaxonomyCreator#buildKnownSubsumers(29a29a73a651901d).(ce);
110 }
111
112 /// prepare signature for given entry
113 const TSignaturecxx . . $ TSignature#*
114 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: buildSignaturecxx . . $ DLConceptTaxonomy#buildSignature(883ea8d29581efad). ( ClassifiableEntrycxx . . $ ClassifiableEntry#* p )
115 {
116 if ( tBoxcxx . . $ DLConceptTaxonomy#tBox..pName2Sigcxx . . $ TBox#pName2Sig. == nullptr )
117 return nullptr;
118 if ( p->getEntitycxx . . $ TNamedEntry#getEntity(1a59bfca6295ee56).() == nullptr )
119 return nullptr;
120 TBoxcxx . . $ TBox#::NameSigMapcxx . . $ TBox#NameSigMap#::iteratorcxx . . $ std/map#iterator# found = tBoxcxx . . $ DLConceptTaxonomy#tBox..pName2Sigcxx . . $ TBox#pName2Sig.->findcxx . . $ std/map#find(36f8d56706583706).(p->getEntitycxx . . $ TNamedEntry#getEntity(1a59bfca6295ee56).());
121 if ( found ==cxx . . $ std/`operator==`(84f83906d8995b82). tBoxcxx . . $ DLConceptTaxonomy#tBox..pName2Sigcxx . . $ TBox#pName2Sig.->endcxx . . $ std/map#end(fbe2f8c57595edf).() )
122 return nullptr;
123 return found->cxx . . $ std/_Rb_tree_iterator#`operator->`(5a2a78a048fb49a8).secondcxx . . $ std/pair#second.;
124 }
125
126 void DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: printcxx . . $ DLConceptTaxonomy#print(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const
127 {
128 o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Totally " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nTriescxx . . $ DLConceptTaxonomy#nTries. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " subsumption tests was made\nAmong them ";
129
130 unsigned long n = ( nTriescxx . . $ DLConceptTaxonomy#nTries. ? nTriescxx . . $ DLConceptTaxonomy#nTries. : 1 );
131
132 o <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nPositivescxx . . $ DLConceptTaxonomy#nPositives. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " (" <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nPositivescxx . . $ DLConceptTaxonomy#nPositives.*100/n <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "%) successful\n";
133 o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Besides that " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nCachedPositivecxx . . $ DLConceptTaxonomy#nCachedPositive. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " successful and " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nCachedNegativecxx . . $ DLConceptTaxonomy#nCachedNegative.
134 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " unsuccessful subsumption tests were cached\n";
135 if ( nSortedNegativecxx . . $ DLConceptTaxonomy#nSortedNegative. )
136 o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Sorted reasoning deals with " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nSortedNegativecxx . . $ DLConceptTaxonomy#nSortedNegative. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " non-subsumptions\n";
137 if ( nModuleNegativecxx . . $ DLConceptTaxonomy#nModuleNegative. )
138 o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Modular reasoning deals with " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nModuleNegativecxx . . $ DLConceptTaxonomy#nModuleNegative. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " non-subsumptions\n";
139 o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "There were made " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nSearchCallscxx . . $ DLConceptTaxonomy#nSearchCalls. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " search calls\nThere were made " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nSubCallscxx . . $ DLConceptTaxonomy#nSubCalls.
140 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Sub calls, of which " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nNonTrivialSubCallscxx . . $ DLConceptTaxonomy#nNonTrivialSubCalls. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " non-trivial\n";
141 o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Current efficiency (wrt Brute-force) is " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). nEntriescxx . . $ TaxonomyCreator#nEntries.*(nEntriescxx . . $ TaxonomyCreator#nEntries.-1)/n <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n";
142
143 TaxonomyCreatorcxx . . $ TaxonomyCreator#::printcxx . . $ TaxonomyCreator#print(490063bd7e6d8d5d).(o);
144 }
145
146 // Baader procedures
147 void
148 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: searchBaadercxx . . $ DLConceptTaxonomy#searchBaader(ea5ea6ad7488bb8a). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* cur )
149 {
150 // label 'visited'
151 pTaxcxx . . $ TaxonomyCreator#pTax.->setVisitedcxx . . $ Taxonomy#setVisited(1e85185f4f4810e2).(cur);
152
153 ++nSearchCallscxx . . $ DLConceptTaxonomy#nSearchCalls.;
154 bool noPosSucc = true;
155
156 // check if there are positive successors; use DFS on them.
157 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = cur->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(upDirectioncxx . . $ TaxonomyCreator#upDirection.), p_end = cur->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(upDirectioncxx . . $ TaxonomyCreator#upDirection.); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
158 if ( enhancedSubscxx . . $ DLConceptTaxonomy#enhancedSubs(50effb95a029e9ba).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p) )
159 {
160 if ( !pTaxcxx . . $ TaxonomyCreator#pTax.->isVisitedcxx . . $ Taxonomy#isVisited(5273acd5b7b596a5).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p) )
161 searchBaadercxx . . $ DLConceptTaxonomy#searchBaader(ea5ea6ad7488bb8a).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
162
163 noPosSucc = false;
164 }
165
166 // in case current node is unchecked (no BOTTOM node) -- check it explicitly
167 if ( !isValuedcxx . . $ TaxonomyCreator#isValued(5273acd5b7b596a5).(cur) )
168 setValuecxx . . $ TaxonomyCreator#setValue(2266beb367975663). ( cur, testSubsumptioncxx . . $ DLConceptTaxonomy#testSubsumption(50effb95a029e9ba).(cur) );
169
170 // mark labelled leaf node as a parent (self check for incremental)
171 if ( noPosSucc && cur->getValuecxx . . $ TaxonomyVertex#getValue(50ce9a9e25b4a850).() && cur != pTaxcxx . . $ TaxonomyCreator#pTax.->getCurrentcxx . . $ Taxonomy#getCurrent(e005a88f538258f6).() )
172 pTaxcxx . . $ TaxonomyCreator#pTax.->getCurrentcxx . . $ Taxonomy#getCurrent(e005a88f538258f6).()->addNeighbourcxx . . $ TaxonomyVertex#addNeighbour(93beaa2f49a74c7). ( !upDirectioncxx . . $ TaxonomyCreator#upDirection., cur );
173 }
174
175 bool
176 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: enhancedSubs1cxx . . $ DLConceptTaxonomy#enhancedSubs1(50effb95a029e9ba). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* cur )
177 {
178 ++nNonTrivialSubCallscxx . . $ DLConceptTaxonomy#nNonTrivialSubCalls.;
179
180 // need to be valued -- check all parents
181 // propagate false
182 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = cur->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(!upDirectioncxx . . $ TaxonomyCreator#upDirection.), p_end = cur->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(!upDirectioncxx . . $ TaxonomyCreator#upDirection.); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
183 if ( !enhancedSubscxx . . $ DLConceptTaxonomy#enhancedSubs(50effb95a029e9ba).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p) )
184 return false;
185
186 // all subsumptions holds -- test current for subsumption
187 return testSubsumptioncxx . . $ DLConceptTaxonomy#testSubsumption(50effb95a029e9ba).(cur);
188 }
189
190 bool
191 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: testSubsumptioncxx . . $ DLConceptTaxonomy#testSubsumption(50effb95a029e9ba). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* cur )
192 {
193 const TConceptcxx . . $ TConcept#* testC = static_cast<const TConceptcxx . . $ TConcept#*>(cur->getPrimercxx . . $ TaxonomyVertex#getPrimer(257357278432d96a).());
194 if ( upDirectioncxx . . $ TaxonomyCreator#upDirection. )
195 return testSubcxx . . $ DLConceptTaxonomy#testSub(7e9f35c32394b4f5). ( testC, curConceptcxx . . $ DLConceptTaxonomy#curConcept(7f9327d86ab44b18).() );
196 else
197 return testSubcxx . . $ DLConceptTaxonomy#testSub(7e9f35c32394b4f5). ( curConceptcxx . . $ DLConceptTaxonomy#curConcept(7f9327d86ab44b18).(), testC );
198 }
199
200 void
201 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: propagateOneCommoncxx . . $ DLConceptTaxonomy#propagateOneCommon(ea5ea6ad7488bb8a). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* node )
202 {
203 // checked if node already was visited this session
204 if ( pTaxcxx . . $ TaxonomyCreator#pTax.->isVisitedcxx . . $ Taxonomy#isVisited(5273acd5b7b596a5).(node) )
205 return;
206
207 // mark node visited
208 pTaxcxx . . $ TaxonomyCreator#pTax.->setVisitedcxx . . $ Taxonomy#setVisited(1e85185f4f4810e2).(node);
209 node->setCommoncxx . . $ TaxonomyVertex#setCommon(49f6e7a06ebc5aa8).();
210 if ( node->correctCommoncxx . . $ TaxonomyVertex#correctCommon(dfa6e707f7696010).(nCommoncxx . . $ DLConceptTaxonomy#nCommon.) )
211 Commoncxx . . $ DLConceptTaxonomy#Common..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(node);
212
213 // mark all children
214 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = node->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(/*upDirection=*/false), p_end = node->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(/*upDirection=*/false); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
215 propagateOneCommoncxx . . $ DLConceptTaxonomy#propagateOneCommon(ea5ea6ad7488bb8a).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
216 }
217
218 bool DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: propagateUpcxx . . $ DLConceptTaxonomy#propagateUp(c9857a73d68e59ba). ( void )
219 {
220 // including node always have some parents (TOP at least)
221 TaxonomyVertexcxx . . $ TaxonomyVertex#* Current = pTaxcxx . . $ TaxonomyCreator#pTax.->getCurrentcxx . . $ Taxonomy#getCurrent(e005a88f538258f6).();
222 TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = Current->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(/*upDirection=*/true), p_end = Current->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(/*upDirection=*/true);
223 fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( p != p_end ); // there is at least one parent (TOP)
224
225 TaxVertexVeccxx . . $ DLConceptTaxonomy#TaxVertexVec# auxcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; // aux set for the vertices in ...
226 nCommoncxx . . $ DLConceptTaxonomy#nCommon. = 1; // number of common parents
227 clearCommoncxx . . $ DLConceptTaxonomy#clearCommon(49f6e7a06ebc5aa8).();
228
229 // define possible successors of the node
230 propagateOneCommoncxx . . $ DLConceptTaxonomy#propagateOneCommon(ea5ea6ad7488bb8a).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
231 pTaxcxx . . $ TaxonomyCreator#pTax.->clearVisitedcxx . . $ Taxonomy#clearVisited(49f6e7a06ebc5aa8).();
232
233 for ( ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p; p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
234 {
235 if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->noNeighbourscxx . . $ TaxonomyVertex#noNeighbours(962fae8be55e1d9).(/*upDirection=*/false) )
236 return true;
237 if ( Commoncxx . . $ DLConceptTaxonomy#Common..emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() )
238 return true;
239
240 ++nCommoncxx . . $ DLConceptTaxonomy#nCommon.;
241 // now Aux contain data from previous run
242 aux.swapcxx . . $ std/vector#swap(a8be04fc17cbdf49).(Commoncxx . . $ DLConceptTaxonomy#Common.);
243 Commoncxx . . $ DLConceptTaxonomy#Common..clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).();
244 propagateOneCommoncxx . . $ DLConceptTaxonomy#propagateOneCommon(ea5ea6ad7488bb8a).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
245 pTaxcxx . . $ TaxonomyCreator#pTax.->clearVisitedcxx . . $ Taxonomy#clearVisited(49f6e7a06ebc5aa8).();
246
247 // clear all non-common nodes (visited on a previous run)
248 for ( TaxVertexVeccxx . . $ DLConceptTaxonomy#TaxVertexVec#::iteratorcxx . . $ std/vector#iterator# q = aux.begincxx . . $ std/vector#begin(33b10a496a38335b).(), q_end = aux.endcxx . . $ std/vector#end(33b10a496a38335b).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q )
249 (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->correctCommoncxx . . $ TaxonomyVertex#correctCommon(dfa6e707f7696010).(nCommoncxx . . $ DLConceptTaxonomy#nCommon.);
250 }
251
252 return false;
253 }
254
255 /// check if no BU classification is required as C=TOP
256 bool
257 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: isEqualToTopcxx . . $ DLConceptTaxonomy#isEqualToTop(c9857a73d68e59ba). ( void )
258 {
259 // check this up-front to avoid Sorted check's flaw wrt equals-to-top
260 const modelCacheInterfacecxx . . $ modelCacheInterface#* cache = tBoxcxx . . $ DLConceptTaxonomy#tBox..initCachecxx . . $ TBox#initCache(6e2e6147ec169214). ( curConceptcxx . . $ DLConceptTaxonomy#curConcept(7f9327d86ab44b18).(), /*sub=*/true );
261 if ( cache->getStatecxx . . $ modelCacheInterface#getState(2c070a27c5715e50).() != csInvalidcxx . . $ csInvalid. )
262 return false;
263 // here concept = TOP
264 pTaxcxx . . $ TaxonomyCreator#pTax.->getCurrentcxx . . $ Taxonomy#getCurrent(e005a88f538258f6).()->addNeighbourcxx . . $ TaxonomyVertex#addNeighbour(93beaa2f49a74c7). ( /*upDirection=*/false, pTaxcxx . . $ TaxonomyCreator#pTax.->getTopVertexcxx . . $ Taxonomy#getTopVertex(16f9ca5fa66f7d36).() );
265 return true;
266 }
267
268 /// @return true iff curEntry is classified as a synonym
269 bool
270 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: classifySynonymcxx . . $ DLConceptTaxonomy#classifySynonym(c9857a73d68e59ba). ( void )
271 {
272 if ( TaxonomyCreatorcxx . . $ TaxonomyCreator#::classifySynonymcxx . . $ TaxonomyCreator#classifySynonym(c9857a73d68e59ba).() )
273 return true;
274
275 if ( curConceptcxx . . $ DLConceptTaxonomy#curConcept(7f9327d86ab44b18).()->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() )
276 {
277 TIndividualcxx . . $ TIndividual#* curI = (TIndividualcxx . . $ TIndividual#*)const_cast<TConceptcxx . . $ TConcept#*>(curConceptcxx . . $ DLConceptTaxonomy#curConcept(7f9327d86ab44b18).());
278
279 if ( unlikelycxx . . $ `Kernel/globaldef.h:29:10`!(tBox.isBlockedInd(curI)) )
280 { // check whether current entry is the same as another individual
281 TIndividualcxx . . $ TIndividual#* syn = tBoxcxx . . $ DLConceptTaxonomy#tBox..getBlockingIndcxx . . $ TBox#getBlockingInd(26bf38a14acccc37).(curI);
282 fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( syn->getTaxVertex() != nullptr );
283
284 if ( tBoxcxx . . $ DLConceptTaxonomy#tBox..isBlockingDetcxx . . $ TBox#isBlockingDet(78140581f8900ef9).(curI) )
285 { // deterministic merge => curI = syn
286 pTaxcxx . . $ TaxonomyCreator#pTax.->addCurrentToSynonymcxx . . $ Taxonomy#addCurrentToSynonym(ea5ea6ad7488bb8a).(syn->getTaxVertexcxx . . $ ClassifiableEntry#getTaxVertex(16f9ca5fa66f7d36).());
287 return true;
288 }
289 else // non-det merge: check whether it is the same
290 {
291 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llTaxTryingcxx . . $ llTaxTrying.) )
292 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nTAX: trying '" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). curI->getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "' = '" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). syn->getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'... ";
293 if ( testSubTBoxcxx . . $ DLConceptTaxonomy#testSubTBox(7e9f35c32394b4f5). ( curI, syn ) ) // they are actually the same
294 {
295 pTaxcxx . . $ TaxonomyCreator#pTax.->addCurrentToSynonymcxx . . $ Taxonomy#addCurrentToSynonym(ea5ea6ad7488bb8a).(syn->getTaxVertexcxx . . $ ClassifiableEntry#getTaxVertex(16f9ca5fa66f7d36).());
296 return true;
297 }
298 }
299 }
300 }
301
302 return false;
303 }
304
305 void /// fill candidates
306 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: fillCandidatescxx . . $ DLConceptTaxonomy#fillCandidates(ea5ea6ad7488bb8a). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* cur )
307 {
308 // std::cout << "fill candidates: " << cur->getPrimer()->getName() << std::endl;
309 if ( isValuedcxx . . $ TaxonomyCreator#isValued(5273acd5b7b596a5).(cur) )
310 {
311 if ( getValuecxx . . $ TaxonomyCreator#getValue(5273acd5b7b596a5).(cur) ) // positive value -- nothing to do
312 return;
313 }
314 else
315 candidatescxx . . $ DLConceptTaxonomy#candidates..insertcxx . . $ std/set#insert(411a10a755068dfe).(cur);
316
317 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = cur->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(true), p_end = cur->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(true); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
318 fillCandidatescxx . . $ DLConceptTaxonomy#fillCandidates(ea5ea6ad7488bb8a).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
319 }
320
321 void
322 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: reclassifycxx . . $ DLConceptTaxonomy#reclassify(75cae9a303a37910). ( const stdcxx . . $ std/::setcxx . . $ std/set#<const TNamedEntitycxx . . $ TNamedEntity#*>& plus, const stdcxx . . $ std/::setcxx . . $ std/set#<const TNamedEntitycxx . . $ TNamedEntity#*>& minus )
323 {
324 MPluscxx . . $ DLConceptTaxonomy#MPlus. =cxx . . $ std/set#`operator=`(7d6e6bfeb60e39ab). plus;
325 MMinuscxx . . $ DLConceptTaxonomy#MMinus. =cxx . . $ std/set#`operator=`(7d6e6bfeb60e39ab). minus;
326 pTaxcxx . . $ TaxonomyCreator#pTax.->deFinalisecxx . . $ Taxonomy#deFinalise(49f6e7a06ebc5aa8).();
327
328 // fill in an order to
329 stdcxx . . $ std/::queuecxx . . $ std/queue#<TaxonomyVertexcxx . . $ TaxonomyVertex#*> queuecxx . . $ std/queue#queue(49f6e7a06ebc5aa8).;
330 stdcxx . . $ std/::vectorcxx . . $ std/vector#<const ClassifiableEntrycxx . . $ ClassifiableEntry#*> toProcesscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
331 queue.pushcxx . . $ std/queue#push(bfe8a576267fe2ec).(pTaxcxx . . $ TaxonomyCreator#pTax.->getTopVertexcxx . . $ Taxonomy#getTopVertex(16f9ca5fa66f7d36).());
332 while ( !queue.emptycxx . . $ std/queue#empty(50ce9a9e25b4a850).() )
333 {
334 TaxonomyVertexcxx . . $ TaxonomyVertex#* cur = queue.frontcxx . . $ std/queue#front(d8c1a3bbdff15733).();
335 queue.popcxx . . $ std/queue#pop(49f6e7a06ebc5aa8).();
336 if ( pTaxcxx . . $ TaxonomyCreator#pTax.->isVisitedcxx . . $ Taxonomy#isVisited(5273acd5b7b596a5).(cur) )
337 continue;
338 pTaxcxx . . $ TaxonomyCreator#pTax.->setVisitedcxx . . $ Taxonomy#setVisited(1e85185f4f4810e2).(cur);
339 const ClassifiableEntrycxx . . $ ClassifiableEntry#* entry = cur->getPrimercxx . . $ TaxonomyVertex#getPrimer(257357278432d96a).();
340 const TNamedEntitycxx . . $ TNamedEntity#* entity = entry->getEntitycxx . . $ TNamedEntry#getEntity(1a59bfca6295ee56).();
341 if ( MPluscxx . . $ DLConceptTaxonomy#MPlus..findcxx . . $ std/set#find(f8922f46a681e6cc).(entity) !=cxx . . $ std/`operator!=`(7e1308a0738ea758). MPluscxx . . $ DLConceptTaxonomy#MPlus..endcxx . . $ std/set#end(a1617ab40ea76896).() || MMinuscxx . . $ DLConceptTaxonomy#MMinus..findcxx . . $ std/set#find(f8922f46a681e6cc).(entity) !=cxx . . $ std/`operator!=`(7e1308a0738ea758). MMinuscxx . . $ DLConceptTaxonomy#MMinus..endcxx . . $ std/set#end(a1617ab40ea76896).() )
342 toProcess.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(entry);
343 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = cur->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(/*upDirection=*/false), p_end = cur->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(/*upDirection=*/false); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
344 queue.pushcxx . . $ std/queue#push(5cd2eaf705c8bad3).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
345 }
346 pTaxcxx . . $ TaxonomyCreator#pTax.->clearVisitedcxx . . $ Taxonomy#clearVisited(49f6e7a06ebc5aa8).();
347 // std::cout << "Add/Del names Taxonomy:\n";
348 // pTax->print(std::cout);
349
350 for ( const ClassifiableEntrycxx . . $ ClassifiableEntry#* entry : toProcess )
351 {
352 TaxonomyVertexcxx . . $ TaxonomyVertex#* node = entry->getTaxVertexcxx . . $ ClassifiableEntry#getTaxVertex(16f9ca5fa66f7d36).();
353 const TNamedEntitycxx . . $ TNamedEntity#* entity = entry->getEntitycxx . . $ TNamedEntry#getEntity(1a59bfca6295ee56).();
354 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Reclassify " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). entity->getNamecxx . . $ TNamedEntity#getName(a9f41ea0e82d88cf).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " (" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). (MPluscxx . . $ DLConceptTaxonomy#MPlus..countcxx . . $ std/set#count(a9c5b6ffd713dfa6).(entity) > 0 ?"Added":"") <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). (MMinuscxx . . $ DLConceptTaxonomy#MMinus..countcxx . . $ std/set#count(a9c5b6ffd713dfa6).(entity) > 0 ?" Removed":"") <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")";
355
356 TsProcTimercxx . . $ TsProcTimer# timer;
357 timer.Startcxx . . $ TsProcTimer#Start(49f6e7a06ebc5aa8).();
358 reclassifycxx . . $ DLConceptTaxonomy#reclassify(95820de7043730ba). ( node, (*tBoxcxx . . $ DLConceptTaxonomy#tBox..pName2Sigcxx . . $ TBox#pName2Sig.)[cxx . . $ std/map#`operator[]`(bbd415b616967878).entity] );
359 timer.Stopcxx . . $ TsProcTimer#Stop(49f6e7a06ebc5aa8).();
360 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "; reclassification time: " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). timer <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
361 // tax->print(std::cout);
362 // std::cout.flush();
363 }
364
365 pTaxcxx . . $ TaxonomyCreator#pTax.->finalisecxx . . $ Taxonomy#finalise(49f6e7a06ebc5aa8).();
366 // print(std::cout);
367 // std::cout.flush();
368 }
369
370 void
371 DLConceptTaxonomycxx . . $ DLConceptTaxonomy# :: reclassifycxx . . $ DLConceptTaxonomy#reclassify(95820de7043730ba). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* node, const TSignaturecxx . . $ TSignature#* s )
372 {
373 upDirectioncxx . . $ TaxonomyCreator#upDirection. = false;
374 sigStackcxx . . $ TaxonomyCreator#sigStack..pushcxx . . $ SearchableStack#push(77d9f17553126ecb).(s);
375 curEntrycxx . . $ TaxonomyCreator#curEntry. = node->getPrimercxx . . $ TaxonomyVertex#getPrimer(257357278432d96a).();
376 TaxonomyVertexcxx . . $ TaxonomyVertex#* oldCur = pTaxcxx . . $ TaxonomyCreator#pTax.->getCurrentcxx . . $ Taxonomy#getCurrent(e005a88f538258f6).();
377 pTaxcxx . . $ TaxonomyCreator#pTax.->setCurrentcxx . . $ Taxonomy#setCurrent(ea5ea6ad7488bb8a).(node);
378
379 // FIXME!! check the unsatisfiability later
380
381 bool added = MPluscxx . . $ DLConceptTaxonomy#MPlus..countcxx . . $ std/set#count(a9c5b6ffd713dfa6).(curEntrycxx . . $ TaxonomyCreator#curEntry.->getEntitycxx . . $ TNamedEntry#getEntity(1a59bfca6295ee56).()) > 0;
382 bool removed = MMinuscxx . . $ DLConceptTaxonomy#MMinus..countcxx . . $ std/set#count(a9c5b6ffd713dfa6).(curEntrycxx . . $ TaxonomyCreator#curEntry.->getEntitycxx . . $ TNamedEntry#getEntity(1a59bfca6295ee56).()) > 0;
383 fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( added || removed );
384 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<TaxonomyVertexcxx . . $ TaxonomyVertex#*> TVArraycxx . . $ DLConceptTaxonomy#reclassify(95820de7043730ba).TVArray#;
385 clearLabelscxx . . $ TaxonomyCreator#clearLabels(49f6e7a06ebc5aa8).();
386
387 setValuecxx . . $ TaxonomyCreator#setValue(2266beb367975663). ( pTaxcxx . . $ TaxonomyCreator#pTax.->getTopVertexcxx . . $ Taxonomy#getTopVertex(16f9ca5fa66f7d36).(), true );
388 if ( node->noNeighbourscxx . . $ TaxonomyVertex#noNeighbours(962fae8be55e1d9).(true) )
389 node->addNeighbourcxx . . $ TaxonomyVertex#addNeighbour(93beaa2f49a74c7).(true, pTaxcxx . . $ TaxonomyCreator#pTax.->getTopVertexcxx . . $ Taxonomy#getTopVertex(16f9ca5fa66f7d36).());
390
391 // we use candidates set if nothing was added (so no need to look further from current subs)
392 useCandidatescxx . . $ DLConceptTaxonomy#useCandidates. = !added;
393 candidatescxx . . $ DLConceptTaxonomy#candidates..clearcxx . . $ std/set#clear(49f6e7a06ebc5aa8).();
394 if ( removed ) // re-check all parents
395 {
396 TVArraycxx . . $ DLConceptTaxonomy#reclassify(95820de7043730ba).TVArray# poscxx . . $ std/vector#vector(49f6e7a06ebc5aa8)., negcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
397 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = node->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(true), p_end = node->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(true); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
398 {
399 if ( isValuedcxx . . $ TaxonomyCreator#isValued(5273acd5b7b596a5).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p) && getValuecxx . . $ TaxonomyCreator#getValue(5273acd5b7b596a5).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p) )
400 continue;
401 bool sub = testSubsumptioncxx . . $ DLConceptTaxonomy#testSubsumption(50effb95a029e9ba).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
402 if ( sub )
403 {
404 pos.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
405 propagateTrueUpcxx . . $ TaxonomyCreator#propagateTrueUp(ea5ea6ad7488bb8a).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
406 }
407 else
408 {
409 setValuecxx . . $ TaxonomyCreator#setValue(2266beb367975663). ( *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p, sub );
410 neg.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
411 }
412 }
413 node->removeLinkscxx . . $ TaxonomyVertex#removeLinks(b45ddcbc8423892c).(true);
414 // for ( TVArray::iterator q = pos.begin(), q_end = pos.end(); q != q_end; ++q )
415 // node->addNeighbour(true, *q);
416 if ( useCandidatescxx . . $ DLConceptTaxonomy#useCandidates. )
417 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#* vertex : neg )
418 fillCandidatescxx . . $ DLConceptTaxonomy#fillCandidates(ea5ea6ad7488bb8a).(vertex);
419 }
420 else // all parents are there
421 {
422 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = node->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(true), p_end = node->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(true); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
423 propagateTrueUpcxx . . $ TaxonomyCreator#propagateTrueUp(ea5ea6ad7488bb8a).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p);
424 node->removeLinkscxx . . $ TaxonomyVertex#removeLinks(b45ddcbc8423892c).(true);
425 }
426
427 // FIXME!! for now. later check the equivalence etc
428 setValuecxx . . $ TaxonomyCreator#setValue(2266beb367975663). ( node, true );
429 // the landscape is prepared
430 searchBaadercxx . . $ DLConceptTaxonomy#searchBaader(ea5ea6ad7488bb8a).(pTaxcxx . . $ TaxonomyCreator#pTax.->getTopVertexcxx . . $ Taxonomy#getTopVertex(16f9ca5fa66f7d36).());
431 node->incorporatecxx . . $ TaxonomyVertex#incorporate(49f6e7a06ebc5aa8).();
432 clearLabelscxx . . $ TaxonomyCreator#clearLabels(49f6e7a06ebc5aa8).();
433 sigStackcxx . . $ TaxonomyCreator#sigStack..popcxx . . $ SearchableStack#pop(49f6e7a06ebc5aa8).();
434 pTaxcxx . . $ TaxonomyCreator#pTax.->setCurrentcxx . . $ Taxonomy#setCurrent(ea5ea6ad7488bb8a).(oldCur);
435 }
436
437 /********************************************************\
438 |* Implementation of class TBox *|
439 \********************************************************/
440
441 void TBoxcxx . . $ TBox# :: createTaxonomycxx . . $ TBox#createTaxonomy(b45ddcbc8423892c). ( bool needIndividual )
442 {
443 bool needConcept = !needIndividual;
444
445 // if there were SAT queries before -- the query (or other) concepts are there. Delete it
446 clearQueryConceptcxx . . $ TBox#clearQueryConcept(49f6e7a06ebc5aa8).();
447
448 // here we sure that ontology is consistent
449 // FIXME!! distinguish later between the 1st run and the following runs
450 if ( pTaxcxx . . $ TBox#pTax. == nullptr ) // 1st run
451 initTaxonomycxx . . $ TBox#initTaxonomy(49f6e7a06ebc5aa8).();
452
453 DLHeapcxx . . $ TBox#DLHeap..setSubOrdercxx . . $ DLDag#setSubOrder(49f6e7a06ebc5aa8).(); // init priorities in order to do subsumption tests
454 pTaxCreatorcxx . . $ TBox#pTaxCreator.->setBottomUpcxx . . $ DLConceptTaxonomy#setBottomUp(2dc2722f98170803).(GCIscxx . . $ TBox#GCIs.);
455 needConcept |= needIndividual; // together with concepts
456 // else // not a first run
457 // return; // FIXME!! now we don't perform staged reasoning, so everything is done
458 /*
459 {
460 fpp_assert ( needIndividual );
461 pTax->deFinalise();
462 }
463 */
464 if ( verboseOutputcxx . . $ TBox#verboseOutput. )
465 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Processing query...";
466
467 TsProcTimercxx . . $ TsProcTimer# locTimer;
468 locTimer.Startcxx . . $ TsProcTimer#Start(49f6e7a06ebc5aa8).();
469
470 // calculate number of items to be classified
471 unsigned int nItems = 0;
472
473 // fills collections
474 arrayCDcxx . . $ TBox#arrayCD..clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).();
475 arrayNoCDcxx . . $ TBox#arrayNoCD..clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).();
476 arrayNPcxx . . $ TBox#arrayNP..clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).();
477
478 // if ( needConcept )
479 nItems += fillArrayscxx . . $ TBox#fillArrays(7aec5fd617a6aa65). ( c_begincxx . . $ TBox#c_begin(23ec1c5bda99ac5d).(), c_endcxx . . $ TBox#c_end(23ec1c5bda99ac5d).() );
480 // if ( needIndividual || nNominalReferences > 0 ) // TODO ORE
481 nItems += fillArrayscxx . . $ TBox#fillArrays(7aec5fd617a6aa65). ( i_begincxx . . $ TBox#i_begin(78b5d4d1a9fb506d).(), i_endcxx . . $ TBox#i_end(78b5d4d1a9fb506d).() );
482
483 // taxonomy progress
484 if ( pMonitorcxx . . $ TBox#pMonitor. )
485 {
486 pMonitorcxx . . $ TBox#pMonitor.->setClassificationStartedcxx . . $ TProgressMonitor#setClassificationStarted(cb2f890c2fdad230).(nItems);
487 pTaxCreatorcxx . . $ TBox#pTaxCreator.->setProgressIndicatorcxx . . $ DLConceptTaxonomy#setProgressIndicator(192f8d731e56d7e3).(pMonitorcxx . . $ TBox#pMonitor.);
488 }
489
490 // sort ( arrayCD.begin(), arrayCD.end(), TSDepthCompare() );
491 classifyConceptscxx . . $ TBox#classifyConcepts(cccdbcffc97ee4ec). ( arrayCDcxx . . $ TBox#arrayCD., true, "completely defined" );
492 // sort ( arrayNoCD.begin(), arrayNoCD.end(), TSDepthCompare() );
493 classifyConceptscxx . . $ TBox#classifyConcepts(cccdbcffc97ee4ec). ( arrayNoCDcxx . . $ TBox#arrayNoCD., false, "regular" );
494 // sort ( arrayNP.begin(), arrayNP.end(), TSDepthCompare() );
495 classifyConceptscxx . . $ TBox#classifyConcepts(cccdbcffc97ee4ec). ( arrayNPcxx . . $ TBox#arrayNP., false, "non-primitive" );
496
497 if ( pMonitorcxx . . $ TBox#pMonitor. )
498 {
499 pMonitorcxx . . $ TBox#pMonitor.->setFinishedcxx . . $ TProgressMonitor#setFinished(49f6e7a06ebc5aa8).();
500 setProgressMonitorcxx . . $ TBox#setProgressMonitor(192f8d731e56d7e3).(nullptr); // no need of PM after classification done
501 pTaxCreatorcxx . . $ TBox#pTaxCreator.->setProgressIndicatorcxx . . $ DLConceptTaxonomy#setProgressIndicator(192f8d731e56d7e3).(nullptr);
502 }
503 pTaxcxx . . $ TBox#pTax.->finalisecxx . . $ Taxonomy#finalise(49f6e7a06ebc5aa8).();
504
505 locTimer.Stopcxx . . $ TsProcTimer#Stop(49f6e7a06ebc5aa8).();
506 if ( verboseOutputcxx . . $ TBox#verboseOutput. )
507 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " done in " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). locTimer <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " seconds\n";
508
509 if ( needConcept && Statuscxx . . $ TBox#Status. < kbClassifiedcxx . . $ kbClassified. )
510 Statuscxx . . $ TBox#Status. = kbClassifiedcxx . . $ kbClassified.;
511 if ( needIndividual )
512 Statuscxx . . $ TBox#Status. = kbRealisedcxx . . $ kbRealised.;
513
514 if ( verboseOutputcxx . . $ TBox#verboseOutput./* && needIndividual*/ )
515 {
516 stdcxx . . $ std/::ofstreamcxx . . $ std/ofstream# ofcxx . . $ std/basic_ofstream#basic_ofstream(b8cd37071ce335df).("Taxonomy.log");
517 pTaxCreatorcxx . . $ TBox#pTaxCreator.->printcxx . . $ DLConceptTaxonomy#print(490063bd7e6d8d5d).(of);
518 }
519 }
520
521 void
522 TBoxcxx . . $ TBox# :: classifyConceptscxx . . $ TBox#classifyConcepts(cccdbcffc97ee4ec). ( const ConceptVectorcxx . . $ TBox#ConceptVector#& collection, bool curCompletelyDefined, const char* type )
523 {
524 // set CD for taxonomy
525 pTaxCreatorcxx . . $ TBox#pTaxCreator.->setCompletelyDefinedcxx . . $ TaxonomyCreator#setCompletelyDefined(b45ddcbc8423892c).(curCompletelyDefined);
526
527 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llStartCfyConceptscxx . . $ llStartCfyConcepts.) )
528 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n\n---Start classifying " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). type <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " concepts";
529
530 unsigned int n = 0;
531
532 for ( ConceptVectorcxx . . $ TBox#ConceptVector#::const_iteratorcxx . . $ std/vector#const_iterator# q = collection.begincxx . . $ std/vector#begin(359ca5030082c9f).(), q_end = collection.endcxx . . $ std/vector#end(359ca5030082c9f).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q )
533 // check if concept is already classified
534 if ( !isCancelledcxx . . $ TBox#isCancelled(50ce9a9e25b4a850).() && !(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->isClassifiedcxx . . $ ClassifiableEntry#isClassified(50ce9a9e25b4a850). () /*&& (*q)->isClassifiable(curCompletelyDefined)*/ )
535 {
536 classifyEntrycxx . . $ TBox#classifyEntry(3f0281ca3ae282d4).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q); // need to classify concept
537 if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->isClassifiedcxx . . $ ClassifiableEntry#isClassified(50ce9a9e25b4a850).() )
538 ++n;
539 }
540
541 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llStartCfyConceptscxx . . $ llStartCfyConcepts.) )
542 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n---Done: " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). n <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). type <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " concepts classified";
543 }