说明
python inferenceagent示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。
编程语言: Python
命名空间/包名称: plnexamplestuffysmokessmokes_agent
示例#1文件:
smokes_example.py项目:
Counterfly/opencog
data = ["opencog/atomspace/core_types.scm",
"opencog/scm/utilities.scm",
"opencog/python/pln/examples/tuffy/smokes/smokes.scm"]
if EXTRA_DATA:
data.append("opencog/python/pln/examples/tuffy/smokes/extra-data.scm")
for item in data:
load_scm(atomspace, item)
atoms = atomspace.get_atoms_by_type(types.Atom)
for atom in atoms:
print(atom)
MAX_STEPS = 500
chainer = InferenceAgent()
chainer.create_chainer(atomspace=atomspace, stimulate_atoms=False)
answer = False
outputs_produced = 0
for i in range(0, MAX_STEPS):
result = chainer.run(atomspace)
output = None
input = None
rule = None
if result is not None:
(rule, input, output) = result
outputs_produced += 1
示例#2文件:
smokes_example.py项目:
vvanirudh/opencog
data = ["opencog/atomspace/core_types.scm",
"opencog/scm/utilities.scm",
"opencog/python/pln/examples/tuffy/smokes/smokes.scm"]
if EXTRA_DATA:
data.append("opencog/python/pln/examples/tuffy/smokes/extra-data.scm")
for item in data:
load_scm(atomspace, item)
atoms = atomspace.get_atoms_by_type(types.Atom)
for atom in atoms:
print(atom)
MAX_STEPS = 500
chainer = InferenceAgent()
chainer.create_chainer(atomspace=atomspace)
def check_result():
# Searches for EvaluationLinks where the first argument is: PredicateNode
# "cancer" and the target of the predicate is a ConceptNode (representing a
# person)
eval_links = atomspace.get_atoms_by_type(types.EvaluationLink)
num_results = 0
for eval_link in eval_links:
out = [atom for atom in atomspace.get_outgoing(eval_link.h)
if atom.is_a(types.PredicateNode) and atom.name == "cancer"]
if out:
list_link = atomspace.get_outgoing(eval_link.h)[1]