| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2011-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 | #ifndef KNOWLEDGEEXPLORER_H |
| 21 | #define KNOWLEDGEEXPLORER_Hcxx . . $ `Kernel/KnowledgeExplorer.h:21:9`! |
| 22 | |
| 23 | #include "taxNamEntry.h"cxx . . $ `<file>/Kernel/taxNamEntry.h`/ |
| 24 | #include "tDag2Interface.h"cxx . . $ `<file>/Kernel/tDag2Interface.h`/ |
| 25 | |
| 26 | // forward declarations |
| 27 | class TBoxcxx . . $ TBox#; |
| 28 | class DlCompletionTreecxx . . $ DlCompletionTree#; |
| 29 | |
| 30 | /// class to perform a knowledge exploration |
| 31 | class KnowledgeExplorercxx . . $ KnowledgeExplorer# |
| 32 | { |
| 33 | public: // types |
| 34 | /// type for the node in the completion graph |
| 35 | typedef const DlCompletionTreecxx . . $ DlCompletionTree# TCGNodecxx . . $ KnowledgeExplorer#TCGNode#; |
| 36 | /// type for the node vector |
| 37 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<TCGNodecxx . . $ KnowledgeExplorer#TCGNode#*> TCGNodeVeccxx . . $ KnowledgeExplorer#TCGNodeVec#; |
| 38 | /// type for a set of role expressions (used in KE to return stuff) |
| 39 | typedef stdcxx . . $ std/::setcxx . . $ std/set#<const TDLRoleExpressioncxx . . $ TDLRoleExpression#*> TCGRoleSetcxx . . $ KnowledgeExplorer#TCGRoleSet#; |
| 40 | /// type for a vector of data/concept expressions (used in KE to return stuff) |
| 41 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<const TDLExpressioncxx . . $ TDLExpression#*> TCGItemVeccxx . . $ KnowledgeExplorer#TCGItemVec#; |
| 42 | |
| 43 | protected: // classes |
| 44 | /// class that maps named entity to a set of ENTITIES |
| 45 | template <typename Entity> |
| 46 | class EE2Mapcxx . . $ KnowledgeExplorer#EE2Map# |
| 47 | { |
| 48 | public: // type interface |
| 49 | /// set of entities |
| 50 | typedef stdcxx . . $ std/::setcxx . . $ std/set#<const Entity*> ESetcxx . . $ KnowledgeExplorer#EE2Map#ESet#; |
| 51 | /// RO iterator to the ESet |
| 52 | typedef typename ESetcxx . . $ KnowledgeExplorer#EE2Map#ESet#::const_iterator iteratorcxx . . $ KnowledgeExplorer#EE2Map#iterator#; |
| 53 | protected: // members |
| 54 | /// the map itself |
| 55 | stdcxx . . $ std/::mapcxx . . $ std/map#<const TNamedEntitycxx . . $ TNamedEntity#*, ESetcxx . . $ KnowledgeExplorer#EE2Map#ESet#> Basecxx . . $ KnowledgeExplorer#EE2Map#Base.; |
| 56 | public: // interface |
| 57 | /// @return true if the entry does not have correspondent entity |
| 58 | bool checkcxx . . $ KnowledgeExplorer#EE2Map#check(d8a4b25e330b0b26). ( const TNamedEntrycxx . . $ TNamedEntry#* e ) const; |
| 59 | /// add an entity corresponding E to a map corresponding to E0 |
| 60 | void addcxx . . $ KnowledgeExplorer#EE2Map#add(7de3045f6c49d346). ( const TNamedEntrycxx . . $ TNamedEntry#* e0, const TNamedEntrycxx . . $ TNamedEntry#* e ) |
| 61 | { |
| 62 | // check for artificial constructions |
| 63 | if ( checkcxx . . $ KnowledgeExplorer#EE2Map#check(d8a4b25e330b0b26).(e) || checkcxx . . $ KnowledgeExplorer#EE2Map#check(d8a4b25e330b0b26).(e0) ) |
| 64 | return; |
| 65 | const TNamedEntitycxx . . $ TNamedEntity#* E0 = e0->getEntitycxx . . $ TNamedEntry#getEntity(1a59bfca6295ee56).(), *E = e->getEntitycxx . . $ TNamedEntry#getEntity(1a59bfca6295ee56).(); |
| 66 | Basecxx . . $ KnowledgeExplorer#EE2Map#Base.[E0].insert(dynamic_cast<const Entity*>(E)); |
| 67 | } |
| 68 | /// get the set corresponding to the entity E |
| 69 | const ESetcxx . . $ KnowledgeExplorer#EE2Map#ESet#& getcxx . . $ KnowledgeExplorer#EE2Map#get(83699c30cd468111). ( const TNamedEntitycxx . . $ TNamedEntity#* e ) { return Basecxx . . $ KnowledgeExplorer#EE2Map#Base.[e]; } |
| 70 | /// get the begin iterator of a set corresponding to the entity E |
| 71 | iteratorcxx . . $ KnowledgeExplorer#EE2Map#iterator# begincxx . . $ KnowledgeExplorer#EE2Map#begin(52c0680aa71ec21c). ( const TNamedEntitycxx . . $ TNamedEntity#* e ) { return Basecxx . . $ KnowledgeExplorer#EE2Map#Base.[e].begin(); } |
| 72 | /// get the end iterator of a set corresponding to the entity E |
| 73 | iteratorcxx . . $ KnowledgeExplorer#EE2Map#iterator# endcxx . . $ KnowledgeExplorer#EE2Map#end(52c0680aa71ec21c). ( const TNamedEntitycxx . . $ TNamedEntity#* e ) { return Basecxx . . $ KnowledgeExplorer#EE2Map#Base.[e].end(); } |
| 74 | }; // EE2Map |
| 75 | |
| 76 | protected: // members |
| 77 | /// map concept into set of its synonyms |
| 78 | EE2Mapcxx . . $ KnowledgeExplorer#EE2Map#<TDLConceptNamecxx . . $ TDLConceptName#> Cscxx . . $ KnowledgeExplorer#Cs.; |
| 79 | /// map individual into set of its synonyms |
| 80 | EE2Mapcxx . . $ KnowledgeExplorer#EE2Map#<TDLIndividualNamecxx . . $ TDLIndividualName#> Iscxx . . $ KnowledgeExplorer#Is.; |
| 81 | /// map object role to the set of its super-roles (self included) |
| 82 | EE2Mapcxx . . $ KnowledgeExplorer#EE2Map#<TDLObjectRoleNamecxx . . $ TDLObjectRoleName#> ORscxx . . $ KnowledgeExplorer#ORs.; |
| 83 | /// map data role to the set of its super-roles (self included) |
| 84 | EE2Mapcxx . . $ KnowledgeExplorer#EE2Map#<TDLDataRoleNamecxx . . $ TDLDataRoleName#> DRscxx . . $ KnowledgeExplorer#DRs.; |
| 85 | /// dag-2-interface translator used in knowledge exploration |
| 86 | TDag2Interfacecxx . . $ TDag2Interface# D2Icxx . . $ KnowledgeExplorer#D2I.; |
| 87 | /// node vector to return |
| 88 | TCGNodeVeccxx . . $ KnowledgeExplorer#TCGNodeVec# Nodescxx . . $ KnowledgeExplorer#Nodes.; |
| 89 | /// role set to return |
| 90 | TCGRoleSetcxx . . $ KnowledgeExplorer#TCGRoleSet# Rolescxx . . $ KnowledgeExplorer#Roles.; |
| 91 | /// concept vector to return |
| 92 | TCGItemVeccxx . . $ KnowledgeExplorer#TCGItemVec# Conceptscxx . . $ KnowledgeExplorer#Concepts.; |
| 93 | |
| 94 | protected: // methods |
| 95 | /// adds an entity as a synonym to a map MAP |
| 96 | template <typename Entity> |
| 97 | void addEcxx . . $ KnowledgeExplorer#addE(8713993980bcfba1). ( EE2Mapcxx . . $ KnowledgeExplorer#EE2Map#<Entity>& map, const ClassifiableEntrycxx . . $ ClassifiableEntry#* entry ) |
| 98 | { |
| 99 | map.addcxx . . $ KnowledgeExplorer#EE2Map#add(7de3045f6c49d346).(entry,entry); |
| 100 | if ( entry->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() ) |
| 101 | map.addcxx . . $ KnowledgeExplorer#EE2Map#add(7de3045f6c49d346). ( entry->getSynonymcxx . . $ ClassifiableEntry#getSynonym(106bdcbfaabaf9a3).(), entry ); |
| 102 | } |
| 103 | /// add concept-like expression E (possibly with synonyms) to CONCEPTS |
| 104 | void addCcxx . . $ KnowledgeExplorer#addC(ca1ea7df707d7472). ( const TDLExpressioncxx . . $ TDLExpression#* e ); |
| 105 | |
| 106 | public: // interface |
| 107 | /// init c'tor |
| 108 | KnowledgeExplorercxx . . $ KnowledgeExplorer#KnowledgeExplorer(e073bc3a62cf46ea). ( const TBoxcxx . . $ TBox#* box, TExpressionManagercxx . . $ TExpressionManager#* pEM ); |
| 109 | |
| 110 | /// @return the set of data neighbours of a NODE |
| 111 | const TCGRoleSetcxx . . $ KnowledgeExplorer#TCGRoleSet#& getDataRolescxx . . $ KnowledgeExplorer#getDataRoles(106d2ee0a895843a). ( const TCGNodecxx . . $ KnowledgeExplorer#TCGNode#* node, bool onlyDet ); |
| 112 | /// @return the set of object neighbours of a NODE |
| 113 | const TCGRoleSetcxx . . $ KnowledgeExplorer#TCGRoleSet#& getObjectRolescxx . . $ KnowledgeExplorer#getObjectRoles(d53edb8dd44149b1). ( const TCGNodecxx . . $ KnowledgeExplorer#TCGNode#* node, bool onlyDet, bool needIncoming ); |
| 114 | /// @return the set of neighbours of a NODE via role ROLE |
| 115 | const TCGNodeVeccxx . . $ KnowledgeExplorer#TCGNodeVec#& getNeighbourscxx . . $ KnowledgeExplorer#getNeighbours(a01bc3e0a8487b5d). ( const TCGNodecxx . . $ KnowledgeExplorer#TCGNode#* node, const TRolecxx . . $ TRole#* role ); |
| 116 | /// @return the set of all the expressions from the NODE label |
| 117 | const TCGItemVeccxx . . $ KnowledgeExplorer#TCGItemVec#& getLabelcxx . . $ KnowledgeExplorer#getLabel(696fa028d0583acd). ( const TCGNodecxx . . $ KnowledgeExplorer#TCGNode#* node, bool onlyDet ); |
| 118 | /// @return blocker of a blocked node NODE or NULL if node is not blocked |
| 119 | const TCGNodecxx . . $ KnowledgeExplorer#TCGNode#* getBlockercxx . . $ KnowledgeExplorer#getBlocker(86f029545115fbc6). ( const TCGNodecxx . . $ KnowledgeExplorer#TCGNode#* node ) const; |
| 120 | }; // KnowledgeExplorer |
| 121 | |
| 122 | #endif |