[Debtags-commits] [svn] r1836 - in debtags/1.6.0: . tools

Enrico Zini enrico at costa.debian.org
Sun Aug 6 22:24:35 UTC 2006


Author: enrico
Date: Sun Aug  6 22:24:34 2006
New Revision: 1836

Modified:
   debtags/1.6.0/   (props changed)
   debtags/1.6.0/tools/DebtagsOptions.h
   debtags/1.6.0/tools/SmartSearcher.cc
   debtags/1.6.0/tools/SmartSearcher.h
   debtags/1.6.0/tools/debtags.cc
Log:
 r3031 at viaza:  enrico | 2006-07-09 11:27:20 +0200
 Added --discriminant and --relevant options to smartsearch


Modified: debtags/1.6.0/tools/DebtagsOptions.h
==============================================================================
--- debtags/1.6.0/tools/DebtagsOptions.h	(original)
+++ debtags/1.6.0/tools/DebtagsOptions.h	Sun Aug  6 22:24:34 2006
@@ -43,6 +43,9 @@
 	BoolOption* misc_local;
 	IntOption* misc_distance;
 
+	BoolOption* smse_reltags;
+	BoolOption* smse_disctags;
+
 	Engine* update;
 	Engine* selfcheck;
 	Engine* check;
@@ -216,6 +219,10 @@
 			"an unwanted tag.  Other words indicate keywords to search.\n"
 			"Remember to use '--' before unwanted tags to avoid to have "
 			"them interpreted as commandline switches.\n");
+		smse_reltags = smartsearch->add<BoolOption>("relevant", 0, "relevant",
+			"only print the tag names sorted by increasing relevance");
+		smse_disctags = smartsearch->add<BoolOption>("discriminant", 0, "discriminant",
+			"only print the tag names sorted by increasing discriminance");
 	}
 };
 

Modified: debtags/1.6.0/tools/SmartSearcher.cc
==============================================================================
--- debtags/1.6.0/tools/SmartSearcher.cc	(original)
+++ debtags/1.6.0/tools/SmartSearcher.cc	Sun Aug  6 22:24:34 2006
@@ -320,6 +320,45 @@
 	}
 }
 
+void SmartSearcher::outputRelevantTags()
+{
+	for (std::vector<Tag>::const_iterator i = interesting.begin();
+			i != interesting.end(); ++i)
+	{
+		using namespace wibble::operators;
+		if (utils::set_contains(wanted, *i)
+			|| utils::set_contains(unwanted, *i)
+			|| utils::set_contains(ignored, *i)
+			|| collMetrics.get(*i) == 0)
+			continue;
+		cout << i->fullname() << " - " << i->shortDescription() << endl;
+	}
+}
+
+void SmartSearcher::outputDiscriminantTags()
+{
+	// Compute the most interesting tags by discriminance
+	coll::Fast<Package, Tag> filtered;
+	for (coll::Fast<Package, Tag>::const_iterator i = fullColl.begin();
+			i != fullColl.end(); ++i)
+		if (patternMatch(i->first))
+			filtered.insert(wibble::singleton(i->first), i->second);
+
+	vector<Tag> discr = filtered.tagsInDiscriminanceOrder();
+
+	for (std::vector<Tag>::const_iterator i = discr.begin();
+			i != discr.end(); ++i)
+	{
+		using namespace wibble::operators;
+		if (utils::set_contains(wanted, *i)
+			|| utils::set_contains(unwanted, *i)
+			|| utils::set_contains(ignored, *i))
+			continue;
+		cout << i->fullname() << " - " << i->shortDescription()
+			 << " (" << filtered.getDiscriminance(*i) * 200 /filtered.itemCount() << "%)" << endl;
+	}
+}
+
 #include <tagcoll/coll/fast.tcc>
 
 // vim:set ts=4 sw=4:

Modified: debtags/1.6.0/tools/SmartSearcher.h
==============================================================================
--- debtags/1.6.0/tools/SmartSearcher.h	(original)
+++ debtags/1.6.0/tools/SmartSearcher.h	Sun Aug  6 22:24:34 2006
@@ -316,6 +316,9 @@
 	SmartSearcher(Ept& ept, const std::string& pattern);
 
 	void interact();
+	void outputRelevantTags();
+	void outputDiscriminantTags();
+
 
 #if 0
 	component::PackageTags& debtags;

Modified: debtags/1.6.0/tools/debtags.cc
==============================================================================
--- debtags/1.6.0/tools/debtags.cc	(original)
+++ debtags/1.6.0/tools/debtags.cc	Sun Aug  6 22:24:34 2006
@@ -1572,44 +1572,14 @@
 					keywords += " " + opts.next();
 
 			SmartSearcher searcher(*ept, keywords);
-			searcher.interact();
 
-#if 0
-			component::PackageTags& debtags = debtagsInit();
-			wantTagDatabase();
-			APTPrinter printer;
-			SmartSearcher smart(debtags, &printer);
-			Searcher searcher(debtags, &smart);
-			predicate::Predicate<Package> p = predicate::True<Package>();
-			//predicate::Factory<Package>::description(opts.next());
-			while (opts.hasNext())
-			{
-				string arg = opts.next();
-				switch (arg[0])
-				{
-					case '+':
-						p = p and predicate::Factory<Package>::tag(
-								Global::get().tags().tagByName(arg.substr(1)));
-						break;
-					case '-':
-						p = p and not predicate::Factory<Package>::tag(
-								Global::get().tags().tagByName(arg.substr(1)));
-						break;
-					default:
-						p = p and predicate::Factory<Package>::description(arg);
-						break;
-				}
+			if (opts.smse_reltags->boolValue())
+				searcher.outputRelevantTags();
+			else if (opts.smse_disctags->boolValue())
+				searcher.outputDiscriminantTags();
+			else {
+				searcher.interact();
 			}
-
-			int step1 = searcher.output(p);
-			int step2 = smart.outputRelated();
-
-			cout << step1 << " normal matches plus " << step2 << " related packages." << endl;
-			OpSet<Tag> topTags = smart.topTags();
-			cout << "Top tags were: " << topTags << endl;
-
-			return step1 + step2 > 0 ? 0 : 1;
-#endif
 		}
 #if 0
 		// update



More information about the Debtags-commits mailing list