annotation_dashboard/commit

minor on representative images and image order

authorJacco van Ossenbruggen
Mon Jun 30 12:10:21 2014 +0200
committerJacco van Ossenbruggen
Mon Jun 30 12:10:21 2014 +0200
commitd559468268047aac458e90b0c268b5b24ce94072
tree117f55de48592caa2029dd109ab461ab87d60178
parent33a768625547791a5f22e670693bd9de3ff63c5c
Diff style: patch stat
diff --git a/api/dashboard_api.pl b/api/dashboard_api.pl
index 9b057a6..113d96c 100644
--- a/api/dashboard_api.pl
+++ b/api/dashboard_api.pl
@@ -17,5 +17,5 @@ http_api_dashboard_task(Request) :-
 					 oneof([ground, number])
 					])
 			]),
-	find_task_properties(Task, Props, [filter(Filter)]),
+	find_task_properties(Task, Props, _, [filter(Filter)]),
 	reply_json(Props).
diff --git a/applications/dashboard.pl b/applications/dashboard.pl
index 856d4bc..f335d44 100644
--- a/applications/dashboard.pl
+++ b/applications/dashboard.pl
@@ -90,11 +90,16 @@ task_page(Task, Options0) :-
 	partition(is_tag, Annotations, Tags, Judgements),
 	maplist(rdf_get_annotation_target, Tags, Targets),
 	sort(Targets, Objects),
+	maplist(count_annotations, Objects, CountPairs),
+	sort(CountPairs, SortedPairs0),
+	reverse(SortedPairs0, ReversePairs),
+	pairs_values(ReversePairs, SortedObjects),
 	Options = [annotations(Annotations),
 		   judgements(Judgements),
 		   annotation_fields(AnnotationFields),
 		   metadata_fields(MetadataFields),
 		   ui(UI),
+		   task(Task),
 		   lazy(true),
 		   image_link_predicate(http_mediumscale) |
 		   Options0
@@ -116,11 +121,7 @@ task_page(Task, Options0) :-
 				div([class(row)], \task_stats(Task)),
 				h3([class('sub-header')],
 				   ['Task objects']),
-				%\show_objects(['http://purl.org/collections/nl/rma/collection/r-115055',
-				%	       'http://purl.org/collections/nl/rma/collection/r-108494',
-				%	       'http://purl.org/collections/nl/rma/collection/r-141319'],
-				%	      Options)
-				\show_objects(Objects, Options)
+				\show_objects(SortedObjects, Options)
 			      ])
 			])
 		  ])
@@ -257,14 +258,17 @@ match_target(T,A) :-
 	rdf_get_annotation_target(A,T).
 
 show_object(O, Options) -->
