accurator/commit
Extend agenda until number is found, limited number to 12.
author | Chris Dijkshoorn |
---|---|
Sat Oct 3 21:01:02 2015 +0200 | |
committer | Chris Dijkshoorn |
Sat Oct 3 21:01:02 2015 +0200 | |
commit | 8c34c5904f4580724d5b0d5f362292f4c2bfc9f3 |
tree | 34b61f7cd6fed3f54b8201bc5308a176a94b6aae |
parent | 9ecdbac00d16e38751c36bb0c114e4a567c273f4 |
Diff style: patch stat
diff --git a/lib/accurator/recommendation/strategy_expertise.pl b/lib/accurator/recommendation/strategy_expertise.pl index 4c3fc59..cd27285 100644 --- a/lib/accurator/recommendation/strategy_expertise.pl +++ b/lib/accurator/recommendation/strategy_expertise.pl @@ -18,30 +18,47 @@ %% strategy_expertise(-Result, +Options) % % Recommend items based on user expertise. -strategy_expertise(Result, Options0) :- +strategy_expertise(Result, Options) :- + option(output_format(OutputFormat), Options), + strategy_expertise(OutputFormat, Result, 3, Options). + +strategy_expertise(cluster, Clusters, AgendaSize, Options0) :- option(user(User), Options0), get_domain(User, Domain), Options = [domain(Domain) | Options0], - set_expertise_agenda(3, Agenda, Options), + set_expertise_agenda(AgendaSize, Agenda, Options), cluster_recommender(Agenda, State, Options), - option(output_format(OutputFormat), Options), - cluster_or_list(OutputFormat, State, Result, Options). - - -cluster_or_list(cluster, State, Clusters, _Options) :- OrganizeOptions = [groupBy(path)], organize_resources(State, Clusters, OrganizeOptions). -cluster_or_list(list, State, FilteredList, Options) :- +strategy_expertise(list, Result, AgendaSize, Options) :- + strategy_expertise_list([], Result, AgendaSize, Options). + +strategy_expertise_list(List, ShortList, AgendaSize, Options) :- + option(number(Number), Options), + length(List, Length), + debug(numbers, 'Agenda ~p Length list ~p', [AgendaSize, Length]), + %Stop extending the agenda when the Length is longer than Number + Length > Number, + %Should in the end add a check for empty agenda + !, + %Shorten the list to number + append(ShortList, _Tail, List), + length(ShortList, Number). + +strategy_expertise_list(_Result, FinalResult, AgendaSize, Options0) :- + option(user(User), Options0), + get_domain(User, Domain), + Options = [domain(Domain) | Options0], + set_expertise_agenda(AgendaSize, Agenda, Options), + cluster_recommender(Agenda, State, Options), OrganizeOptions = [groupBy(path)], organize_resources(State, Clusters, OrganizeOptions), merge_in_list(Clusters, List, Options), - length(List, LengthList), option(filter(Filter), Options), - debug(filter, 'length list ~p', [LengthList]), filter(Filter, List, FilteredList, Options), - length(FilteredList, FilterLengthList), - debug(filter, 'length filtered list ~p', [FilterLengthList]). + NewAgendaSize is AgendaSize + 1, + strategy_expertise_list(FilteredList, FinalResult, NewAgendaSize, Options0). merge_in_list(clusters(Clusters), ElementsList, _Options) :- get_elements_list(Clusters, ElementsList). diff --git a/web/js/accurator_results.js b/web/js/accurator_results.js index 4d8c355..1da4791 100644 --- a/web/js/accurator_results.js +++ b/web/js/accurator_results.js @@ -171,7 +171,7 @@ function recommendExpertiseList(target) { query = "expertise"; $.getJSON("recommendation", {strategy:'expertise', - number:20, + number:12, target:target, output_format:'list'}) .done(function(data){ @@ -194,10 +194,10 @@ function recommendExpertiseList(target) { function randomResults(target) { query = "random"; - console.log(target); + // Populate a list of random items $.getJSON("recommendation", {strategy:'random', - number:20, + number:12, target:target}) .done(function(data){ var numberOfItems = data.length;