OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PatternSCM.cc
Go to the documentation of this file.
1 /*
2  * PatternSCM.cc
3  *
4  * Guile Scheme bindings for the pattern matcher.
5  * Copyright (c) 2008, 2014, 2015 Linas Vepstas <linas@linas.org>
6  */
7 
10 
11 #include "BindLinkAPI.h"
12 #include "PatternMatch.h"
13 #include "PatternSCM.h"
15 
16 
17 using namespace opencog;
18 
19 // ========================================================
20 
21 // XXX HACK ALERT This needs to be static, in order for python to
22 // work correctly. The problem is that python keeps creating and
23 // destroying this class, but it expects things to stick around.
24 // Oh well. I guess that's OK, since the definition is meant to be
25 // for the lifetime of the server, anyway.
26 std::vector<FunctionWrap*> PatternSCM::_binders;
27 
29  ModuleWrap("opencog query")
30 {}
31 
34 void PatternSCM::init(void)
35 {
36  // Run implication, assuming that the argument is a handle to an
37  // BindLink containing variables, a pattern and a rewrite rules.
38  _binders.push_back(new FunctionWrap(bindlink, "cog-bind", "query"));
39 
40  // Identical to do_bindlink above, except that it only returns the
41  // first match.
43  "cog-bind-single", "query"));
44 
45  // Attentional Focus function
46  _binders.push_back(new FunctionWrap(af_bindlink,
47  "cog-bind-af", "query"));
48 
49  // Fuzzy matching.
51  "cog-fuzzy-match", "query"));
52 
53  // A bindlink that return a TV
55  "cog-satisfy", "query"));
56 
57  _binders.push_back(new FunctionWrap(satisfying_set,
58  "cog-satisfying-set", "query"));
59 }
60 
62 {
63 #if PYTHON_BUG_IS_FIXED
64  for (FunctionWrap* pw : _binders)
65  delete pw;
66 #endif
67 }
68 
69 
71 {
72  static PatternSCM patty;
73  patty.module_init();
74 }
void module_init(void)
Definition: SchemeModule.cc:62
static std::vector< FunctionWrap * > _binders
Definition: PatternSCM.h:19
Wrapper class, to invoke misc extension code from guile.
Definition: SchemeModule.h:20
Handle af_bindlink(AtomSpace *, const Handle &)
Definition: Implicator.cc:182
Handle satisfying_set(AtomSpace *, const Handle &)
Definition: Satisfier.cc:86
void opencog_query_init(void)
Definition: PatternSCM.cc:70
TruthValuePtr satisfaction_link(AtomSpace *, const Handle &)
Definition: Satisfier.cc:67
Handle bindlink(AtomSpace *, const Handle &)
Definition: Implicator.cc:156
Handle find_approximate_match(AtomSpace *, const Handle &, Type rtn_type=0, const HandleSeq &excl_list={})
virtual void init(void)
Definition: PatternSCM.cc:34
Handle single_bindlink(AtomSpace *, const Handle &)
Definition: Implicator.cc:171