From d1839b730c219bf43628b430e97d59666f4d1f67 Mon Sep 17 00:00:00 2001 From: Theofrastos Mantadelis Date: Wed, 6 Oct 2010 12:59:18 +0200 Subject: [PATCH] ProbLog versioning, ProbLog Tabling warning message instead of error --- packages/ProbLog/problog.yap | 5 +-- packages/ProbLog/problog/os.yap | 12 +++++-- packages/ProbLog/problog/print.yap | 47 +++++++++++++++------------- packages/ProbLog/problog/tabling.yap | 9 +++--- 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/packages/ProbLog/problog.yap b/packages/ProbLog/problog.yap index 873c53837..fe47bad99 100644 --- a/packages/ProbLog/problog.yap +++ b/packages/ProbLog/problog.yap @@ -2,8 +2,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2010-10-05 18:15:57 +0200 (Tue, 05 Oct 2010) $ -% $Revision: 4876 $ +% $Date: 2010-10-06 12:56:13 +0200 (Wed, 06 Oct 2010) $ +% $Revision: 4877 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog @@ -249,6 +249,7 @@ non_ground_fact/1, export_facts/1, problog_help/0, + problog_version/0, show_inference/0, problog_dir/1, set_problog_flag/2, diff --git a/packages/ProbLog/problog/os.yap b/packages/ProbLog/problog/os.yap index 6d3f11a14..42bcea592 100644 --- a/packages/ProbLog/problog/os.yap +++ b/packages/ProbLog/problog/os.yap @@ -2,8 +2,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2010-10-05 18:15:57 +0200 (Tue, 05 Oct 2010) $ -% $Revision: 4876 $ +% $Date: 2010-10-06 12:56:13 +0200 (Wed, 06 Oct 2010) $ +% $Revision: 4877 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog @@ -212,6 +212,7 @@ convert_filename_to_working_path/2, convert_filename_to_problog_path/2, concat_path_with_filename/3, + concat_path_with_filename2/3, split_path_file/3, check_existance/1, calc_md5/2]). @@ -249,6 +250,13 @@ concat_path_with_filename(Path, File_Name, Result):- path_seperator(Path_Seperator), atomic_concat([Path_Absolute, Path_Seperator, File_Name], Result). +concat_path_with_filename2(Path, File_Name, Result):- + nonvar(File_Name), + nonvar(Path), + path_seperator(Path_Seperator), + (atomic_concat(Path_Absolute, Path_Seperator, Path) ; Path_Absolute = Path), + atomic_concat([Path_Absolute, Path_Seperator, File_Name], Result). + %======================================================================== %= Calculate the MD5 checksum of +Filename by calling md5sum %= in case m5sum is not installed, try md5, otherwise fail diff --git a/packages/ProbLog/problog/print.yap b/packages/ProbLog/problog/print.yap index 60395b476..70fabd14d 100644 --- a/packages/ProbLog/problog/print.yap +++ b/packages/ProbLog/problog/print.yap @@ -2,8 +2,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2010-10-05 18:15:57 +0200 (Tue, 05 Oct 2010) $ -% $Revision: 4876 $ +% $Date: 2010-10-06 12:56:13 +0200 (Wed, 06 Oct 2010) $ +% $Revision: 4877 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog @@ -222,7 +222,8 @@ show_inference/0, problog_flags/0, problog_flags/1, - problog_help/0]). + problog_help/0, + problog_version/0]). % load library modules :- use_module(library(lists), [member/2]). @@ -231,7 +232,7 @@ % load our own modules :- use_module(flags). :- use_module(variables). -:- use_module(os, [check_existance/1, convert_filename_to_problog_path/2]). +:- use_module(os, [check_existance/1, convert_filename_to_problog_path/2, concat_path_with_filename2/3]). :- use_module(version_control, [get_version/3]). @@ -299,8 +300,7 @@ make_column_format([HC|TC], [HS|TS], Format, Acc):- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% problog_help :- - print_version, - format('~nProbLog inference currently offers the following inference methods:~n',[]), + format('~2nProbLog inference currently offers the following inference methods:~n',[]), show_inference, problog:problog_path(PD), format('~nProbLog directory: ~q~n',[PD]), @@ -314,28 +314,33 @@ problog_help :- nl, flush_output. -print_version :- +problog_version :- + MainProblogFiles = ['problog.yap', 'problog_learning.yap', 'dtproblog.yap'], nl, - print_group_line('Version Information'), - check_existance('problog.yap'), - convert_filename_to_problog_path('problog.yap', Path), - get_version(Path, Version, Revision), - format('~w~35+ Last Modified at:~w~65+Revision:~w~n', ['problog.yap', Version, Revision]), + print_group_line_bold('Version Information'), + print_version(MainProblogFiles, ''), + print_sep_line, convert_filename_to_problog_path('problog', ProblogPath), directory_files(ProblogPath, ProblogFiles), - print_version(ProblogFiles), - print_sep_line. + sort(ProblogFiles, ProblogFilesS), + print_version(ProblogFilesS, 'problog'), + print_sep_line_bold. -print_version([]). -print_version([H|T]):- - atom_concat('.', _, H), !, - print_version(T). -print_version([H|T]):- - atom_concat('problog/', H, FileName), +print_version([], _Path). +print_version([H|T], Path):- + atom_concat(_, '.yap', H), !, + (Path == '' -> + FileName = H + ; + concat_path_with_filename2(Path, H, FileName) + ), + check_existance(FileName), convert_filename_to_problog_path(FileName, FilePath), get_version(FilePath, Version, Revision), format('~w~35+ Last Modified at:~w~65+Revision:~w~n', [FileName, Version, Revision]), - print_version(T). + print_version(T, Path). +print_version([_H|T], Path):- + print_version(T, Path). show_inference :- diff --git a/packages/ProbLog/problog/tabling.yap b/packages/ProbLog/problog/tabling.yap index 3559a446f..7ba047a96 100644 --- a/packages/ProbLog/problog/tabling.yap +++ b/packages/ProbLog/problog/tabling.yap @@ -2,8 +2,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $ -% $Revision: 4838 $ +% $Date: 2010-10-06 12:56:13 +0200 (Wed, 06 Oct 2010) $ +% $Revision: 4877 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog @@ -328,8 +328,9 @@ problog_table(Name/Arity, Module) :- atom_concat(['problog_', Name, '_tabled'], ExactName), % Monte carlo tabling - table(Module:MCName/Arity), - assertz(problog_tabled(Module:Name/Arity)), + catch((table(Module:MCName/Arity), + assertz(problog_tabled(Module:Name/Arity))), _, + (format(user_error, 'Warning: Tabling was not enabled over compilation, montecarlo tabling is disabled!~nPredicate: ~q~n', [Module:MCName/Arity]))), findall(_,( OriginalPred =.. [OriginalName|Args],