Important: The CogServer must be running in the background and the REST API must be loaded before running this notebook.
%%capture
import opencog as opencog
server = opencog.Server()
#server.start()
opencog.clear_atomspace()
opencog.load_scheme_files(["python/pln/examples/tuffy/smokes/smokes.scm"])
print("The atomspace contains {0} atoms.".format(len(opencog.atomspace())))
The atomspace contains 46 atoms.
atomspace = opencog.atomspace()
for handle, atom in atomspace.iteritems():
if atom['type'] == 'ConceptNode':
print("ConceptNode #{0} is '{1}'".
format(handle, atom['name']))
if atom['type'] == 'EvaluationLink':
print("EvaluationLink #{0} refers to a predicate '{1}'".
format(handle, atomspace[atom['outgoing'][0]]['name']))
ConceptNode #60 is 'Anna' ConceptNode #61 is 'Bob' ConceptNode #62 is 'Edward' ConceptNode #63 is 'Frank' ConceptNode #64 is 'Gary' ConceptNode #65 is 'Helen' EvaluationLink #68 refers to a predicate 'smokes' EvaluationLink #69 refers to a predicate 'cancer' EvaluationLink #74 refers to a predicate 'friends' EvaluationLink #76 refers to a predicate 'smokes' EvaluationLink #78 refers to a predicate 'smokes' EvaluationLink #82 refers to a predicate 'friends' EvaluationLink #84 refers to a predicate 'friends' EvaluationLink #86 refers to a predicate 'friends' EvaluationLink #88 refers to a predicate 'friends' EvaluationLink #90 refers to a predicate 'friends' EvaluationLink #92 refers to a predicate 'smokes' EvaluationLink #94 refers to a predicate 'smokes' EvaluationLink #97 refers to a predicate 'cancer' EvaluationLink #100 refers to a predicate 'cancer'
print("This atom is of type {0}".
format(opencog.scheme('(cog-type (ConceptNode "Bob"))')))
This atom is of type ConceptNode
import graphics
graphics.render_image(opencog.dump_atomspace_dot(), 1)
from IPython.core.display import Image
Image(filename='images/00001.png', width=500)