OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FuzzyPatternMatch.cc
Go to the documentation of this file.
1 /*
2  * FuzzyPatternMatch.cc
3  *
4  * Copyright (C) 2015 OpenCog Foundation
5  *
6  * Author: Leung Man Hin <https://github.com/leungmanhin>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Affero General Public License v3 as
10  * published by the Free Software Foundation and including the exceptions
11  * at http://opencog.org/wiki/Licenses
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with this program; if not, write to:
20  * Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
26 
27 #include "FuzzyPatternMatchCB.h"
28 #include "FuzzyPatternMatch.h"
29 
30 using namespace opencog;
31 
32 //#define DEBUG
33 
46  Type rtn_type,
47  const HandleSeq& excl_list)
48 {
49 #ifdef HAVE_GUILE
50  FuzzyPatternMatchCB fpmcb(as, rtn_type, excl_list);
51 
52  HandleSeq terms;
53  terms.push_back(hp);
54 
55  std::set<Handle> no_vars;
56 
57  PatternLinkPtr slp(createPatternLink(no_vars, terms));
58  slp->satisfy(fpmcb);
59 
60 #ifdef DEBUG
61  std::cout << "\n---------- solns ----------\n";
62  for (Handle h : fpmcb.solns) std::cout << h->toShortString();
63 #endif
64 
65  // The result_list contains a list of the grounded expressions.
66  // Turn it into a true list, and return it.
67  Handle gl = as->add_link(LIST_LINK, fpmcb.solns);
68  return gl;
69 #else
70  return Handle::UNDEFINED;
71 #endif
72 }
73 
std::vector< Handle > HandleSeq
a list of handles
Definition: Handle.h:246
virtual std::string toShortString(std::string indent="")=0
#define createPatternLink
Definition: PatternLink.h:188
static const Handle UNDEFINED
Definition: Handle.h:77
std::shared_ptr< PatternLink > PatternLinkPtr
Definition: PatternLink.h:181
unsigned short Type
type of Atoms, represented as short integer (16 bits)
Definition: types.h:40
Handle find_approximate_match(AtomSpace *, const Handle &, Type rtn_type=0, const HandleSeq &excl_list={})
Handle add_link(Type t, const HandleSeq &outgoing, bool async=false)
Definition: AtomSpace.cc:175