Debian Codegraph @

FaCT++.Python/lib/Kernel/Actor.h

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2006-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 ACTOR_H
21 #define ACTOR_H
22
23 #include "taxVertex.h"
24 #include "TaxGatheringWalker.h"
25
26 /// class for acting with concept taxonomy
27 class Actor: public TaxGatheringWalker
28 {
29 public: // types
30 /// entry in an output
31 typedef ClassifiableEntry EntryType;
32 /// 1D vector of entries
33 typedef std::vector<const EntryType*> Array1D;
34 /// 2D vector of entries
35 typedef std::vector<Array1D> Array2D;
36
37 protected: // members
38 /// flag to look at concept-like or role-like entities
39 bool isRole = false;
40 /// flag to look at concepts or object roles
41 bool isStandard = true;
42
43 protected: // methods
44 /// check whether actor is applicable to the ENTRY
45 bool applicable ( const EntryType* entry ) const override;
46 /// fills an array with all suitable data from the vertex
47 void fillArray ( const TaxonomyVertex& v, Array1D& array ) const
48 {
49 if ( tryEntry(v.getPrimer()) )
50 array.push_back(v.getPrimer());
51 for ( const auto& synonym: v.synonyms() )
52 if ( tryEntry(synonym) )
53 array.push_back(synonym);
54 }
55
56 public: // interface
57 /// empty c'tor
58 Actor() = default;
59
60 // flags setup
61
62 /// set the actor to look for classes
63 void needConcepts ( void ) { isRole = false; isStandard = true; }
64 /// set the actor to look for individuals
65 void needIndividuals ( void ) { isRole = false; isStandard = false; }
66 /// set the actor to look for object properties
67 void needObjectRoles ( void ) { isRole = true; isStandard = true; }
68 /// set the actor to look for individuals
69 void needDataRoles ( void ) { isRole = true; isStandard = false; }
70
71 // fill structures according to what's in the taxonomy
72
73 /// return data as a 1D-array
74 void getFoundData ( Array1D& array ) const
75 {
76 array.clear();
77 for ( size_t i = 0; i < found.size(); i++ )
78 fillArray ( *found[i], array );
79 }
80 /// return data as a 2D-array
81 void getFoundData ( Array2D& array ) const
82 {
83 array.clear();
84 array.resize(found.size());
85 for ( size_t i = 0; i < found.size(); i++ )
86 fillArray ( *found[i], array[i] );
87 }
88 }; // Actor
89
90 #endif