From d8dd4cab535d850355fa1cf4b615e7378c40eff5 Mon Sep 17 00:00:00 2001 From: Eric Kafe Date: Mon, 19 Feb 2024 08:57:23 +0100 Subject: [PATCH] Use current_predicate/2 instead of current/functor/2 --- pred_format.pl | 18 ------------------ wn2csv.pl | 6 ++---- wn_load.pl | 9 +++++++-- wn_valid.pl | 5 ++--- 4 files changed, 11 insertions(+), 27 deletions(-) delete mode 100644 pred_format.pl diff --git a/pred_format.pl b/pred_format.pl deleted file mode 100644 index dbbdda0..0000000 --- a/pred_format.pl +++ /dev/null @@ -1,18 +0,0 @@ -/* -# https://github.com/ekaf/wordnet-prolog/raw/master/pred_format.pl -(c) 2020 Eric Kafe, CC BY 4.0, https://creativecommons.org/licenses/by/4.0/ -*/ - -/* ------------------------------------------ -Predicate arity and generic argument list ------------------------------------------- */ - -size2list(2,[_,_]). -size2list(3,[_,_,_]). -size2list(4,[_,_,_,_]). -size2list(5,[_,_,_,_,_]). -size2list(6,[_,_,_,_,_,_]). - -pred2arity(P,A,L):- - current_functor(P,A), - size2list(A,L). diff --git a/wn2csv.pl b/wn2csv.pl index 81c2abf..f03da69 100644 --- a/wn2csv.pl +++ b/wn2csv.pl @@ -1,11 +1,10 @@ /* # https://github.com/ekaf/wordnet-prolog/raw/master/wn2csv.pl -(c) 2020 Eric Kafe, CC BY 4.0, https://creativecommons.org/licenses/by/4.0/ +(c) 2020-24 Eric Kafe, CC BY 4.0, https://creativecommons.org/licenses/by/4.0/ SWI-prolog program to convert all WordNet databases to comma-separated CSV files */ -:-consult('pred_format.pl'). :-consult('wn_load.pl'). pred2file(P):- @@ -21,8 +20,7 @@ list2csv([B|T],S1,S2). out2csv(P):- - current_functor(P,A), - pred2arity(P,A,L), + pred2arity(P,_,L), apply(P,L), list2csv(L,'',S), writeln(S), diff --git a/wn_load.pl b/wn_load.pl index 8f18d58..5a44bd9 100644 --- a/wn_load.pl +++ b/wn_load.pl @@ -1,6 +1,6 @@ /* # https://github.com/ekaf/wordnet-prolog/raw/master/wn_load.pl -(c) 2020 Eric Kafe, CC BY 4.0, https://creativecommons.org/licenses/by/4.0/ +(c) 2020-24 Eric Kafe, CC BY 4.0, https://creativecommons.org/licenses/by/4.0/ SWI-prolog program to load all WordNet databases */ @@ -31,10 +31,15 @@ Load WN ------------------------------------------ */ +pred2arity(P,A,L):- + current_predicate(P,Term), + Term =.. [P|L], + length(L,A). + loadpred(P):- swritef(F,'prolog/wn_%w.pl',[P]), consult(F), - current_functor(P,A), + pred2arity(P,A,_), writef('Loaded %w (%w/%w)\n',[F,P,A]). loadwn:- diff --git a/wn_valid.pl b/wn_valid.pl index 47e6701..be962ce 100644 --- a/wn_valid.pl +++ b/wn_valid.pl @@ -1,6 +1,6 @@ /* # https://github.com/ekaf/wordnet-prolog/raw/master/wn_valid.pl -(c) 2020 Eric Kafe, CC BY 4.0, https://creativecommons.org/licenses/by/4.0/ +(c) 2020-24 Eric Kafe, CC BY 4.0, https://creativecommons.org/licenses/by/4.0/ SWI-prolog program testing for some potential issues in WordNet: @@ -67,7 +67,7 @@ member(R,L), swritef(F,'wn_%w.pl',[R]), writef('Checking symmetry in %w relation (%w):\n',[R,F]), - current_functor(R,N), + pred2arity(R,N,_), symrel(N,R), false. symcheck:- @@ -148,7 +148,6 @@ (N>0 -> outdups(N,P); ok). check_duplicates:- - consult('pred_format.pl'), allwn(LR), member(P,LR), pred2arity(P,A,L),