SWI Prolog and knowledge graphs

Yes, I filed an issue computation of the metrics · Issue #7 · symbolic-kg/PyClause · GitHub

The reason for the discrepancy is that PyClause adopts object identity: it does not allow any two distinct variable in a clause to take the same value.

With this condition, I get with lp4kg/wn18rr/confidenceoi.pl at fd866664fa9ff859c3459d9663c7d56386f5b46b · friguzzi/lp4kg · GitHub
the same results as PyClause for confidence.

From Anytime bottom-up rule learning for large-scale knowledge graph completion | The VLDB Journal
image

1 Like

concurrent_maplist. When did these kind of predicates enter the language?

concurrent_maplist/2 was added 2012-01-15; the various concurrency predicates are older. (I found one commit that referenced concurrent/3 dated 2007-06-27; the multi-threading support appears to have been added in mid-1999.)

1 Like

Hi all,
I’m trying to use findnsols/3 for finding only 100 answers for a KG completion task.
However, I have found a case where there are 3 answers but findnsols(100,…) finds 0.
A file to reproduce it is at lp4kg/fbk237/bug.pl at b85ee8a89e2d1cfb465b456132c5599fe3ea2310 · friguzzi/lp4kg · GitHub
by calling mainfa(Ans) you get all answers, by calling mainfn(Ans) you get the first 100 solutions.
Unfortunately, the first query returns 3 answers, while the latter 0.
How is it possible?

Fabrizio

The sort could be removing duplicates (resulting in potentially 1 element, for example), and filter_atoms could be filtering out the remainder.

Look at the result of findnsols/4 itself.

You’re right, the problem was in sorting.
However, how to find n distinct solutions?

Anything that can reduce the number of solutions should be inside the findnsols/4 (i.e. being called by it) rather than after it.

Here is my stab at it

I think you are looking for distinct/2. Unfortunately it is rather slow, using a Prolog base hash-table and non-backtrackable destructive assignment. Possibly we should add a fast version using all available low-level tricks.

In the end I implemented a solution using asserts for checking uniqueness and the number of solutions. However, I got different results using maplist and concurrent_maplist, see the post Difference in success between maplist and concurrent_maplist