yaz/commit

assert scores when a match is made in the gardening

authorMichiel Hildebrand
Sat Feb 5 17:47:30 2011 +0100
committerMichiel Hildebrand
Sat Feb 5 17:47:30 2011 +0100
commit2fcafeb0acfe059c53ff5605357f49ea3c3a1dba
treead2596423b669d3d521142f5f5f8376ca42ea635
parenta9a49666ca4dfb06895a2efd32be6ac21e34369a
Diff style: patch stat
diff --git a/applications/yaz_cgarden.pl b/applications/yaz_cgarden.pl
index 0dfa242..6a8823e 100644
--- a/applications/yaz_cgarden.pl
+++ b/applications/yaz_cgarden.pl
@@ -72,11 +72,13 @@ tag_matches([], _, _, _, []).
 tag_matches([A0|As], User, Process, Interval, [A|Rest]) :-
 	A0 = annotation(Value,Start,End,Entries),
 	A =  annotation(Value,Start,End,Entries,Match),
-	existing_match(Entries, Match),
-	!,
+	(   existing_match(Entries, Match)
+	->  true
+	;   Match = @false
+	),
 	tag_matches(As, User, Process, Interval, Rest).
-tag_matches([_|As], User, Process, Interval, Rest) :-
- 	tag_matches(As, User, Process, Interval, Rest).
+%tag_matches([_|As], User, Process, Interval, Rest) :-
+% 	tag_matches(As, User, Process, Interval, Rest).
 
 existing_match(Entries, Match) :-
 	findall(S, (member(i(E,_), Entries),
@@ -120,7 +122,7 @@ html_video_page_yui(Video, User, Annotations, StartTime, _Options) -->
 	  http_absolute_location(js('videoplayer/videoplayer.js'), VideoPlayer, []),
 	  http_absolute_location(js('tagcarousel/tagcarousel.js'), TagCarousel, []),
 	  %setting(request_interval, RequestInterval),
-	  http_location_by_id(http_reconcile, ReconcileServer),
+	  %http_location_by_id(http_reconcile, ReconcileServer),
   	  annotation_to_json(Annotations, JSONTags)
    	},
 	html_requires(js('videoplayer/swfobject.js')),
diff --git a/applications/yaz_game.pl b/applications/yaz_game.pl
index 984c26d..e4376f1 100644
--- a/applications/yaz_game.pl
+++ b/applications/yaz_game.pl
@@ -1,5 +1,6 @@
 :- module(yaz_game,
-	  [ http_yaz_game/1
+	  [ http_yaz_game/1,
+	    assert_match/5
 	  ]).
 
 :- use_module(library(http/http_dispatch)).
diff --git a/applications/yaz_sgarden.pl b/applications/yaz_sgarden.pl
index eb92c7b..2319d66 100644
--- a/applications/yaz_sgarden.pl
+++ b/applications/yaz_sgarden.pl
@@ -180,28 +180,32 @@ http_yaz_api_edit_tag(Request) :-
  	debug(yaz(update), '~w with ~w', [Tagentry, Tag]),
 	(   rdf(Tagentry, rdf:value, literal(Tag))
 	->  Score = 0
-	;   matching_tag(Tagentry, Tag, 10000, Score),
+	;   tag_matches(Tagentry, Tag, 10000, Score),
 	    update_annotation_value(Tagentry, literal(Tag))
+
 	),
  	reply_json(json([tagentry=Tagentry,
 			 tag=Tag,
 			 score=Score
  			])).
 
-matching_tag(Tagentry, Tag, Interval, Score) :-
+tag_matches(Tagentry, Tag, Interval, Score) :-
 	rdf(Tagentry, pprime:videoPlayhead, literal(Time0), Game:_),
  	rdf(Tagentry, pprime:creator, User),
 	literal_to_number(Time0, Time),
 	Start is Time-Interval,
 	End is Time+Interval,
 	findall(E, tagentry_in_interval(Tag, Game, User, Start, End, E), Es),
-	length(Es, N),
-	Score is N*10.
+	(   Es = []
+	->  Score = 0
+	;   length(Es, N),
+	    N1 is N+1,
+	    Score is max(25, 100-((N-1)*25)),
+	    current_user_process(Process),
+	    assert_match(Tagentry, Process, exact, Score, N1)
+	).
 
 tagentry_in_interval(Tag, Game, User, Start, End, E) :-
 	rdf(E, rdf:value, literal(Tag), Game),
  	rdf(E, pprime:videoPlayhead, literal(between(Start,End), _)),
 	\+ rdf(E, pprime:creator, User).
-
-
-