[Debtags-commits] [svn] r1414 - autodebtag/trunk/dbacl

Enrico Zini enrico at costa.debian.org
Thu Oct 27 20:32:17 UTC 2005


Author: enrico
Date: Thu Oct 27 20:32:17 2005
New Revision: 1414

Modified:
   autodebtag/trunk/dbacl/debtags-ai
Log:
Added fixpatch feature

Modified: autodebtag/trunk/dbacl/debtags-ai
==============================================================================
--- autodebtag/trunk/dbacl/debtags-ai	(original)
+++ autodebtag/trunk/dbacl/debtags-ai	Thu Oct 27 20:32:17 2005
@@ -63,6 +63,7 @@
 sub read_apt ();
 sub patch_all (@);
 sub scan_facet ($$);
+sub fix_patch ();
 
 
 ##
@@ -91,6 +92,8 @@
                   if none is given)
   facets pkg      For every available facet, select a tag candidate for the
                   given package.
+  fixpatch        Reads a patch from stdin and only output those parts that are
+                  confirmed by dbacl.
 Options are:
   --help, -h      Print this help message.
   --verbose, -v   Be verbose.  A number can be provided for more verbose
@@ -187,6 +190,9 @@
 				exists $tags{$tag}{$pkg} ? " and it is" : "";
 
 		}
+	} elsif ($cmd eq 'fixpatch') {
+		read_apt();
+		fix_patch();
 	} else {
 		usage();
 	}
@@ -273,6 +279,7 @@
 	my ($pkg, $tag) = @_;
 	return undef if not -f "$traindir/$tag";
 	return undef if not -f "$traindir/not-$tag";
+	return undef if not exists $pkgdata{$pkg};
 
 	my($rdrfh, $wtrfh);
 	my $pid = open2($rdrfh, $wtrfh, "dbacl -m -U -c $traindir/$tag -c $traindir/not-$tag");
@@ -394,6 +401,47 @@
 	printf STDERR "\n" if $verbose == 1;
 }
 
+# Reads a patch, and output only those parts that are confirmed by dbacl
+sub fix_patch ()
+{
+	# Filter out tags for which we know the bayesian doesn't do a good job
+#	for my $tag (keys %tags)
+#	{
+#		push @interesting_tags, $tag 
+#			if scalar keys %{$tags{$tag}} >= $tag_min_card
+#			   and $tag !~ $tag_blacklist;
+#	}
+
+	my $failed = 0;
+	while (<STDIN>)
+	{
+		chop;
+		my ($pkg, $patch) = split(': ', $_);
+		next if not exists $pkgdata{$pkg};
+		my @res;
+		for my $p (split(', ', $patch))
+		{
+			my ($op, $tag) = (substr($p, 0, 1), substr($p, 1));
+			my $perc = testtag($pkg, $tag);
+			if (not defined $perc)
+			{
+				$failed++;
+#				print STDERR "Error evaluating $tag for $pkg\n";
+				next;
+			}
+			if ($op eq '+' && $perc >= $sure_perc)
+			{
+				push @res, "+$tag";
+			} elsif ($op eq '-' && $perc <= -$sure_perc) {
+				push @res, "-$tag";
+			}
+		}
+		print "$pkg: ", join(', ', @res), "\n" if @res;
+	}
+	printf STDERR "Could not evaluate %d tags.\n", $failed if $failed;
+}
+
+
 ##
 ## Training
 ##



More information about the Debtags-commits mailing list