| 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 "LogicFeature.h" |
| 21 | #include "logging.h" |
| 22 | #include "dlVertex.h" |
| 23 | #include "tConcept.h" |
| 24 | #include "tRole.h" |
| 25 | |
| 26 | void LogicFeatures :: fillConceptData ( const TConcept* p ) |
| 27 | { |
| 28 | if ( p->isSingleton() ) |
| 29 | setX(lfSingleton); |
| 30 | } |
| 31 | |
| 32 | void LogicFeatures :: fillRoleData ( const TRole* p, bool both ) |
| 33 | { |
| 34 | if ( unlikely(p->isTop()) ) |
| 35 | { |
| 36 | if ( !p->isDataRole() ) |
| 37 | setX(lfTopRole); |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | if ( p->getId() > 0 ) // direct role |
| 42 | setX(lfDirectRoles); |
| 43 | else |
| 44 | setX(lfInverseRoles); |
| 45 | |
| 46 | // inverse roles check |
| 47 | if ( both ) |
| 48 | setX(lfBothRoles); |
| 49 | |
| 50 | // transitivity check |
| 51 | if ( p->isTransitive() ) |
| 52 | setX(lfTransitiveRoles); |
| 53 | |
| 54 | // subsumption check |
| 55 | if ( p->hasToldSubsumers() ) |
| 56 | setX(lfRolesSubsumption); |
| 57 | |
| 58 | // functionality check |
| 59 | if ( p->isFunctional() ) |
| 60 | setX(lfFunctionalRoles); |
| 61 | |
| 62 | // R&D check |
| 63 | if ( p->getBPDomain() != bpTOP || p->getBPRange() != bpTOP ) |
| 64 | setX(lfRangeAndDomain); |
| 65 | } |
| 66 | |
| 67 | void LogicFeatures :: fillDAGData ( const DLVertex& v, bool ) |
| 68 | { |
| 69 | switch ( v.Type () ) |
| 70 | { |
| 71 | case dtForall: |
| 72 | setX(lfSomeConstructor); |
| 73 | break; |
| 74 | |
| 75 | case dtLE: |
| 76 | setX(lfNConstructor); |
| 77 | if ( v.getC() != bpTOP ) |
| 78 | setX(lfQConstructor); |
| 79 | |
| 80 | break; |
| 81 | |
| 82 | case dtPSingleton: |
| 83 | case dtNSingleton: |
| 84 | setX(lfSingleton); |
| 85 | break; |
| 86 | |
| 87 | case dtIrr: |
| 88 | setX(lfSelfRef); |
| 89 | break; |
| 90 | |
| 91 | default: // any other vertex -- nothing to do |
| 92 | break; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | void LogicFeatures :: writeState ( void ) const |
| 97 | { |
| 98 | CHECK_LL_RETURN(llAlways); |
| 99 | LL << "\nLoaded KB used DL with following features:\nKB contains "; |
| 100 | if ( !hasInverseRole () ) |
| 101 | LL << "NO "; |
| 102 | LL << "inverse role(s)\nKB contains "; |
| 103 | if ( !hasRoleHierarchy () ) |
| 104 | LL << "NO "; |
| 105 | LL << "role hierarchy\nKB contains "; |
| 106 | if ( !hasTransitiveRole () ) |
| 107 | LL << "NO "; |
| 108 | LL << "transitive role(s)\nKB contains "; |
| 109 | if ( !hasTopRole () ) |
| 110 | LL << "NO "; |
| 111 | LL << "top role expressions\nKB contains "; |
| 112 | if ( !hasSomeAll () ) |
| 113 | LL << "NO "; |
| 114 | LL << "quantifier(s)\nKB contains "; |
| 115 | if ( !hasFunctionalRestriction () ) |
| 116 | LL << "NO "; |
| 117 | LL << "functional restriction(s)\nKB contains "; |
| 118 | if ( !hasNumberRestriction () ) |
| 119 | LL << "NO "; |
| 120 | else if ( hasQNumberRestriction () ) |
| 121 | LL << "qualified "; |
| 122 | LL << "number restriction(s)\nKB contains "; |
| 123 | if ( !hasSingletons() ) |
| 124 | LL << "NO "; |
| 125 | LL << "nominal(s)\n"; |
| 126 | } |