[Debtags-commits] [svn] r1815 - in debtags/1.6.0: . tools
Enrico Zini
enrico at costa.debian.org
Sat Jul 8 09:37:12 UTC 2006
Author: enrico
Date: Sat Jul 8 09:37:11 2006
New Revision: 1815
Modified:
debtags/1.6.0/ (props changed)
debtags/1.6.0/tools/debtags.cc
Log:
r2998 at viaza: enrico | 2006-07-08 11:36:17 +0200
Improved keyword->tag mapping by weighting by cardinality when computing jumps. Now it rocks!
Modified: debtags/1.6.0/tools/debtags.cc
==============================================================================
--- debtags/1.6.0/tools/debtags.cc (original)
+++ debtags/1.6.0/tools/debtags.cc Sat Jul 8 09:37:11 2006
@@ -791,27 +791,25 @@
return res;
}
- TagMetrics<Tag, Number> jumpsFrom(const TagMetrics<Tag, Number>& other) const
+ TagMetrics<Tag, double> jumpsFrom(const TagMetrics<Tag, Number>& other) const
{
// Compute rank metrics
TagMetrics<Tag, Number> rank1 = other.rankMetrics();
TagMetrics<Tag, Number> rank2 = rankMetrics();
- TagMetrics<Tag, Number> res;
+ TagMetrics<Tag, double> res;
typename TagMetrics::const_iterator i1 = rank1.begin();
typename TagMetrics::const_iterator i2 = rank2.begin();
while (i1 != rank1.end() || i2 != rank2.end())
{
if (i1->first == i2->first)
{
- res.add(i1->first, i1->second - i2->second);
+ res.add(i1->first, (i1->second - i2->second) / i2->second);
++i1;
++i2;
} else if (i1 == rank1.end() || (i2 != rank2.end() && i2->first < i1->first)) {
- res.add(i2->first, rank2.size() - i2->second);
++i2;
} else {
- res.add(i1->first, i1->second - rank1.size());
++i1;
}
}
@@ -1111,7 +1109,7 @@
// Compute the set of tags that better represent the keyword search
TagMetrics<Tag, int> metrics1 = TagMetrics<Tag, int>::computeFromTags(fullColl);
collMetrics = TagMetrics<Tag, int>::computeFromTags(coll);
- TagMetrics<Tag, int> jumps = collMetrics.jumpsFrom(metrics1);
+ TagMetrics<Tag, double> jumps = collMetrics.jumpsFrom(metrics1);
interesting = jumps.tagsSortedByMetrics();
coll = fullColl;
More information about the Debtags-commits
mailing list