atomspace = AtomSpace()
initialize_opencog(atomspace)
me = ConceptNode("me")
you = ConceptNode("you")
hungry = ConceptNode("hungry")
StateLink(me, hungry)
query = GetLink(
TypedVariableLink(VariableNode("someone"), TypeNode("ConceptNode")),
PresentLink(StateLink(VariableNode("someone"), hungry)))
who_is_hungry = execute_atom(atomspace, query)
print("\nhungry people")
print('expected: (SetLink (ConceptNode "me"))')
print(who_is_hungry)
query1 = GetLink(
TypedVariableLink(VariableNode("someone"), TypeNode("ConceptNode")),
NotLink(PresentLink(StateLink(VariableNode("someone"), hungry))))
who_isnt_hungry1 = execute_atom(atomspace, query1)
print("\nnot hungry people (NotLink (PresentLink ...) )")
print('expected: (SetLink (ConceptNode "you") (ConceptNode "hungry"))')
print(who_isnt_hungry1)
query2 = GetLink(
TypedVariableLink(VariableNode("someone"), TypeNode("ConceptNode")),
AndLink(NotLink(PresentLink(StateLink(VariableNode("someone"), hungry)))))
who_isnt_hungry2 = execute_atom(atomspace, query2)
print("\nnot hungry people (AndLink (NotLink (PresentLink ...)))")
print('expected: (SetLink (ConceptNode "you") (ConceptNode "hungry"))')
print(who_isnt_hungry2)
query3 = GetLink(
TypedVariableLink(VariableNode("someone"), TypeNode("ConceptNode")),
NotLink(AndLink(PresentLink(StateLink(VariableNode("someone"), hungry)))))
who_isnt_hungry3 = execute_atom(atomspace, query3)
print("\nnot hungry people (NotLink (AndLink (PresentLink ...)))")
print('expected: (SetLink (ConceptNode "you") (ConceptNode "hungry"))')
print(who_isnt_hungry3)
query4 = GetLink(
TypedVariableLink(VariableNode("someone"), TypeNode("ConceptNode")),
AbsentLink(StateLink(VariableNode("someone"), hungry)))
who_isnt_hungry4 = execute_atom(atomspace, query4)
print("\nnot hungry people (AbsentLink ...)")
print('expected: (SetLink (ConceptNode "you") (ConceptNode "hungry"))')
print(who_isnt_hungry4)