0

I'm implementing a natural language generator using prolog (swipl).

I have a .txt test file with some of the phrases I should be able to generate in this format:

[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,?]

and so on...

How can I use plunit (or something else?) to check if all the elements of my test file are in my output file returning true/false?

1 Answers1

1

read/1 might be what you are looking for:

Suppose I define a fact p/1:

p([a,b,c]).

then I can read a term from standard input and compare ( lines starting with |: are denoted as user input by SWI Prolog, your implementation might differ):

?- read(X), p(X).
|: [a,b,c].

X = [a, b, c].

?- read(X), p(X).
|: [].

false.
lambda.xy.x
  • 4,918
  • 24
  • 35
  • That would work if my correct output was the same size as my test. In reality, my teste sample is much smaller. But I like the direction. Thanks! – Dalai Ribeiro Jan 03 '19 at 02:14