accurator/commit
Filter already annotated from random list.
author | Chris Dijkshoorn |
---|---|
Sat Oct 3 10:03:53 2015 +0200 | |
committer | Chris Dijkshoorn |
Sat Oct 3 10:03:53 2015 +0200 | |
commit | 2e87913d7bd0332ee69bf9b19c64e5e5266d8da7 |
tree | fd34520fb5afdc9c6d4311c9b3f27d6925d33f21 |
parent | f126c85164b28b00ba35eb7befaeab6f06f95e30 |
Diff style: patch stat
diff --git a/lib/accurator/accurator_user.pl b/lib/accurator/accurator_user.pl index b12f66f..05b2d24 100644 --- a/lib/accurator/accurator_user.pl +++ b/lib/accurator/accurator_user.pl @@ -1,10 +1,11 @@ :- module(accurator_user, [get_annotated/2, - get_domain/2, - get_locale/2, - register_user/1, - get_user/1, - get_user_settings/1, - save_user_info/1]). + get_annotated_user/2, + get_domain/2, + get_locale/2, + register_user/1, + get_user/1, + get_user_settings/1, + save_user_info/1]). /** <module> Domain */ @@ -18,19 +19,23 @@ %% get_annotated(-Dic, +Options) % -% Query for a list of artworks the user recently annotated. +% Query for a list of artworks the user recently annotated and return +% dict get_annotated(Dic, Options) :- option(user(User), Options), - setof(Uri, Annotation^User^ - ( rdf(Annotation, oa:annotatedBy, User), - rdf(Annotation, oa:hasTarget, Uri), - rdf(Uri, rdf:type, edm:'ProvidedCHO')), - Uris), - !, + get_annotated_user(User, Uris), Dic = artworks{uris:Uris}. -get_annotated(Dic, _Options) :- - Dic = artworks{uris:[]}. +%% get_annotated(+User, -AnnotatedUris) +% +% Query for a list of artworks the user recently annotated. +get_annotated_user(User, Uris) :- + setof(Uri, Annotation^User^ + ( rdf(Annotation, oa:annotatedBy, User), + rdf(Annotation, oa:hasTarget, Uri), + rdf(Uri, rdf:type, edm:'ProvidedCHO')), + Uris), !. +get_annotated_user(_User, []). %% register_user(+Request) % diff --git a/lib/accurator/recommendation/strategy_random.pl b/lib/accurator/recommendation/strategy_random.pl index 567cc9a..e6d8e87 100644 --- a/lib/accurator/recommendation/strategy_random.pl +++ b/lib/accurator/recommendation/strategy_random.pl @@ -1,5 +1,6 @@ :- module(strategy_random, [strategy_random/2]). +:- use_module(library(accurator/accurator_user)). :- use_module(library(semweb/rdf_db)). %% strategy_random(-Result, +Options) @@ -8,8 +9,20 @@ strategy_random(Result, Options) :- option(target(Target), Options), option(number(Number), Options), + option(filter(Filter), Options), + % Get list of all targets findall(Uri, rdf(Uri, rdf:type, Target), SourceList), - assign_random(Number, SourceList, Result). + filter(Filter, SourceList, FilteredList, Options), + assign_random(Number, FilteredList, Result). + +%% filter(+FilterOption, +Uris, -FilteredUris, +Options) +% +% Filter the potential candidates. +filter(annotated, SourceList, FilteredUris, Options) :- + option(user(User), Options), + get_annotated_user(User, AnnotatedUris), + subtract(SourceList, AnnotatedUris, FilteredUris). +filter(none, SourceList, SourceList, _Options). assign_random(0, _SourceList, []).