6 Example of how to use the pattern matcher.
7 Based on the following example in the wiki:
8 http://wiki.opencog.org/w/Pattern_matching#The_Simplified_API
11 __author__ =
'Cosmo Harrigan'
13 from opencog.atomspace
import AtomSpace, TruthValue, types, get_type_name
14 from opencog.scheme_wrapper
import load_scm, scheme_eval, scheme_eval_h, __init__
16 atomspace = AtomSpace()
19 data = [
"opencog/atomspace/core_types.scm",
20 "opencog/scm/utilities.scm"]
23 load_scm(atomspace, item)
28 (InheritanceLink (ConceptNode "Frog") (ConceptNode "animal"))
29 (InheritanceLink (ConceptNode "Zebra") (ConceptNode "animal"))
30 (InheritanceLink (ConceptNode "Deer") (ConceptNode "animal"))
31 (InheritanceLink (ConceptNode "Spaceship") (ConceptNode "machine"))
33 scheme_eval_h(atomspace, scheme_animals)
40 ;; The variable to be bound
43 ;; The pattern to be searched for
46 (ConceptNode "animal")
49 ;; The value to be returned.
54 scheme_eval_h(atomspace, scheme_query)
57 result = scheme_eval_h(atomspace,
'(cog-bind find-animals)')
58 print "The result of pattern matching is:\n\n" + str(atomspace[result])