accurator/commit
Agenda can now be set based on expertise values.
author | Chris Dijkshoorn |
---|---|
Sun Mar 8 21:35:37 2015 +0000 | |
committer | Chris Dijkshoorn |
Sun Mar 8 21:35:37 2015 +0000 | |
commit | 0314dce4206944cd64a623d8b392e99c12d2c985 |
tree | d9fd085879aa4017072d93e48f3235f4a684415a |
parent | a1451cc4bacf7a18626ac7ca05dff3f45fc04008 |
Diff style: patch stat
diff --git a/lib/accurator/expertise.pl b/lib/accurator/expertise.pl index e6cf1e0..c7df151 100644 --- a/lib/accurator/expertise.pl +++ b/lib/accurator/expertise.pl @@ -163,7 +163,9 @@ get_latest_user_expertise(User, Topic, Topic-Value) :- DateValuePairs), keysort(DateValuePairs, SortedPairs), reverse(SortedPairs, ReversePairs), - member(Date-Value, ReversePairs). + member(Date-Value, ReversePairs), + !. +get_latest_user_expertise(_User, Topic, Topic-no_value). %% get_label(Locale, Uri, Label) % diff --git a/lib/accurator/recommendation/strategy_expertise.pl b/lib/accurator/recommendation/strategy_expertise.pl index 911eb79..f84b5df 100644 --- a/lib/accurator/recommendation/strategy_expertise.pl +++ b/lib/accurator/recommendation/strategy_expertise.pl @@ -1,13 +1,31 @@ :- module(strategy_expertise, [strategy_expertise/2]). :- use_module(library(accurator/accurator_user)). +:- use_module(library(accurator/expertise)). %% strategy_expertise(-Result, +Options) % % Assign a number of objects in a random fassion. -strategy_expertise(_Result, Options) :- - option(target(_Target), Options), - option(user(User), Options), - get_domain(User, Domain), - option(domain(Domain), Options) . +strategy_expertise(_Result, _Options) :- + %option(target(_Target), Options), + %Remove line below + User = 'http://accurator.nl/user#kip', + get_domain(User, DomainString), + atom_string(Domain, DomainString), + set_expertise_agenda(5, _Agenda, [user(User), domain(Domain)]). +set_expertise_agenda(MaxNumber, Agenda, Options) :- + get_user_expertise_domain(ExpertiseValues, Options), + transpose_pairs(ExpertiseValues, SortedExpertiseValues), + reverse(SortedExpertiseValues, TransposedExpertiseValues), + length(TransposedExpertiseValues, NumberExpertise), + number_of_items(NumberExpertise, MaxNumber, NumberItems), + length(AgendaPairs, NumberItems), + append(AgendaPairs, _, TransposedExpertiseValues), + maplist(pair_single, AgendaPairs, Agenda). + +number_of_items(NumberExpertise, Number0, NumberExpertise) :- + NumberExpertise < Number0, !. +number_of_items(_NumberExpertise, Number0, Number0). + +pair_single(_Left-Right, Right).