[Debtags-commits] [svn] r1890 - central-database/branches/alioth/webfrontend

Enrico Zini enrico at costa.debian.org
Mon Sep 4 13:40:50 UTC 2006


Author: enrico
Date: Mon Sep  4 13:40:49 2006
New Revision: 1890

Modified:
   central-database/branches/alioth/webfrontend/Engine.pm
Log:
Compute the relevant tags using the new algorithm
Fixed a bug in choosing the tag preselection when 0 packages would match (but why did it happen?)


Modified: central-database/branches/alioth/webfrontend/Engine.pm
==============================================================================
--- central-database/branches/alioth/webfrontend/Engine.pm	(original)
+++ central-database/branches/alioth/webfrontend/Engine.pm	Mon Sep  4 13:40:49 2006
@@ -145,6 +145,17 @@
 	return undef;
 }
 
+sub tagcard ($$)
+{
+	my ($self, $name) = shift;
+	return scalar(@{$self->{tags}{$name}{pkgs}});
+}
+
+sub tagCount ($)
+{
+	return scalar keys %{$_[0]->{tags}};
+}
+
 sub tags ($;@)
 {
 	my $self = shift;
@@ -806,7 +817,12 @@
 			}
 		}
 	}
-	my @res = (sort { $tags{$b} <=> $tags{$a} } keys %tags)[0 .. $max_tags];
+	my $tagdiscr = sub {
+		my $tag = shift;
+
+		return $tags{$tag} / $db->tagcard($tag) * sqrt($db->tagcard($tag) / $db->tagCount);
+	};
+	my @res = (sort { &$tagdiscr($b) <=> &$tagdiscr($a) } keys %tags)[0 .. $max_tags];
 #	for my $tag (@res)
 #	{
 #		&main::msg("%d: %s\n", $tags{$tag}, $tag);
@@ -823,7 +839,7 @@
 		{
 			last if not exists $ts{$res[$count]};
 		}
-		++$occ[$count - 1];
+		++$occ[$count - 1] if $count > 0;
 	}
 #	for my $c (@occ) { &main::msg("Initial count: $c\n"); }
 



More information about the Debtags-commits mailing list