我正在尝试从python调用swi-prolog文件。颂歌非常简单,但却出现了这个错误:
Exception AttributeError: 'swipl_qid' in <bound method _QueryWrapper.__del__ of <pyswip.prolog._QueryWrapper object at 0x8fbe26c>> ignored
python:
self.prolog_rule_identify = Prolog()
self.prolog_rule_identify.consult("anstype_rule.pro")
def process_pyswip(self, post_script_link_list,read_str):
for linking in post_script_link_list:
sub_link = re.search('\((.*?)\)',linking).group(1)
linkage = "linkage('"+str(read_str)+"', '"+ str(sub_link) +"')"
self.prolog_rule_identify.assertz(linkage)
prolog_output_subjobj = self.prolog_rule_identify.query("anstype_rule(ANSTYPE)")
prolog:
rule_first_question(QUERY, LINK):-
(
(
writeln(QUERY),
nb_linkval(result , 'Person')
)
).
anstype_rule(ANSTYPE):-
linkage(QUERY, LINK),
(
(
rule_first_question(QUERY, LINK) ->
nb_getval(rule, RULE)
; nb_linkval(rule, 'Man'), nb_getval(rule, RULE)
)
).
错误:
Exception AttributeError: 'swipl_qid' in <bound method _QueryWrapper.__del__ of <pyswip.prolog._QueryWrapper object at 0x8fbe26c>> ignored