| 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 | #include <fstream> |
| 21 | #include <iostream> |
| 22 | |
| 23 | #include "dlTBox.h"cxx . . $ `<file>/Kernel/dlTBox.h`/ |
| 24 | |
| 25 | #include "procTimer.h"cxx . . $ `<file>/Kernel/procTimer.h`/ |
| 26 | #include "logging.h"cxx . . $ `<file>/Kernel/logging.h`/ |
| 27 | |
| 28 | //#define DEBUG_PREPROCESSING |
| 29 | |
| 30 | #ifdef DEBUG_PREPROCESSING |
| 31 | # define BEGIN_PASS(str) std::cerr << "\n" str "... " |
| 32 | # define END_PASS() std::cerr << "done" |
| 33 | #else |
| 34 | # define BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!(str) |
| 35 | # define END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!() |
| 36 | #endif |
| 37 | |
| 38 | void TBoxcxx . . $ TBox# :: Preprocesscxx . . $ TBox#Preprocess(49f6e7a06ebc5aa8). ( void ) |
| 39 | { |
| 40 | if ( verboseOutputcxx . . $ TBox#verboseOutput. ) |
| 41 | stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Preprocessing..."; |
| 42 | TsProcTimercxx . . $ TsProcTimer# pt; |
| 43 | pt.Startcxx . . $ TsProcTimer#Start(49f6e7a06ebc5aa8).(); |
| 44 | |
| 45 | // builds role hierarchy |
| 46 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Build role hierarchy"); |
| 47 | ORMcxx . . $ TBox#ORM..initAncDesccxx . . $ RoleMaster#initAncDesc(49f6e7a06ebc5aa8).(); |
| 48 | DRMcxx . . $ TBox#DRM..initAncDesccxx . . $ RoleMaster#initAncDesc(49f6e7a06ebc5aa8).(); |
| 49 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 50 | |
| 51 | if ( verboseOutputcxx . . $ TBox#verboseOutput. ) |
| 52 | { |
| 53 | stdcxx . . $ std/::ofstreamcxx . . $ std/ofstream# orolescxx . . $ std/basic_ofstream#basic_ofstream(b8cd37071ce335df).("Taxonomy.ORoles"); |
| 54 | ORMcxx . . $ TBox#ORM..getTaxonomycxx . . $ RoleMaster#getTaxonomy(f8112ea4e715bb99).()->printcxx . . $ Taxonomy#print(490063bd7e6d8d5d).(oroles); |
| 55 | stdcxx . . $ std/::ofstreamcxx . . $ std/ofstream# drolescxx . . $ std/basic_ofstream#basic_ofstream(b8cd37071ce335df).("Taxonomy.DRoles"); |
| 56 | DRMcxx . . $ TBox#DRM..getTaxonomycxx . . $ RoleMaster#getTaxonomy(f8112ea4e715bb99).()->printcxx . . $ Taxonomy#print(490063bd7e6d8d5d).(droles); |
| 57 | } |
| 58 | |
| 59 | // all concept descriptions contains synonyms. Remove them now |
| 60 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Replace synonyms in expressions"); |
| 61 | if ( countSynonymscxx . . $ TBox#countSynonyms(ddd8539a2fcdd4ce).() > 0 ) |
| 62 | replaceAllSynonymscxx . . $ TBox#replaceAllSynonyms(49f6e7a06ebc5aa8).(); |
| 63 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 64 | |
| 65 | // preprocess Related structure (before classification tags are defined) |
| 66 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Preprocess related axioms"); |
| 67 | preprocessRelatedcxx . . $ TBox#preprocessRelated(49f6e7a06ebc5aa8).(); |
| 68 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 69 | |
| 70 | // FIXME!! find a proper place for this |
| 71 | TransformExtraSubsumptionscxx . . $ TBox#TransformExtraSubsumptions(49f6e7a06ebc5aa8).(); |
| 72 | |
| 73 | // init told subsumers as they would be used soon |
| 74 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Init told subsumers"); |
| 75 | initToldSubsumerscxx . . $ TBox#initToldSubsumers(49f6e7a06ebc5aa8).(); |
| 76 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 77 | |
| 78 | // locate told (definitional) cycles and transform them into synonyms |
| 79 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Detect and replace told cycles"); |
| 80 | transformToldCyclescxx . . $ TBox#transformToldCycles(49f6e7a06ebc5aa8).(); |
| 81 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 82 | |
| 83 | // detect singleton with singleton parents and make them synonyms |
| 84 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Detect and transform singleton hierarchy"); |
| 85 | transformSingletonHierarchycxx . . $ TBox#transformSingletonHierarchy(49f6e7a06ebc5aa8).(); |
| 86 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 87 | |
| 88 | // absorb axioms (move some Axioms to Role and Concept Description) |
| 89 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Perform absorption"); |
| 90 | AbsorbAxiomscxx . . $ TBox#AbsorbAxioms(49f6e7a06ebc5aa8).(); |
| 91 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 92 | |
| 93 | // set told TOP concepts whether necessary |
| 94 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Set told TOP"); |
| 95 | setToldTopcxx . . $ TBox#setToldTop(49f6e7a06ebc5aa8).(); |
| 96 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 97 | |
| 98 | // no more axiom transformations allowed |
| 99 | |
| 100 | // create DAG (concept normalisation etc) |
| 101 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Build DAG"); |
| 102 | buildDAGcxx . . $ TBox#buildDAG(49f6e7a06ebc5aa8).(); |
| 103 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 104 | |
| 105 | // fills classification tag (strictly after told cycles) |
| 106 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Detect classification tags"); |
| 107 | fillsClassificationTagcxx . . $ TBox#fillsClassificationTag(49f6e7a06ebc5aa8).(); |
| 108 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 109 | |
| 110 | // set up TS depth |
| 111 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Calculate told subsumer depth"); |
| 112 | calculateTSDepthcxx . . $ TBox#calculateTSDepth(49f6e7a06ebc5aa8).(); |
| 113 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 114 | |
| 115 | // set indexes for model caching |
| 116 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Set all indexes"); |
| 117 | setAllIndexescxx . . $ TBox#setAllIndexes(49f6e7a06ebc5aa8).(); |
| 118 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 119 | |
| 120 | // create sorts for KB |
| 121 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Determine sorts"); |
| 122 | determineSortscxx . . $ TBox#determineSorts(49f6e7a06ebc5aa8).(); |
| 123 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 124 | |
| 125 | // calculate statistic for the whole KB: |
| 126 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Gather relevance info"); |
| 127 | gatherRelevanceInfocxx . . $ TBox#gatherRelevanceInfo(49f6e7a06ebc5aa8).(); |
| 128 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 129 | |
| 130 | // here it is safe to print KB features (all are known; the last one was in Relevance) |
| 131 | printFeaturescxx . . $ TBox#printFeatures(83f5f38750778ac8).(); |
| 132 | |
| 133 | // GALEN-like flag is known here, so we can set OR defaults |
| 134 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Set defaults for OR orderings"); |
| 135 | DLHeapcxx . . $ TBox#DLHeap..setOrderDefaultscxx . . $ DLDag#setOrderDefaults(2fa786934fe80e24). ( |
| 136 | isGalenLikeTBoxcxx . . $ TBox#isGalenLikeTBox(50ce9a9e25b4a850).() ? "Fdn" : isWineLikeTBoxcxx . . $ TBox#isWineLikeTBox(50ce9a9e25b4a850).() ? "Sdp" : "Sap", // SAT settings |
| 137 | isGalenLikeTBoxcxx . . $ TBox#isGalenLikeTBox(50ce9a9e25b4a850).() ? "Ban" : isWineLikeTBoxcxx . . $ TBox#isWineLikeTBox(50ce9a9e25b4a850).() ? "Fdn" : "Dap" // SUB settings |
| 138 | ); |
| 139 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 140 | |
| 141 | // now we can gather DAG statistics (if necessary) |
| 142 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Gather usage statistics"); |
| 143 | DLHeapcxx . . $ TBox#DLHeap..gatherStatisticcxx . . $ DLDag#gatherStatistic(49f6e7a06ebc5aa8).(); |
| 144 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 145 | |
| 146 | // calculate statistic on DAG and Roles |
| 147 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Gather concept-related statistics"); |
| 148 | CalculateStatisticcxx . . $ TBox#CalculateStatistic(49f6e7a06ebc5aa8).(); |
| 149 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 150 | |
| 151 | // free extra memory |
| 152 | BEGIN_PASScxx . . $ `Kernel/Preprocess.cpp:34:10`!("Free unused memory"); |
| 153 | RemoveExtraDescriptionscxx . . $ TBox#RemoveExtraDescriptions(49f6e7a06ebc5aa8).(); |
| 154 | END_PASScxx . . $ `Kernel/Preprocess.cpp:35:10`!(); |
| 155 | |
| 156 | pt.Stopcxx . . $ TsProcTimer#Stop(49f6e7a06ebc5aa8).(); |
| 157 | preprocTimecxx . . $ TBox#preprocTime. = pt; |
| 158 | if ( verboseOutputcxx . . $ TBox#verboseOutput. ) |
| 159 | stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " done in " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). pt <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " seconds\n"; |
| 160 | } |
| 161 | |
| 162 | static bool |
| 163 | replaceSynonymsFromTreecxx . . $ replaceSynonymsFromTree(38a18fab043f8799). ( DLTreecxx . . $ DLTree#* desc ) |
| 164 | { |
| 165 | if ( desc == nullptr ) |
| 166 | return false; |
| 167 | |
| 168 | if ( isNamecxx . . $ isName(937bda690ff1bb73).(desc) ) |
| 169 | { |
| 170 | TLexemecxx . . $ TLexeme#& cur = desc->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).(); // not const |
| 171 | ClassifiableEntrycxx . . $ ClassifiableEntry#* entry = static_cast<ClassifiableEntrycxx . . $ ClassifiableEntry#*>(cur.getNEcxx . . $ TLexeme#getNE(28c03b9fd3c689f8).()); |
| 172 | |
| 173 | if ( entry->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() ) |
| 174 | { |
| 175 | entry = resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(entry); |
| 176 | // check for TOP/BOTTOM |
| 177 | if ( entry->isTopcxx . . $ TNamedEntry#isTop(50ce9a9e25b4a850).() ) |
| 178 | cur =cxx . . $ TLexeme#`operator=`(d573732c929da5f6). TLexemecxx . . $ TLexeme#(TOPcxx . . $ TOP.); |
| 179 | else if ( entry->isBottomcxx . . $ TNamedEntry#isBottom(50ce9a9e25b4a850).() ) |
| 180 | cur =cxx . . $ TLexeme#`operator=`(d573732c929da5f6). TLexemecxx . . $ TLexeme#(BOTTOMcxx . . $ BOTTOM.); |
| 181 | else |
| 182 | cur =cxx . . $ TLexeme#`operator=`(d573732c929da5f6). TLexemecxx . . $ TLexeme#TLexeme(fd83bdfbf3306061). ( static_cast<TConceptcxx . . $ TConcept#*>(entry)->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ? INAMEcxx . . $ INAME. : CNAMEcxx . . $ CNAME., entry ); |
| 183 | return true; |
| 184 | } |
| 185 | else |
| 186 | return false; |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | bool ret = replaceSynonymsFromTreecxx . . $ replaceSynonymsFromTree(38a18fab043f8799). ( desc->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).() ); |
| 191 | ret |= replaceSynonymsFromTreecxx . . $ replaceSynonymsFromTree(38a18fab043f8799). ( desc->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).() ); |
| 192 | return ret; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | void TBoxcxx . . $ TBox# :: replaceAllSynonymscxx . . $ TBox#replaceAllSynonyms(49f6e7a06ebc5aa8). ( void ) |
| 197 | { |
| 198 | // replace synonyms in role's domain |
| 199 | for ( const auto& oRole: ORMcxx . . $ TBox#ORM. ) |
| 200 | if ( !oRole->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() ) |
| 201 | replaceSynonymsFromTreecxx . . $ replaceSynonymsFromTree(38a18fab043f8799). ( oRole->getTDomaincxx . . $ TRole#getTDomain(7ba0ba2d2b26f6a8).() ); |
| 202 | for ( const auto& dRole: DRMcxx . . $ TBox#DRM. ) |
| 203 | if ( !dRole->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() ) |
| 204 | replaceSynonymsFromTreecxx . . $ replaceSynonymsFromTree(38a18fab043f8799). ( dRole->getTDomaincxx . . $ TRole#getTDomain(7ba0ba2d2b26f6a8).() ); |
| 205 | |
| 206 | for ( c_iteratorcxx . . $ TBox#c_iterator# pc = c_begincxx . . $ TBox#c_begin(23ec1c5bda99ac5d).(); pc !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). c_endcxx . . $ TBox#c_end(23ec1c5bda99ac5d).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).pc ) |
| 207 | if ( replaceSynonymsFromTreecxx . . $ replaceSynonymsFromTree(38a18fab043f8799). ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pc)->Descriptioncxx . . $ TConcept#Description. ) ) |
| 208 | (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pc)->initToldSubsumerscxx . . $ TConcept#initToldSubsumers(49f6e7a06ebc5aa8).(); |
| 209 | for ( i_iteratorcxx . . $ TBox#i_iterator# pi = i_begincxx . . $ TBox#i_begin(78b5d4d1a9fb506d).(); pi !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). i_endcxx . . $ TBox#i_end(78b5d4d1a9fb506d).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).pi ) |
| 210 | if ( replaceSynonymsFromTreecxx . . $ replaceSynonymsFromTree(38a18fab043f8799). ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pi)->Descriptioncxx . . $ TConcept#Description. ) ) |
| 211 | (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pi)->initToldSubsumerscxx . . $ TIndividual#initToldSubsumers(49f6e7a06ebc5aa8).(); |
| 212 | } |
| 213 | |
| 214 | void TBoxcxx . . $ TBox# :: preprocessRelatedcxx . . $ TBox#preprocessRelated(49f6e7a06ebc5aa8). ( void ) |
| 215 | { |
| 216 | for ( auto& related: RelatedIcxx . . $ TBox#RelatedI. ) |
| 217 | related->simplifycxx . . $ TRelated#simplify(49f6e7a06ebc5aa8).(); |
| 218 | } |
| 219 | |
| 220 | void TBoxcxx . . $ TBox# :: transformToldCyclescxx . . $ TBox#transformToldCycles(49f6e7a06ebc5aa8). ( void ) |
| 221 | { |
| 222 | // remember number of synonyms appeared in KB |
| 223 | unsigned int nSynonyms = countSynonymscxx . . $ TBox#countSynonyms(ddd8539a2fcdd4ce).(); |
| 224 | |
| 225 | clearRelevanceInfocxx . . $ TBox#clearRelevanceInfo(49f6e7a06ebc5aa8).(); |
| 226 | for ( c_iteratorcxx . . $ TBox#c_iterator# pc = c_begincxx . . $ TBox#c_begin(23ec1c5bda99ac5d).(); pc !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). c_endcxx . . $ TBox#c_end(23ec1c5bda99ac5d).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).pc ) |
| 227 | if ( !(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pc)->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() ) |
| 228 | checkToldCyclecxx . . $ TBox#checkToldCycle(2463a09a87430b75).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pc); |
| 229 | |
| 230 | for ( i_iteratorcxx . . $ TBox#i_iterator# pi = i_begincxx . . $ TBox#i_begin(78b5d4d1a9fb506d).(); pi !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). i_endcxx . . $ TBox#i_end(78b5d4d1a9fb506d).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).pi ) |
| 231 | if ( !(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pi)->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() ) |
| 232 | checkToldCyclecxx . . $ TBox#checkToldCycle(2463a09a87430b75).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pi); |
| 233 | clearRelevanceInfocxx . . $ TBox#clearRelevanceInfo(49f6e7a06ebc5aa8).(); |
| 234 | |
| 235 | // update number of synonyms |
| 236 | nSynonyms = countSynonymscxx . . $ TBox#countSynonyms(ddd8539a2fcdd4ce).() - nSynonyms; |
| 237 | if ( nSynonyms ) |
| 238 | { |
| 239 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llAlwayscxx . . $ llAlways.) ) |
| 240 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nTold cycle elimination done with " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). nSynonyms <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " synonyms created"; |
| 241 | |
| 242 | replaceAllSynonymscxx . . $ TBox#replaceAllSynonyms(49f6e7a06ebc5aa8).(); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | TConceptcxx . . $ TConcept#* TBoxcxx . . $ TBox# :: checkToldCyclecxx . . $ TBox#checkToldCycle(2463a09a87430b75). ( TConceptcxx . . $ TConcept#* p ) |
| 247 | { |
| 248 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( p != nullptr ); // safety check |
| 249 | |
| 250 | // resolve synonym (if happens) to prevent cases like A[=B[=C[=A, A[=D[=B |
| 251 | p = resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(p); |
| 252 | |
| 253 | // no reason to process TOP here |
| 254 | if ( p == pTopcxx . . $ TBox#pTop. ) |
| 255 | return nullptr; |
| 256 | |
| 257 | // if we found a cycle... |
| 258 | if ( CInProcesscxx . . $ TBox#CInProcess..findcxx . . $ std/set#find(f8922f46a681e6cc).(p) !=cxx . . $ std/`operator!=`(7e1308a0738ea758). CInProcesscxx . . $ TBox#CInProcess..endcxx . . $ std/set#end(a1617ab40ea76896).() ) |
| 259 | { |
| 260 | // std::cout << "Cycle with " << p->getName() << std::endl; |
| 261 | return p; |
| 262 | } |
| 263 | |
| 264 | if ( isRelevantcxx . . $ TBox#isRelevant(b352c686bfa4bc3f).(p) ) |
| 265 | { |
| 266 | // std::cout << "Already checked: " << p->getName() << std::endl; |
| 267 | return nullptr; |
| 268 | } |
| 269 | |
| 270 | TConceptcxx . . $ TConcept#* ret = nullptr; |
| 271 | |
| 272 | // add concept in processing |
| 273 | CInProcesscxx . . $ TBox#CInProcess..insertcxx . . $ std/set#insert(411a10a755068dfe).(p); |
| 274 | |
| 275 | redo: |
| 276 | |
| 277 | // std::cout << "Start from " << p->getName() << std::endl; |
| 278 | |
| 279 | for ( auto r: p->toldcxx . . $ ClassifiableEntry#told(e7230ad44187fae2).() ) |
| 280 | // if cycle was detected |
| 281 | if ( (ret = checkToldCyclecxx . . $ TBox#checkToldCycle(2463a09a87430b75).(static_cast<TConceptcxx . . $ TConcept#*>(r))) != nullptr ) |
| 282 | { |
| 283 | if ( ret == p ) |
| 284 | { |
| 285 | // std::cout << "Fill cycle with " << p->getName() << std::endl; |
| 286 | ToldSynonymscxx . . $ TBox#ToldSynonyms..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(p); |
| 287 | |
| 288 | // find a representative for the cycle; nominal is preferable |
| 289 | for ( auto& rep: ToldSynonymscxx . . $ TBox#ToldSynonyms. ) |
| 290 | if ( rep->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ) |
| 291 | p = rep; |
| 292 | // now p is a representative for all the synonyms |
| 293 | |
| 294 | // fill the description |
| 295 | DLTreecxx . . $ DLTree#* desc = nullptr; |
| 296 | for ( auto& syn: ToldSynonymscxx . . $ TBox#ToldSynonyms. ) |
| 297 | if ( syn != p ) // make it a synonym of RET, save old desc |
| 298 | { |
| 299 | desc = createSNFAndcxx . . $ createSNFAnd(f2877343b7b69ea7). ( desc, makeNonPrimitivecxx . . $ TBox#makeNonPrimitive(1e45738bba157392). ( syn, getTreecxx . . $ TBox#getTree(8f1a6b264b733ed7).(p) ) ); |
| 300 | // check whether we had an extra definition for Q |
| 301 | ConceptDefMapcxx . . $ TBox#ConceptDefMap#::iteratorcxx . . $ std/map#iterator# extra = ExtraConceptDefscxx . . $ TBox#ExtraConceptDefs..findcxx . . $ std/map#find(36f8d56706583706).(syn); |
| 302 | if ( extra !=cxx . . $ std/`operator!=`(84f83906d8995b82). ExtraConceptDefscxx . . $ TBox#ExtraConceptDefs..endcxx . . $ std/map#end(fbe2f8c57595edf).() ) |
| 303 | { |
| 304 | desc = createSNFAndcxx . . $ createSNFAnd(f2877343b7b69ea7). ( desc, extra->cxx . . $ std/_Rb_tree_iterator#`operator->`(5a2a78a048fb49a8).secondcxx . . $ std/pair#second. ); |
| 305 | ExtraConceptDefscxx . . $ TBox#ExtraConceptDefs..erasecxx . . $ std/map#erase(9238c2f1608b9ba6).(extra); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | ToldSynonymscxx . . $ TBox#ToldSynonyms..clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).(); |
| 310 | |
| 311 | // mark the returned concept primitive (to allow addDesc to work) |
| 312 | p->setPrimitivecxx . . $ TConcept#setPrimitive(49f6e7a06ebc5aa8).(); |
| 313 | p->addDesccxx . . $ TConcept#addDesc(edf821a2fc5509f9).(desc); |
| 314 | |
| 315 | // replace all synonyms with TOP |
| 316 | p->removeSelfFromDescriptioncxx . . $ TConcept#removeSelfFromDescription(49f6e7a06ebc5aa8).(); |
| 317 | |
| 318 | // re-run the search starting from new sample |
| 319 | if ( ret != p ) // need to fix the stack |
| 320 | { |
| 321 | CInProcesscxx . . $ TBox#CInProcess..erasecxx . . $ std/set#erase(3a53bfe100edb289).(ret); |
| 322 | CInProcesscxx . . $ TBox#CInProcess..insertcxx . . $ std/set#insert(411a10a755068dfe).(p); |
| 323 | ret->setRelevantcxx . . $ TConcept#setRelevant(9ce72ecab6fc8b2b).(relevancecxx . . $ TBox#relevance.); |
| 324 | p->dropRelevantcxx . . $ TConcept#dropRelevant(9ce72ecab6fc8b2b).(relevancecxx . . $ TBox#relevance.); |
| 325 | } |
| 326 | |
| 327 | ret = nullptr; |
| 328 | goto redo; |
| 329 | } |
| 330 | else |
| 331 | { |
| 332 | ToldSynonymscxx . . $ TBox#ToldSynonyms..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(p); |
| 333 | // no need to continue; finish with this cycle first |
| 334 | break; |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | // remove processed concept from set |
| 339 | CInProcesscxx . . $ TBox#CInProcess..erasecxx . . $ std/set#erase(3a53bfe100edb289).(p); |
| 340 | |
| 341 | p->setRelevantcxx . . $ TConcept#setRelevant(9ce72ecab6fc8b2b).(relevancecxx . . $ TBox#relevance.); |
| 342 | // std::cout << "Done with " << p->getName() << std::endl; |
| 343 | |
| 344 | return ret; |
| 345 | } |
| 346 | |
| 347 | /// transform i [= C [= j into i=C=j for i,j nominals |
| 348 | void |
| 349 | TBoxcxx . . $ TBox# :: transformSingletonHierarchycxx . . $ TBox#transformSingletonHierarchy(49f6e7a06ebc5aa8). ( void ) |
| 350 | { |
| 351 | // remember number of synonyms appeared in KB |
| 352 | unsigned int nSynonyms = countSynonymscxx . . $ TBox#countSynonyms(ddd8539a2fcdd4ce).(); |
| 353 | |
| 354 | // cycle until no new synonyms are created |
| 355 | bool changed; |
| 356 | |
| 357 | do |
| 358 | { |
| 359 | changed = false; |
| 360 | |
| 361 | for ( i_iteratorcxx . . $ TBox#i_iterator# pi = i_begincxx . . $ TBox#i_begin(78b5d4d1a9fb506d).(); pi !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). i_endcxx . . $ TBox#i_end(78b5d4d1a9fb506d).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).pi ) |
| 362 | if ( !(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pi)->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pi)->isHasSPcxx . . $ TConcept#isHasSP(50ce9a9e25b4a850).() ) |
| 363 | { |
| 364 | TIndividualcxx . . $ TIndividual#* i = transformSingletonWithSPcxx . . $ TBox#transformSingletonWithSP(38385e3551a319c2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pi); |
| 365 | i->removeSelfFromDescriptioncxx . . $ TConcept#removeSelfFromDescription(49f6e7a06ebc5aa8).(); |
| 366 | changed = true; |
| 367 | } |
| 368 | } while ( changed ); |
| 369 | |
| 370 | // update number of synonyms |
| 371 | nSynonyms = countSynonymscxx . . $ TBox#countSynonyms(ddd8539a2fcdd4ce).() - nSynonyms; |
| 372 | if ( nSynonyms ) |
| 373 | replaceAllSynonymscxx . . $ TBox#replaceAllSynonyms(49f6e7a06ebc5aa8).(); |
| 374 | } |
| 375 | |
| 376 | /// helper to the transformSingletonWithSP() function |
| 377 | TIndividualcxx . . $ TIndividual#* |
| 378 | TBoxcxx . . $ TBox# :: getSPForConceptcxx . . $ TBox#getSPForConcept(38385e3551a319c2). ( TConceptcxx . . $ TConcept#* p ) |
| 379 | { |
| 380 | for ( auto r: p->toldcxx . . $ ClassifiableEntry#told(e7230ad44187fae2).() ) |
| 381 | { |
| 382 | TConceptcxx . . $ TConcept#* i = static_cast<TConceptcxx . . $ TConcept#*>(r); |
| 383 | if ( i->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ) // found the end of the chain |
| 384 | return static_cast<TIndividualcxx . . $ TIndividual#*>(i); |
| 385 | if ( i->isHasSPcxx . . $ TConcept#isHasSP(50ce9a9e25b4a850).() ) // found the continuation of the chain |
| 386 | return transformSingletonWithSPcxx . . $ TBox#transformSingletonWithSP(38385e3551a319c2).(i); |
| 387 | } |
| 388 | // will always found the entry |
| 389 | fpp_unreachablecxx . . $ `Kernel/fpp_assert.h:49:9`!(); |
| 390 | } |
| 391 | |
| 392 | /// make P and all its non-singleton parents synonyms to its singleton parent |
| 393 | TIndividualcxx . . $ TIndividual#* |
| 394 | TBoxcxx . . $ TBox# :: transformSingletonWithSPcxx . . $ TBox#transformSingletonWithSP(38385e3551a319c2). ( TConceptcxx . . $ TConcept#* p ) |
| 395 | { |
| 396 | TIndividualcxx . . $ TIndividual#* i = getSPForConceptcxx . . $ TBox#getSPForConcept(38385e3551a319c2).(p); |
| 397 | |
| 398 | // make p a synonym of i |
| 399 | if ( p->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ) |
| 400 | i->addRelatedcxx . . $ TIndividual#addRelated(8c463a1a9ca3e3d3).(static_cast<TIndividualcxx . . $ TIndividual#*>(p)); |
| 401 | addSubsumeAxiomcxx . . $ TBox#addSubsumeAxiom(4128fa2c78139db0). ( i, makeNonPrimitivecxx . . $ TBox#makeNonPrimitive(1e45738bba157392). ( p, getTreecxx . . $ TBox#getTree(8f1a6b264b733ed7).(i) ) ); |
| 402 | |
| 403 | return i; |
| 404 | } |
| 405 | |
| 406 | /// @return true if C is referenced in TREE; use PROCESSED to record explored names |
| 407 | bool |
| 408 | TBoxcxx . . $ TBox# :: isReferencedcxx . . $ TBox#isReferenced(98b03190f111a09d). ( TConceptcxx . . $ TConcept#* C, DLTreecxx . . $ DLTree#* tree, ConceptSetcxx . . $ TBox#ConceptSet#& processed ) const |
| 409 | { |
| 410 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( tree != nullptr ); |
| 411 | switch ( tree->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).().getTokencxx . . $ TLexeme#getToken(d71a1020745f3953).() ) |
| 412 | { |
| 413 | // names |
| 414 | case CNAMEcxx . . $ CNAME.: |
| 415 | case INAMEcxx . . $ INAME.: |
| 416 | { |
| 417 | TConceptcxx . . $ TConcept#* D = toConceptcxx . . $ TBox#toConcept(45d7b14406cbd318).(tree->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).().getNEcxx . . $ TLexeme#getNE(28c03b9fd3c689f8).()); |
| 418 | // check whether we found cycle |
| 419 | if ( C == D ) |
| 420 | return true; |
| 421 | // check if we already processed D |
| 422 | if ( processed.countcxx . . $ std/set#count(a9c5b6ffd713dfa6).(D) > 0 ) |
| 423 | return false; |
| 424 | // recurse here |
| 425 | return isReferencedcxx . . $ TBox#isReferenced(301dea6fb175ea62). ( C, D, processed ); |
| 426 | } |
| 427 | |
| 428 | // binary concept operations |
| 429 | case ANDcxx . . $ AND.: |
| 430 | case ORcxx . . $ OR.: |
| 431 | return isReferencedcxx . . $ TBox#isReferenced(98b03190f111a09d). ( C, tree->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).(), processed ) || isReferencedcxx . . $ TBox#isReferenced(98b03190f111a09d). ( C, tree->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).(), processed ); |
| 432 | |
| 433 | // operations with a single concept |
| 434 | case NOTcxx . . $ NOT.: |
| 435 | return isReferencedcxx . . $ TBox#isReferenced(98b03190f111a09d). ( C, tree->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).(), processed ); |
| 436 | case EXISTScxx . . $ EXISTS.: |
| 437 | case FORALLcxx . . $ FORALL.: |
| 438 | case GEcxx . . $ GE.: |
| 439 | case LEcxx . . $ LE.: |
| 440 | return isReferencedcxx . . $ TBox#isReferenced(98b03190f111a09d). ( C, tree->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).(), processed ); |
| 441 | |
| 442 | // operations w/o concept |
| 443 | case SELFcxx . . $ SELF.: |
| 444 | case TOPcxx . . $ TOP.: |
| 445 | case BOTTOMcxx . . $ BOTTOM.: |
| 446 | return false; |
| 447 | |
| 448 | // non-concept expressions: should not be here |
| 449 | case INVcxx . . $ INV.: |
| 450 | case RCOMPOSITIONcxx . . $ RCOMPOSITION.: // role composition |
| 451 | case PROJINTOcxx . . $ PROJINTO.: // role projection into |
| 452 | case PROJFROMcxx . . $ PROJFROM.: // role projection from |
| 453 | case DATAEXPRcxx . . $ DATAEXPR.: // any data expression: data value, [constrained] datatype |
| 454 | case RNAMEcxx . . $ RNAME.: |
| 455 | case DNAMEcxx . . $ DNAME.: |
| 456 | fpp_unreachablecxx . . $ `Kernel/fpp_assert.h:49:9`!(); |
| 457 | |
| 458 | default: // just for safety: all possible options were checked |
| 459 | fpp_unreachablecxx . . $ `Kernel/fpp_assert.h:49:9`!(); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | /// transform C [= E with C = D into GCIs |
| 464 | void |
| 465 | TBoxcxx . . $ TBox# :: TransformExtraSubsumptionscxx . . $ TBox#TransformExtraSubsumptions(49f6e7a06ebc5aa8). ( void ) |
| 466 | { |
| 467 | auto p = ExtraConceptDefscxx . . $ TBox#ExtraConceptDefs..begincxx . . $ std/map#begin(fbe2f8c57595edf).(), p_end = ExtraConceptDefscxx . . $ TBox#ExtraConceptDefs..endcxx . . $ std/map#end(fbe2f8c57595edf).(); |
| 468 | |
| 469 | while ( p !=cxx . . $ std/`operator!=`(84f83906d8995b82). p_end ) |
| 470 | { |
| 471 | TConceptcxx . . $ TConcept#* C = p->cxx . . $ std/_Rb_tree_iterator#`operator->`(5a2a78a048fb49a8).firstcxx . . $ std/pair#first.; |
| 472 | DLTreecxx . . $ DLTree#* E = p->cxx . . $ std/_Rb_tree_iterator#`operator->`(5a2a78a048fb49a8).secondcxx . . $ std/pair#second.; |
| 473 | // for every C here we have C = D in KB and C [= E in ExtraConceptDefs |
| 474 | // if there is a cycle for C |
| 475 | if ( isCycliccxx . . $ TBox#isCyclic(78140581f8900ef9).(C) ) |
| 476 | { |
| 477 | DLTreecxx . . $ DLTree#* D = clonecxx . . $ clone(ec41a33c52a5614b).(C->Descriptioncxx . . $ TConcept#Description.); |
| 478 | // then we should make C [= (D and E) and go with GCI D [= C |
| 479 | makeDefinitionPrimitivecxx . . $ TBox#makeDefinitionPrimitive(12a9e5ce3420c48d). ( C, E, D ); |
| 480 | } |
| 481 | else // it is safe to keep definition C = D and go with GCI C [= E |
| 482 | processGCIcxx . . $ TBox#processGCI(237c04ede5740138). ( getTreecxx . . $ TBox#getTree(8f1a6b264b733ed7).(C), E ); |
| 483 | // remove processed entry from the set, reset the pointer |
| 484 | p =cxx . . $ std/_Rb_tree_iterator#`operator=`(821c513420c7cde9). ExtraConceptDefscxx . . $ TBox#ExtraConceptDefs..erasecxx . . $ std/map#erase(9238c2f1608b9ba6).(p); |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | void |
| 489 | TBoxcxx . . $ TBox# :: setAllIndexescxx . . $ TBox#setAllIndexes(49f6e7a06ebc5aa8). ( void ) |
| 490 | { |
| 491 | ++nCcxx . . $ TBox#nC.; // place for the query concept |
| 492 | nRcxx . . $ TBox#nR. = 0; // start with 1 to make index 0 an indicator of "not processed" |
| 493 | auto setRoleIndex = [&] (TRolecxx . . $ TRole#* R) { if ( !R->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() ) R->setIndexcxx . . $ ClassifiableEntry#setIndex(cb2f890c2fdad230).(++nRcxx . . $ TBox#nR.); }; |
| 494 | stdcxx . . $ std/::for_eachcxx . . $ std/for_each(88304b602929f6f4). ( ORMcxx . . $ TBox#ORM..begincxx . . $ RoleMaster#begin(f6b8bc1058fc1c99).(), ORMcxx . . $ TBox#ORM..endcxx . . $ RoleMaster#end(f6b8bc1058fc1c99).(), setRoleIndex ); |
| 495 | stdcxx . . $ std/::for_eachcxx . . $ std/for_each(88304b602929f6f4). ( DRMcxx . . $ TBox#DRM..begincxx . . $ RoleMaster#begin(f6b8bc1058fc1c99).(), DRMcxx . . $ TBox#DRM..endcxx . . $ RoleMaster#end(f6b8bc1058fc1c99).(), setRoleIndex ); |
| 496 | // make nR be a number of indexed roles |
| 497 | ++nRcxx . . $ TBox#nR.; |
| 498 | } |
| 499 | |
| 500 | /// determine all sorts in KB (make job only for SORTED_REASONING) |
| 501 | void TBoxcxx . . $ TBox# :: determineSortscxx . . $ TBox#determineSorts(49f6e7a06ebc5aa8). ( void ) |
| 502 | { |
| 503 | #ifdef RKG_USE_SORTED_REASONINGcxx . . $ `Kernel/globaldef.h:40:9`! |
| 504 | // Related individuals does not appears in DLHeap, |
| 505 | // so their sorts shall be determined explicitly |
| 506 | for ( RelatedCollectioncxx . . $ TBox#RelatedCollection#::const_iteratorcxx . . $ std/vector#const_iterator# p = RelatedIcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0)..begincxx . . $ std/vector#begin(33b10a496a38335b).(), p_end = RelatedIcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0)..endcxx . . $ std/vector#end(33b10a496a38335b).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p, ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 507 | DLHeapcxx . . $ TBox#DLHeap..updateSortscxx . . $ DLDag#updateSorts(f5f2d1ccf66c503). ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->acxx . . $ TRelated#a.->pNamecxx . . $ TConcept#pName., (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->Rcxx . . $ TRelated#R., (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->bcxx . . $ TRelated#b.->pNamecxx . . $ TConcept#pName. ); |
| 508 | |
| 509 | // simple rules needs the same treatment |
| 510 | for ( const auto& rule: SimpleRulescxx . . $ TBox#SimpleRules. ) |
| 511 | { |
| 512 | mergeableLabelcxx . . $ mergeableLabel#& lab = DLHeapcxx . . $ TBox#DLHeap.[cxx . . $ DLDag#`operator[]`(e265d70853dfed20).rule->bpHeadcxx . . $ TBox#TSimpleRule#bpHead.].getSortcxx . . $ DLVertexSort#getSort(e1d2169d387f9f72).(); |
| 513 | for ( const auto& atom: rule->Bodycxx . . $ TBox#TSimpleRule#Body. ) |
| 514 | DLHeapcxx . . $ TBox#DLHeap..mergecxx . . $ DLDag#merge(b399d136bc0b5cf7). ( lab, atom->pNamecxx . . $ TConcept#pName. ); |
| 515 | } |
| 516 | |
| 517 | // create sorts for concept and/or roles |
| 518 | DLHeapcxx . . $ TBox#DLHeap..determineSortscxx . . $ DLDag#determineSorts(553262e3595539a7). ( ORMcxx . . $ TBox#ORM., DRMcxx . . $ TBox#DRM. ); |
| 519 | #endif // RKG_USE_SORTED_REASONING |
| 520 | } |
| 521 | |
| 522 | // Told stuff is used here, so run this AFTER fillTold*() |
| 523 | void TBoxcxx . . $ TBox# :: CalculateStatisticcxx . . $ TBox#CalculateStatistic(49f6e7a06ebc5aa8). ( void ) |
| 524 | { |
| 525 | // skip all statistic if no logging needed |
| 526 | CHECK_LL_RETURNcxx . . $ `Kernel/LeveLogger.h:60:9`!(llAlways); |
| 527 | |
| 528 | unsigned int npFull = 0, nsFull = 0; // number of completely defined concepts |
| 529 | unsigned int nPC = 0, nNC = 0, nSing = 0; // number of primitive, non-prim and singleton concepts |
| 530 | unsigned int nNoTold = 0; // number of concepts w/o told subsumers |
| 531 | |
| 532 | auto getCStat = [&] (const TConceptcxx . . $ TConcept#* C) { |
| 533 | if ( isValidcxx . . $ isValid(83c267b20bac841a).(C->pNamecxx . . $ TConcept#pName.) ) |
| 534 | { |
| 535 | if ( C->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ) |
| 536 | ++nSing; |
| 537 | if ( C->isPrimitivecxx . . $ TConcept#isPrimitive(50ce9a9e25b4a850).() ) |
| 538 | ++nPC; |
| 539 | else if ( C->isNonPrimitivecxx . . $ TConcept#isNonPrimitive(50ce9a9e25b4a850).() ) |
| 540 | ++nNC; |
| 541 | |
| 542 | if ( C->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850). () ) |
| 543 | ++nsFull; |
| 544 | |
| 545 | if ( C->isCompletelyDefinedcxx . . $ ClassifiableEntry#isCompletelyDefined(50ce9a9e25b4a850).() ) |
| 546 | { |
| 547 | if ( C->isPrimitivecxx . . $ TConcept#isPrimitive(50ce9a9e25b4a850).() ) |
| 548 | ++npFull; |
| 549 | } |
| 550 | else |
| 551 | if ( !C->hasToldSubsumerscxx . . $ ClassifiableEntry#hasToldSubsumers(50ce9a9e25b4a850).() ) |
| 552 | ++nNoTold; |
| 553 | } |
| 554 | }; |
| 555 | // calculate statistic for all concepts |
| 556 | stdcxx . . $ std/::for_eachcxx . . $ std/for_each(88304b602929f6f4). ( c_begincxx . . $ TBox#c_begin(23ec1c5bda99ac5d).(), c_endcxx . . $ TBox#c_end(23ec1c5bda99ac5d).(), getCStat ); |
| 557 | // calculate statistic for all individuals |
| 558 | stdcxx . . $ std/::for_eachcxx . . $ std/for_each(88304b602929f6f4). ( i_begincxx . . $ TBox#i_begin(78b5d4d1a9fb506d).(), i_endcxx . . $ TBox#i_end(78b5d4d1a9fb506d).(), getCStat ); |
| 559 | // output all statistics |
| 560 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "There are " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). nPC <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " primitive concepts used\n"; |
| 561 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " of which " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). npFull <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " completely defined\n"; |
| 562 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " and " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). nNoTold <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " has no told subsumers\n"; |
| 563 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "There are " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). nNC <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " non-primitive concepts used\n"; |
| 564 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " of which " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). nsFull <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " synonyms\n"; |
| 565 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "There are " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). nSing <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " individuals or nominals used\n"; |
| 566 | } |
| 567 | |
| 568 | void TBoxcxx . . $ TBox#::RemoveExtraDescriptionscxx . . $ TBox#RemoveExtraDescriptions(49f6e7a06ebc5aa8). ( void ) |
| 569 | { |
| 570 | // remove DLTree* from all named concepts |
| 571 | auto removeDescription = [] (TConceptcxx . . $ TConcept#* C) { C->removeDescriptioncxx . . $ TConcept#removeDescription(49f6e7a06ebc5aa8).(); }; |
| 572 | stdcxx . . $ std/::for_eachcxx . . $ std/for_each(88304b602929f6f4). ( c_begincxx . . $ TBox#c_begin(23ec1c5bda99ac5d).(), c_endcxx . . $ TBox#c_end(23ec1c5bda99ac5d).(), removeDescription ); |
| 573 | stdcxx . . $ std/::for_eachcxx . . $ std/for_each(88304b602929f6f4). ( i_begincxx . . $ TBox#i_begin(78b5d4d1a9fb506d).(), i_endcxx . . $ TBox#i_end(78b5d4d1a9fb506d).(), removeDescription ); |
| 574 | } |
| 575 |