Debian Codegraph @

Kernel/Taxonomy.h

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 #ifndef TAXONOMY_H
21 #define TAXONOMY_Hcxx . . $ `Kernel/Taxonomy.h:21:9`!
22
23 // taxonomy graph for DL
24
25 #include "taxVertex.h"cxx . . $ `<file>/Kernel/taxVertex.h`/
26 #include "WalkerInterface.h"cxx . . $ `<file>/Kernel/WalkerInterface.h`/
27
28 class SaveLoadManagercxx . . $ SaveLoadManager#;
29
30 class Taxonomycxx . . $ Taxonomy#
31 {
32 protected: // typedefs
33 /// type for a vector of TaxVertex
34 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<TaxonomyVertexcxx . . $ TaxonomyVertex#*> TaxVertexVeccxx . . $ Taxonomy#TaxVertexVec#;
35
36 protected: // members
37 /// array of taxonomy vertices
38 TaxVertexVeccxx . . $ Taxonomy#TaxVertexVec# Graphcxx . . $ Taxonomy#Graph.;
39 /// vertex with parent Top and child Bot, represents the fresh entity
40 TaxonomyVertexcxx . . $ TaxonomyVertex# FreshNodecxx . . $ Taxonomy#FreshNode.;
41
42 /// labeller for marking nodes as checked
43 TLabellercxx . . $ TLabeller# visitedLabelcxx . . $ Taxonomy#visitedLabel.;
44 /// aux vertex to be included to taxonomy
45 TaxonomyVertexcxx . . $ TaxonomyVertex#* Currentcxx . . $ Taxonomy#Current.;
46
47 /// behaviour flag: if true, insert temporary vertex into taxonomy
48 bool willInsertIntoTaxonomycxx . . $ Taxonomy#willInsertIntoTaxonomy. = true;
49
50 public: // classification interface
51
52 //-----------------------------------------------------------------
53 //-- General classification support
54 //-----------------------------------------------------------------
55
56 /// @return true if current entry is a synonym of an already classified one
57 bool processSynonymcxx . . $ Taxonomy#processSynonym(c9857a73d68e59ba). ( void );
58 /// add current entry to a synonym SYN
59 void addCurrentToSynonymcxx . . $ Taxonomy#addCurrentToSynonym(ea5ea6ad7488bb8a). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* syn );
60 /// remove node from the taxonomy; assume no references to the node
61 void removeNodecxx . . $ Taxonomy#removeNode(ea5ea6ad7488bb8a). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* node ) { node->setInUsecxx . . $ TaxonomyVertex#setInUse(b45ddcbc8423892c).(false); }
62 /// insert current node either directly or as a synonym
63 void finishCurrentNodecxx . . $ Taxonomy#finishCurrentNode(49f6e7a06ebc5aa8). ( void );
64
65 /// @return true if taxonomy works in a query mode (no need to insert query vertex)
66 bool queryModecxx . . $ Taxonomy#queryMode(50ce9a9e25b4a850). ( void ) const { return !willInsertIntoTaxonomycxx . . $ Taxonomy#willInsertIntoTaxonomy.; }
67
68 /// set node NODE as checked within taxonomy
69 void setVisitedcxx . . $ Taxonomy#setVisited(1e85185f4f4810e2). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* node ) const { node->setCheckedcxx . . $ TaxonomyVertex#setChecked(9ce72ecab6fc8b2b).(visitedLabelcxx . . $ Taxonomy#visitedLabel.); }
70 /// check whether NODE is checked within taxonomy
71 bool isVisitedcxx . . $ Taxonomy#isVisited(5273acd5b7b596a5). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* node ) const { return node->isCheckedcxx . . $ TaxonomyVertex#isChecked(cb76649e174af24).(visitedLabelcxx . . $ Taxonomy#visitedLabel.); }
72 /// clear the CHECKED label from all the taxonomy vertex
73 void clearVisitedcxx . . $ Taxonomy#clearVisited(49f6e7a06ebc5aa8). ( void ) { visitedLabelcxx . . $ Taxonomy#visitedLabel..newLabelcxx . . $ TLabeller#newLabel(49f6e7a06ebc5aa8).(); }
74
75 /// call this method after taxonomy is built
76 void finalisecxx . . $ Taxonomy#finalise(49f6e7a06ebc5aa8). ( void );
77 /// unlink the bottom from the taxonomy
78 void deFinalisecxx . . $ Taxonomy#deFinalise(49f6e7a06ebc5aa8). ( void );
79
80 protected: // methods
81 /// apply ACTOR to subgraph starting from NODE as defined by flags
82 template<bool onlyDirect, bool upDirection, class Actor>
83 void getRelativesInfoReccxx . . $ Taxonomy#getRelativesInfoRec(9884b8d7edde0234). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* node, Actor& actor )
84 {
85 // recursive applicability checking
86 if ( isVisitedcxx . . $ Taxonomy#isVisited(5273acd5b7b596a5).(node) )
87 return;
88
89 // label node as visited
90 setVisitedcxx . . $ Taxonomy#setVisited(1e85185f4f4810e2).(node);
91
92 // if current node processed OK and there is no need to continue -- exit
93 // if node is NOT processed for some reasons -- go to another level
94 if ( actor.apply(*node) && onlyDirect )
95 return;
96
97 // apply method to the proper neighbours with proper parameters
98 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = node->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(upDirection), p_end = node->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(upDirection); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
99 getRelativesInfoReccxx . . $ Taxonomy#getRelativesInfoRec(9884b8d7edde0234).<onlyDirect, upDirection> ( *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p, actor );
100 }
101
102 public: // interface
103 /// init c'tor
104 Taxonomycxx . . $ Taxonomy#Taxonomy(d190bd46de14e314). ( const ClassifiableEntrycxx . . $ ClassifiableEntry#* pTop, const ClassifiableEntrycxx . . $ ClassifiableEntry#* pBottom )
105 : Currentcxx . . $ Taxonomy#Current.(new TaxonomyVertexcxx . . $ TaxonomyVertex#TaxonomyVertex(49f6e7a06ebc5aa8).())
106 {
107 Graphcxx . . $ Taxonomy#Graph..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70). (new TaxonomyVertexcxx . . $ TaxonomyVertex#TaxonomyVertex(25e3a48069a92e6e).(pBottom)); // bottom
108 Graphcxx . . $ Taxonomy#Graph..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70). (new TaxonomyVertexcxx . . $ TaxonomyVertex#TaxonomyVertex(25e3a48069a92e6e).(pTop)); // top
109 // set up fresh node
110 FreshNodecxx . . $ Taxonomy#FreshNode..addNeighbourcxx . . $ TaxonomyVertex#addNeighbour(93beaa2f49a74c7). ( /*upDirection=*/true, getTopVertexcxx . . $ Taxonomy#getTopVertex(16f9ca5fa66f7d36).() );
111 FreshNodecxx . . $ Taxonomy#FreshNode..addNeighbourcxx . . $ TaxonomyVertex#addNeighbour(93beaa2f49a74c7). ( /*upDirection=*/false, getBottomVertexcxx . . $ Taxonomy#getBottomVertex(16f9ca5fa66f7d36).() );
112 }
113 /// no copy c'tor
114 Taxonomycxx . . $ Taxonomy#Taxonomy(c4f4f096ee00d9b6). ( const Taxonomycxx . . $ Taxonomy#& ) = delete;
115 /// no assignment
116 Taxonomycxx . . $ Taxonomy#& operatorcxx . . $ Taxonomy#`operator=`(56814b95e00da12c). = ( const Taxonomycxx . . $ Taxonomy#& ) = delete;
117 /// d'tor
118 ~cxx . . $ Taxonomy#`~Taxonomy`(49f6e7a06ebc5aa8).Taxonomycxx . . $ Taxonomy#();
119
120 //------------------------------------------------------------------------------
121 //-- Access to taxonomy entries
122 //------------------------------------------------------------------------------
123
124 /// special access to TOP of taxonomy
125 TaxonomyVertexcxx . . $ TaxonomyVertex#* getTopVertexcxx . . $ Taxonomy#getTopVertex(16f9ca5fa66f7d36). ( void ) const { return *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).(Graphcxx . . $ Taxonomy#Graph..begincxx . . $ std/vector#begin(359ca5030082c9f).()+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).1); }
126 /// special access to BOTTOM of taxonomy
127 TaxonomyVertexcxx . . $ TaxonomyVertex#* getBottomVertexcxx . . $ Taxonomy#getBottomVertex(16f9ca5fa66f7d36). ( void ) const { return *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).Graphcxx . . $ Taxonomy#Graph..begincxx . . $ std/vector#begin(359ca5030082c9f).(); }
128 /// get node for fresh entity E
129 TaxonomyVertexcxx . . $ TaxonomyVertex#* getFreshVertexcxx . . $ Taxonomy#getFreshVertex(cb64ec330cc81472). ( const ClassifiableEntrycxx . . $ ClassifiableEntry#* e ) { FreshNodecxx . . $ Taxonomy#FreshNode..setSamplecxx . . $ TaxonomyVertex#setSample(c310a0381288b48e).(e,false); return &FreshNodecxx . . $ Taxonomy#FreshNode.; }
130 /// get RW access to current
131 TaxonomyVertexcxx . . $ TaxonomyVertex#* getCurrentcxx . . $ Taxonomy#getCurrent(e005a88f538258f6). ( void ) { return Currentcxx . . $ Taxonomy#Current.; }
132 /// get RO access to current
133 const TaxonomyVertexcxx . . $ TaxonomyVertex#* getCurrentcxx . . $ Taxonomy#getCurrent(235d4e6d7932df19). ( void ) const { return Currentcxx . . $ Taxonomy#Current.; }
134 /// set current to a given node
135 void setCurrentcxx . . $ Taxonomy#setCurrent(ea5ea6ad7488bb8a). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* cur ) { Currentcxx . . $ Taxonomy#Current. = cur; }
136
137 /// apply ACTOR to subgraph starting from NODE as defined by flags;
138 template<bool needCurrent, bool onlyDirect, bool upDirection, class Actor>
139 void getRelativesInfocxx . . $ Taxonomy#getRelativesInfo(e811dd8058b26e1c). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* node, Actor& actor )
140 {
141 // if current node processed OK and there is no need to continue -- exit
142 // this is the helper to the case like getDomain():
143 // if there is a named concept that represent's a domain -- that's what we need
144 if ( needCurrent )
145 if ( actor.apply(*node) && onlyDirect )
146 return;
147
148 for ( TaxonomyVertexcxx . . $ TaxonomyVertex#::iteratorcxx . . $ TaxonomyVertex#iterator# p = node->begincxx . . $ TaxonomyVertex#begin(98265602f6db0361).(upDirection), p_end = node->endcxx . . $ TaxonomyVertex#end(98265602f6db0361).(upDirection); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
149 getRelativesInfoReccxx . . $ Taxonomy#getRelativesInfoRec(9884b8d7edde0234).<onlyDirect, upDirection> ( *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p, actor );
150
151 clearVisitedcxx . . $ Taxonomy#clearVisited(49f6e7a06ebc5aa8).();
152 }
153
154 // taxonomy info access
155
156 /// print taxonomy info to a stream
157 void printcxx . . $ Taxonomy#print(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const;
158
159 // save/load interface; implementation is in SaveLoad.cpp
160
161 /// save entry
162 void Savecxx . . $ Taxonomy#Save(ba6c946c98e44172). ( SaveLoadManagercxx . . $ SaveLoadManager#& m, const stdcxx . . $ std/::setcxx . . $ std/set#<const TNamedEntrycxx . . $ TNamedEntry#*>& excluded ) const;
163 /// load entry
164 void Loadcxx . . $ Taxonomy#Load(da67b8e43f9c9b96). ( SaveLoadManagercxx . . $ SaveLoadManager#& m );
165 }; // Taxonomy
166
167 #endif // TAXONOMY_H