diff --git a/config.pl b/config.pl new file mode 100644 index 0000000000000000000000000000000000000000..93cf11d58d28fc85bfbf10e22766a0fbf2850d68 --- /dev/null +++ b/config.pl @@ -0,0 +1,16 @@ +:- module(config, [ + load_config/2 + ]). + +:- use_module(library(yaml)). + +%! load_config(+Filename, -Config) is det +% +% Load a configuration file. +load_config(Filename, Config) :- + expand_file_name(Filename, [ExpFilename|_]), + absolute_file_name(ExpFilename, AbsFilename), + yaml_read(AbsFilename, Config), + ! + . +load_config(_, nil). diff --git a/wbel.pl b/wbel.pl index 548b59a5b22aaa4fa64361ee399b8ef88ecdda5c..56c242d6a51bacbf263cb883e12d3a8c2da70bc8 100644 --- a/wbel.pl +++ b/wbel.pl @@ -14,6 +14,7 @@ :- use_module(generator). :- use_module(logic). :- use_module(evidence). +:- use_module(config). optspec([ [opt(raw), type(boolean), default(false), shortflags([r]), longflags([raw]), @@ -54,6 +55,8 @@ go :- full_evidence_computation(Opts, PosArgs) :- [BFile, MuFile] = PosArgs, + load_config('~/.wbel.cfg', Config), + set_config(Config), nb_setval(clasppath, '/home/wurbel/local/anaconda3/envs/potassco/bin/clingo'), init_form_atom, init_subform_atom, @@ -128,6 +131,20 @@ test_wbel(Beliefs) :- print_beliefs(Beliefs, Assoc) . +%! set_config(+Config) +set_config(Config) :- + is_dict(Config), + Config.get(clasppath) = ClaspPath, + nb_setval(clasppath, ClaspPath), + ! + . +set_config(_) :- + nb_setval(clasppath, '/home/wurbel/local/anaconda3/envs/potassco/bin/clingo') + . + + + + %! print_raw_beliefs(+Bels) is det print_raw_beliefs([]).