-	{ option(annotations(A), Options),
+	{ option(annotations(A), Options, []),
 	  include(match_target(O), A, Annotations),
 	  (   ( option(metadata_fields(_), Options),
 		option(ui(_), Options),
 		option(annotation_fields(_), Options))
 	  ->  NewOptions = Options
-	  ;   member(First, A),
-	      guess_task(First, Task-First),
+	  ;   ( option(task(Task), Options)
+	      ->  true
+	      ;	  member(First, A),
+		  guess_task(First, Task-First)
+	      ),
 	      rdf_has(Task, ann_ui:taskUI, UI),
 	      get_metafields(UI, [], MetadataFields),
 	      get_anfields(UI, [], [], AnnotationFields),
@@ -300,20 +304,29 @@ show_tasks([H|T]) -->
 show_task(Task) -->
 	{ rdf_display_label(Task,Title),
 	  http_link_to_id(http_dashboard_task, [task(Task)], TaskLink),
-	  find_task_properties(Task, Props0, []),
-	  predsort(task_compare, Props0, Props)
+	  find_task_properties(Task, Props0, Representative,[]),
+	  predsort(task_compare, Props0, Props),
+	  object_image(Representative, Image),
+	  http_link_to_id(http_medium_fit, [uri(Image)], ImageHref)
+
 	},
-	html([h3([class('sub-header')],
-		 [a([href(TaskLink)],Title)]),
-	      div([class('table-responsive')],
-		  [table([class('table table-striped')],
-			 [ thead([
-			       tr([th('Property'), th('Value')])
-			   ]),
-			   tbody([
-			       \show_option_list(Props)
-			   ])
-			 ])
+	html([div(class(row),
+		  [ h3([class('sub-header')],
+		       [a([href(TaskLink)],Title)]),
+		    div(class('col-sm-3'),
+			[
+			    img([src(ImageHref), alt('Example image for this task'),
+				 class('img-responsive')],[])
+			]),
+		    div(class('col-sm-9'),
+			[
+			  div([class('table-responsive')],
+			      [table([class('table table-striped')],
+				     [ % thead([tr([th('Property'), th('Value')])]),
+				       tbody([\show_option_list(Props)])
+				     ])
+			      ])
+			])
 		  ])
 	     ]).
 
diff --git a/lib/dashboard_util.pl b/lib/dashboard_util.pl
index fcd957f..deb3c4b 100644
--- a/lib/dashboard_util.pl
+++ b/lib/dashboard_util.pl
@@ -1,12 +1,14 @@
 :- module(dashboard_util,
 	  [ is_tag/1,
 	    guess_task/2,
+	    count_annotations/2,
+	    blacklisted_annotation/1,
 	    find_annotations_by_user/2,
 	    find_annotations_by_task/2,
 	    find_annotations_without_task/1,
 
 	    find_tasks/1,
-	    find_task_properties/3,
+	    find_task_properties/4,
 
 	    find_workers/1
 	  ]).
@@ -22,9 +24,16 @@
 	task_property_blacklist(t).
 
 task_property_blacklist(
-    [rdf:type,
-     dcterms:title
+    [rdf:xtype,
+     dcterms:xtitle,
+     'xhttp://semanticweb.cs.vu.nl/annotate/ui/taskUI'
     ]).
+blacklisted_annotation(A) :-
+	rdf_has(A, oa:annotatedBy, 'http://sealinc.ops.few.vu.nl/accurator/user/jasper')
+	;
+	rdf_has(A, oa:annotedBy, 'http://localhost:3020/user/admin')
+	;
+	rdf_has(A, dcterms:title, literal(test)).
 
 is_tag(A) :-
 	rdf_has(A, oa:motivatedBy, oa:tagging).
@@ -66,7 +75,8 @@ find_annotations_by_task(Task, Annotations) :-
 	findall(
 	    A,
 	    (	rdfs_member(Field, FieldList),
-		annotation_by_field(Field, A)
+		annotation_by_field(Field, A),
+		\+ blacklisted_annotation(A)
 	    ),
 	    Annotations).
 
@@ -87,7 +97,7 @@ is_specific_target_annotation(A, T) :-
 	rdf_has(A, oa:hasTarget, T),
 	rdfs_individual_of(T, oa:'SpecificResource').
 
-find_task_properties(Task, Props, Options) :-
+find_task_properties(Task, Props, Representative, Options) :-
 	option(filter(Filter), Options, ground),
 	find_annotations_by_task(Task, Annotations),
 	maplist(rdf_get_annotation_target, Annotations, WorkedOn0),
@@ -101,6 +111,7 @@ find_task_properties(Task, Props, Options) :-
 	NrCompleteTargets = 0, % Fixme
 	NrUntouched is NrTotalTargets - NrWorkedOn,
 	task_property_blacklist(PropertyBlackList),
+	representative(WorkedOn, Representative),
 	findall(Prop,
 		(   rdf_has(Task, P, O),
 		    \+ member(P, PropertyBlackList),
@@ -120,10 +131,24 @@ find_task_properties(Task, Props, Options) :-
 	append([CountProps, RDFProps], Opts0),
 	maplist(pmap, Opts0, Props).
 
-property_key_label(500, targets_untouched, 'objects without tags').
-property_key_label(200, targets_total,     'objects targeted').
-property_key_label(250, targets_complete,  'objects completed').
-property_key_label(300, targets_worked_on, 'objects with some tags').
+count_annotations(Target, Count-Target) :-
+	findall(A,
+		(   rdf_get_annotation_target(A, Target),
+		    \+ blacklisted_annotation(A)
+		),
+		As),
+
+	length(As, Count).
+
+representative(Candidates, Representative) :-
+	maplist(count_annotations, Candidates, Counts),
+	sort(Counts, Sorted),
+	reverse(Sorted, [_Count-Representative|_]).
+
+property_key_label(500, targets_untouched, 'works without tags').
+property_key_label(200, targets_total,     'works targeted').
+property_key_label(250, targets_complete,  'works completed').
+property_key_label(300, targets_worked_on, 'works with some tags').
 property_key_label(100, annotations,       'total annotations').
 property_key_label(105, obj_annotations,   'annotations on object').
 property_key_label(104, spec_annotations,  'annotations on region').