Author: siren
Date: Wed May 31 11:42:34 2006
New Revision: 410633
URL: http://svn.apache.org/viewvc?rev=410633&view=rev
Log:
Moved clusterer initialization to start method, restored the configuration
option for number of hits to cluster
Modified:
lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/clustering/ClusteringPresearchExtension.java
lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/webapp/controller/ClusteringController.java
Modified:
lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/clustering/ClusteringPresearchExtension.java
URL:
http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/clustering/ClusteringPresearchExtension.java?rev=410633&r1=410632&r2=410633&view=diff
==============================================================================
---
lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/clustering/ClusteringPresearchExtension.java
(original)
+++
lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/clustering/ClusteringPresearchExtension.java
Wed May 31 11:42:34 2006
@@ -28,9 +28,11 @@
public void doPreSearch(SearchContext context) {
int orig=context.getSearch().getHitsRequired();
- //TODO set this configurable
- if(orig < 100){
- context.getSearch().setHitsRequired(100);
+ int hitsToCluster = context.getConfigiration().getInt(
+ "extension.clustering.hits-to-cluster", 100);
+
+ if(orig < hitsToCluster){
+ context.getSearch().setHitsRequired(hitsToCluster);
}
}
}
Modified:
lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/webapp/controller/ClusteringController.java
URL:
http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/webapp/controller/ClusteringController.java?rev=410633&r1=410632&r2=410633&view=diff
==============================================================================
---
lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/webapp/controller/ClusteringController.java
(original)
+++
lucene/nutch/trunk/contrib/web2/plugins/web-clustering/src/java/org/apache/nutch/webapp/controller/ClusteringController.java
Wed May 31 11:42:34 2006
@@ -30,21 +30,21 @@
import org.apache.nutch.searcher.HitDetails;
import org.apache.nutch.searcher.Summary;
import org.apache.nutch.webapp.common.ServiceLocator;
+import org.apache.nutch.webapp.common.Startable;
import org.apache.struts.tiles.ComponentContext;
-public class ClusteringController extends NutchController {
+public class ClusteringController extends NutchController implements Startable
{
public static final String REQ_ATTR_CLUSTERS = "clusters";
+ static OnlineClusterer clusterer=null;
+
public void nutchPerform(ComponentContext tileContext,
HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext) throws ServletException, IOException {
ServiceLocator locator = getServiceLocator(request);
- int HITS_TO_CLUSTER = locator.getConfiguration().getInt(
- "extension.clustering.hits-to-cluster", 100);
-
// display top N clusters and top Q documents inside them.
// TODO move these to configuration
int N = locator.getConfiguration().getInt(
@@ -53,15 +53,6 @@
"extension.clustering.cluster-top-documents-count", 3);
int maxLabels = 2;
- OnlineClusterer clusterer = null;
- try {
- clusterer = new OnlineClustererFactory(locator.getConfiguration())
- .getOnlineClusterer();
- } catch (PluginRuntimeException e) {
- LOG.info("Could not ionitialize Clusterer, is the plugin enabled?");
- return;
- }
-
HitDetails[] details = locator.getSearch().getDetails();
Summary[] summaries = locator.getSearch().getSummaries();
@@ -86,5 +77,16 @@
//set to request
Clusters clusterResult = new Clusters(clusters, N, Q, maxLabels);
request.setAttribute(REQ_ATTR_CLUSTERS, clusterResult);
+ }
+
+ public void start(ServletContext servletContext) {
+ ServiceLocator locator = getServiceLocator(servletContext);
+ try {
+ clusterer = new OnlineClustererFactory(locator.getConfiguration())
+ .getOnlineClusterer();
+ } catch (PluginRuntimeException e) {
+ LOG.info("Could not ionitialize Clusterer, is the plugin enabled?");
+ return;
+ }
}
}