我正在使用prolog (swipl)实现一个自然语言生成器。
我有一个.txt测试文件,其中包含了我应该能够以这种格式生成的一些短语:
[goal,identify,type_object,animal,object,cat,event,ran away,when,[last,mont],where,[]]
[which,cats,ran away,last,month,?]
[goal,identify,type_object,animal,object,dog,event,ran,when,[last,mont],where,[]]
[which,dogs,ran away,last,year,?]等等..。
我如何使用plunit (或其他什么?)要检查测试文件的所有元素是否都在输出文件中,是否返回true/false?
发布于 2018-12-10 19:04:20
read/1可能是您要寻找的内容:
假设我定义了一个事实p/1
p([a,b,c]).然后,我可以从标准输入和比较中读取一个术语(从|:开始的行由SWI表示为用户输入,您的实现可能有所不同):
?- read(X), p(X).
|: [a,b,c].
X = [a, b, c].
?- read(X), p(X).
|: [].
false.https://stackoverflow.com/questions/53701779
复制相似问题