How to find the best matching fact

I will take that to mean the one that requires the least amount of learning.

Since s(CASP) is so new and still has warts and those using it are finding bugs and discrepancies lets cross s(CASP) off the list.
Since constraint systems require a good understanding of Prolog before one can start to use constraints effectively and AFAIK there is no way to debug constraints as expected with something like gtrace/0 lets cross constraint systems off the list.
Since aggregate_all/4 is a generalisation of the bagof/3, setof/3 and findall/3 built-in predicates one would have to have a basic knowledge of findall/3, lets cross aggregate_all/4 off the list.

The only option left is findall/3.

That is one of the guiding principles I use, get it working first, then go after optimizations.


So you are asking for example code for a recommendation system based on findall/3.

While the Prolog repositories for SWI-Prolog on GitHub are loaded with the use of findall/3, (list) AFAIK none of them are used to implement a recommendation system.

IIRC one of the classic books creates a recommendation system as one of the ending chapters so will have to take a look to verify.

Give me some time while I look.


EDIT

The Art of Prolog - advanced programming techniques by Leon S Sterling, Ehud Y Shapior and David H D Warren (WorldCat )

Chapter 22 - A Credit Evaluation Expert System

The code has one findall/3, is very simple and has an entire chapter to help understand the code.

A free PDF copy can be downloaded under the Open Access section. (ref)
Noah Evans has posted the code on GitHub (code)

3 Likes