This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/CLPBN/benchmarks/workshop_attrs/gen_attrs.sh

40 lines
1014 B
Bash
Executable File

#!/home/tgomes/bin/yap -L --
:- use_module(library(lists)).
:- initialization(main).
main :-
unix(argv(Args)),
nth(1, Args, NP), % number of invitees
nth(2, Args, NA), % number of attributes
atomic_concat(['p', NP , 'attrs', NA, '.yap'], FileName),
open(FileName, 'write', S),
atom_number(NP, NP2),
atom_number(NA, NA2),
generate_people(S, NP2, 1),
write(S, '\n'),
generate_attrs(S, NA2, 7),
write(S, '\n'),
close(S).
generate_people(S, N, Counting) :-
Counting > N, !.
generate_people(S, N, Counting) :-
format(S, 'person(p~w).~n', [Counting]),
Counting1 is Counting + 1,
generate_people(S, N, Counting1).
generate_attrs(S, N, Counting) :-
Counting > N, !.
generate_attrs(S, N, Counting) :-
%format(S, 'person(p~w).~n', [Counting]),
format(S, 'markov attends(P)::[t,f], attr~w::[t,f]', [Counting]),
format(S, '; [0.7, 0.3, 0.3, 0.3] ; [person(P)].~n',[]),
Counting1 is Counting + 1,
generate_attrs(S, N, Counting1).