import progressbar
[docs]class Agent(object):
"""Base class for Graphbrain cognitive agents.
These agents perform some change to an hypergraph, either by processing
some external source of information of by inferring new knowledge from
what is already contained in the hypregraph.
"""
def __init__(self):
self.search_pattern = '*'
self.system = None
self.running = False
self.silent = False
[docs] def name(self):
"""Returns the agent's name."""
raise NotImplementedError()
[docs] def languages(self):
"""Returns set of languages supported by the agent, or an empty set
if the agent is language-agnostic.
"""
return set()
[docs] def on_start(self):
"""Called before a cycle of activity is started."""
[docs] def on_end(self):
"""Called at the end of a cycle of activity."""
return []
[docs] def report(self):
"""Produce a report of the agent's activities."""
return ''
[docs] def run(self):
"""High-level method to run an agent."""
for op in self.input():
yield op