本文整理汇总了Python中pln.chainers.Chainer.link方法的典型用法代码示例。如果您正苦于以下问题:Python Chainer.link方法的具体用法?Python Chainer.link怎么用?Python Chainer.link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pln.chainers.Chainer
的用法示例。
在下文中一共展示了Chainer.link方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_predicate_arguments
# 需要导入模块: from pln.chainers import Chainer [as 别名]
# 或者: from pln.chainers.Chainer import link [as 别名]
def get_predicate_arguments(atomspace, predicate_name):
"""
Finds the unique EvaluationLink for a predicate and returns its list
of arguments.
(Adapted from Alex's PLNUnitTester class)
:param atomspace: the atomspace where the predicate should be looked for
:param predicate_name: the name of the predicate
:return: a list of the predicate arguments
"""
chainer = Chainer(atomspace)
var = chainer.new_variable()
predicate = chainer.atomspace.add_node(types.PredicateNode, predicate_name)
template = chainer.link(types.EvaluationLink,
[predicate, var])
queries = chainer.lookup_atoms(template, "")
# The template needs to be removed from the results
queries.remove(template)
if len(queries) != 1:
if predicate_name == "undesired_outputs":
return None
else:
raise ValueError("Predicate {0} must have 1 EvaluationLink"
.format(predicate_name))
return queries[0].out[1].out