| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2015-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 TRIPLEGATHERER_H |
| 21 | #define TRIPLEGATHERER_Hcxx . . $ `Kernel/TripleGatherer.h:21:9`! |
| 22 | |
| 23 | #include <vector> |
| 24 | #include <string> |
| 25 | #include <functional> |
| 26 | #include "taxVertex.h"cxx . . $ `<file>/Kernel/taxVertex.h`/ |
| 27 | #include "RDF_URIs.h"cxx . . $ `<file>/Kernel/RDF_URIs.h`/ |
| 28 | #include "tIndividual.h"cxx . . $ `<file>/Kernel/tIndividual.h`/ |
| 29 | |
| 30 | void pushTriplecxx . . $ pushTriple(f4d4fc70533161ad).(stdcxx . . $ std/::setcxx . . $ std/set#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>>& triples, const char* subj, const char* role, const char* obj, const char* literal_type = "") |
| 31 | { |
| 32 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> triplecxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 33 | |
| 34 | triple.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(toRdfcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(subj)); |
| 35 | triple.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(toRdfcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(role)); |
| 36 | triple.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(toRdfcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(obj)); |
| 37 | triple.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(literal_typecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 38 | |
| 39 | triples.insertcxx . . $ std/set#insert(411a10a755068dfe).(triple); |
| 40 | } |
| 41 | |
| 42 | class TripleGatherercxx . . $ TripleGatherer# { |
| 43 | stdcxx . . $ std/::setcxx . . $ std/set#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>>* triplescxx . . $ TripleGatherer#triples.; |
| 44 | bool isDirectcxx . . $ TripleGatherer#isDirect.; |
| 45 | const char* roleNamecxx . . $ TripleGatherer#roleName.; |
| 46 | const char* nodeNamecxx . . $ TripleGatherer#nodeName.; |
| 47 | stdcxx . . $ std/::functioncxx . . $ std/function#<bool(const ClassifiableEntrycxx . . $ ClassifiableEntry#*)> filtercxx . . $ TripleGatherer#filter.; |
| 48 | |
| 49 | public: |
| 50 | |
| 51 | TripleGatherercxx . . $ TripleGatherer#TripleGatherer(f3150cd543ce0609).(stdcxx . . $ std/::setcxx . . $ std/set#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>>* triples, bool isDirect, const char* roleName, const char* nodeName) : triplescxx . . $ TripleGatherer#triples.(triples), isDirectcxx . . $ TripleGatherer#isDirect.(isDirect), roleNamecxx . . $ TripleGatherer#roleName.(roleName), nodeNamecxx . . $ TripleGatherer#nodeName.(nodeName) |
| 52 | { |
| 53 | filtercxx . . $ TripleGatherer#filter. =cxx . . $ std/function#`operator=`(4991ca3d6986ddc6). [](const ClassifiableEntrycxx . . $ ClassifiableEntry#*) |
| 54 | { |
| 55 | return true; |
| 56 | }; |
| 57 | } |
| 58 | |
| 59 | TripleGatherercxx . . $ TripleGatherer#TripleGatherer(dbc16e4b8bce4b59).(stdcxx . . $ std/::setcxx . . $ std/set#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>>* triples, bool isDirect, const char* roleName, const char* nodeName, stdcxx . . $ std/::functioncxx . . $ std/function#<bool(const ClassifiableEntrycxx . . $ ClassifiableEntry#*)> filter) : triplescxx . . $ TripleGatherer#triples.(triples), isDirectcxx . . $ TripleGatherer#isDirect.(isDirect), roleNamecxx . . $ TripleGatherer#roleName.(roleName), nodeNamecxx . . $ TripleGatherer#nodeName.(nodeName), filtercxx . . $ TripleGatherer#filter.(filter) |
| 60 | {} |
| 61 | |
| 62 | void clearcxx . . $ TripleGatherer#clear(49f6e7a06ebc5aa8).() |
| 63 | {} |
| 64 | |
| 65 | void addTriplecxx . . $ TripleGatherer#addTriple(25e3a48069a92e6e).(const ClassifiableEntrycxx . . $ ClassifiableEntry#* entry) |
| 66 | { |
| 67 | if (filtercxx . . $ TripleGatherer#filter.(cxx . . $ std/function#`operator()`(39e0826ffb540481).entry)) |
| 68 | { |
| 69 | const char* entityName = toRdfcxx . . $ toRdf(fb58d2e09a2a1ce6).(entry->getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).()); |
| 70 | |
| 71 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> triplecxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 72 | |
| 73 | if (isDirectcxx . . $ TripleGatherer#isDirect.) |
| 74 | pushTriplecxx . . $ pushTriple(f4d4fc70533161ad).(*triplescxx . . $ TripleGatherer#triples., nodeNamecxx . . $ TripleGatherer#nodeName., roleNamecxx . . $ TripleGatherer#roleName., entityName); |
| 75 | else |
| 76 | pushTriplecxx . . $ pushTriple(f4d4fc70533161ad).(*triplescxx . . $ TripleGatherer#triples., entityName, roleNamecxx . . $ TripleGatherer#roleName., nodeNamecxx . . $ TripleGatherer#nodeName.); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | /// taxonomy walking method. |
| 81 | /// @return true if node was processed |
| 82 | /// @return false if node can not be processed in current settings |
| 83 | bool applycxx . . $ TripleGatherer#apply(9e72d36cb75ed014).(const TaxonomyVertexcxx . . $ TaxonomyVertex#& vertex) |
| 84 | { |
| 85 | addTriplecxx . . $ TripleGatherer#addTriple(25e3a48069a92e6e).(vertex.getPrimercxx . . $ TaxonomyVertex#getPrimer(257357278432d96a).()); |
| 86 | |
| 87 | for (const auto& synonym : vertex.synonymscxx . . $ TaxonomyVertex#synonyms(c783afb9bc916663).()) |
| 88 | addTriplecxx . . $ TripleGatherer#addTriple(25e3a48069a92e6e).(synonym); |
| 89 | |
| 90 | return true; |
| 91 | } |
| 92 | }; // TripleGatherer |
| 93 | |
| 94 | #endif |