[Debtags-commits] [svn] r1931 - python

Enrico Zini enrico at costa.debian.org
Tue Sep 19 19:51:53 UTC 2006


Author: enrico
Date: Tue Sep 19 19:51:52 2006
New Revision: 1931

Modified:
   python/   (props changed)
   python/Debtags.py
Log:
 r3354 at viaza:  enrico | 2006-09-18 14:41:21 +0200
 Simplified relevance value computation


Modified: python/Debtags.py
==============================================================================
--- python/Debtags.py	(original)
+++ python/Debtags.py	Tue Sep 19 19:51:52 2006
@@ -92,7 +92,20 @@
 	# Weighted by the square root of the relevance, to downplay the very
 	# common tags a bit
 	#return lambda tag: float(sub.card(tag)) / float(full.card(tag)) * math.sqrt(full.card(tag) / float(full.tagCount()))
-	return lambda tag: float(sub.card(tag)) / float(full.card(tag)) * math.sqrt(full.card(tag) / float(full.packageCount()))
+	#return lambda tag: float(sub.card(tag)) / float(full.card(tag)) * math.sqrt(full.card(tag) / float(full.packageCount()))
+	# One useless factor removed, and simplified further, thanks to Benjamin Mesing
+	return lambda tag: float(sub.card(tag)) / math.sqrt(float(full.card(tag)))
+
+	# The difference between how many packages are in and how many packages are out
+	# (problems: tags that mean many different things can be very much out
+	# as well.  In the case of 'image editor', for example, there will be
+	# lots of editors not for images in the outside group.
+	# It is very, very good for nonambiguous keywords like 'image'.
+	#return lambda tag: 2 * sub.card(tag) - full.card(tag)
+	# Same but it tries to downplay the 'how many are out' value in the
+	# case of popular tags, to mitigate the 'there will always be popular
+	# tags left out' cases.  Does not seem to be much of an improvement.
+	#return lambda tag: sub.card(tag) - float(full.card(tag) - sub.card(tag))/(math.sin(float(full.card(tag))*3.1415/full.packageCount())/4 + 0.75)
 
 
 class DB:
@@ -179,6 +192,10 @@
 		res.rdb = reverse(db)
 		return res
 
+	def hasPackage(self, pkg):
+		"""Check if the collection contains the given package"""
+		return self.db.has_key(pkg)
+
 	def hasTag(self, tag):
 		"""Check if the collection contains packages tagged with tag"""
 		return self.rdb.has_key(tag)



More information about the Debtags-commits mailing list