我想在模板的字符串槽中插入两个变量值,但出现错误。我知道多槽,但它给了我这样的字典输出:
('1.', '§ 2 is amended as follows:')
但我想要这样:
1. § 2 is amended as follows:
https://www.csee.umbc.edu/portal/clips/usersguide/ug4.html在此链接中写道,我们可以将许多变量分配给断言中的一个插槽,但是当我这样做时,我遇到了错误。我在 VSCode 中的 python 中导入剪辑。提前谢谢你,我希望我能正确解释这个问题。这些是规则:
(defrule createlist1
(declare (salience 91))
(ROW (counter ?A)
(ID ?id)
(Text ?t)
(Path "//Document/Sect[3]/Sect/L/LI/Lbl"))
=>
(assert (Temp (tempvalue "YES")
(temptext ?t))))
(defrule createlist2
(declare (salience 91))
(and (Temp (tempvalue "YES")
(temptext ?t))
(ROW (counter ?A)
(ID ?id)
(Text ?text)
(Path "//Document/Sect[3]/Sect/L/LI/LBody/ParagraphSpan")))
=>
(printout t " value is " ?t ?text crlf)
(assert (WordPR (counter ?A)
(structure ?id)
(tag "list")
(style "list")
(text ?t ?text))))
这些是模板:
template_WordPR = """
(deftemplate WordPR
(slot counter (type INTEGER))
(slot structure (type INTEGER))
(slot tag (type STRING))
(slot style (type STRING))
(slot text (type STRING)))
"""
template_temporary = """
(deftemplate Temp
(slot tempvalue (type STRING))
(slot temptext (type STRING)))
"""
template_string = """
(deftemplate ROW
(slot counter (type INTEGER))
(slot ID (type INTEGER))
(slot Text (type STRING))
(slot Path (type STRING)))
"""
这是我得到的错误:
ERROR: The single field slot 'text' can only contain a single field value.