You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by og...@apache.org on 2012/03/26 23:47:08 UTC

svn commit: r1305620 - in /incubator/stanbol/trunk/enhancer/engines/topic: ./ src/main/java/org/apache/stanbol/enhancer/engine/topic/ src/main/java/org/apache/stanbol/enhancer/topic/ src/main/java/org/apache/stanbol/enhancer/topic/training/ src/test/ja...

Author: ogrisel
Date: Mon Mar 26 21:47:08 2012
New Revision: 1305620

URL: http://svn.apache.org/viewvc?rev=1305620&view=rev
Log:
STANBOL-197: fixed OSGi registration and lookups for training set from classifier

Modified:
    incubator/stanbol/trunk/enhancer/engines/topic/pom.xml
    incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java
    incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/ConfiguredSolrCoreTracker.java
    incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/TopicClassifier.java
    incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/SolrTrainingSet.java
    incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/TrainingSet.java
    incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TopicEngineTest.java
    incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TrainingSetTest.java
    incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/integration/TopicClassificationOSGiTest.java

Modified: incubator/stanbol/trunk/enhancer/engines/topic/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/topic/pom.xml?rev=1305620&r1=1305619&r2=1305620&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/topic/pom.xml (original)
+++ incubator/stanbol/trunk/enhancer/engines/topic/pom.xml Mon Mar 26 21:47:08 2012
@@ -61,6 +61,7 @@
         <configuration>
           <instructions>
             <Export-Package>
+              org.apache.stanbol.enhancer.topic.*;version=${project.version},
               org.apache.stanbol.enhancer.engine.topic.*;version=${project.version}
             </Export-Package>
             <Install-Path>install-config</Install-Path>

Modified: incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java?rev=1305620&r1=1305619&r2=1305620&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java Mon Mar 26 21:47:08 2012
@@ -64,6 +64,8 @@ import org.apache.solr.common.params.Mor
 import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
 import org.apache.stanbol.commons.solr.utils.StreamQueryRequest;
 import org.apache.stanbol.enhancer.servicesapi.Blob;
+import org.apache.stanbol.enhancer.servicesapi.Chain;
+import org.apache.stanbol.enhancer.servicesapi.ChainException;
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
 import org.apache.stanbol.enhancer.servicesapi.EngineException;
 import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
@@ -82,12 +84,16 @@ import org.apache.stanbol.enhancer.topic
 import org.apache.stanbol.enhancer.topic.TopicSuggestion;
 import org.apache.stanbol.enhancer.topic.UTCTimeStamper;
 import org.apache.stanbol.enhancer.topic.training.Example;
+import org.apache.stanbol.enhancer.topic.training.SolrTrainingSet;
 import org.apache.stanbol.enhancer.topic.training.TrainingSet;
 import org.apache.stanbol.enhancer.topic.training.TrainingSetException;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.component.ComponentContext;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -110,7 +116,7 @@ import org.slf4j.LoggerFactory;
 @Component(metatype = true, immediate = true, configurationFactory = true, policy = ConfigurationPolicy.REQUIRE)
 @Service
 @Properties(value = {
-                     @Property(name = TopicClassificationEngine.ENGINE_ID),
+                     @Property(name = EnhancementEngine.PROPERTY_NAME),
                      @Property(name = TopicClassificationEngine.ORDER, intValue = 100),
                      @Property(name = TopicClassificationEngine.SOLR_CORE),
                      @Property(name = TopicClassificationEngine.LANGUAGES),
@@ -129,6 +135,7 @@ import org.slf4j.LoggerFactory;
                      @Property(name = TopicClassificationEngine.FALSE_POSITIVES_FIELD, value = "false_positives"),
                      @Property(name = TopicClassificationEngine.POSITIVE_SUPPORT_FIELD, value = "positive_support"),
                      @Property(name = TopicClassificationEngine.NEGATIVE_SUPPORT_FIELD, value = "negative_support"),
+                     @Property(name = TopicClassificationEngine.TRAINING_SET_ID),
                      @Property(name = Constants.SERVICE_RANKING, intValue = 0)})
 public class TopicClassificationEngine extends ConfiguredSolrCoreTracker implements EnhancementEngine,
         ServiceProperties, TopicClassifier {
@@ -137,8 +144,6 @@ public class TopicClassificationEngine e
 
     public static final String METADATA_ENTRY = "metadata";
 
-    public static final String ENGINE_ID = EnhancementEngine.PROPERTY_NAME;
-
     public static final String SOLR_CORE = "org.apache.stanbol.enhancer.engine.topic.solrCore";
 
     public static final String LANGUAGES = "org.apache.stanbol.enhancer.engine.topic.languages";
@@ -175,6 +180,8 @@ public class TopicClassificationEngine e
 
     public static final String NEGATIVE_SUPPORT_FIELD = "org.apache.stanbol.enhancer.engine.topic.negativeSupportField";
 
+    public static final String TRAINING_SET_ID = "org.apache.stanbol.enhancer.engine.topic.trainingSetId";
+
     private static final Logger log = LoggerFactory.getLogger(TopicClassificationEngine.class);
 
     /**
@@ -201,7 +208,7 @@ public class TopicClassificationEngine e
     public int MAX_SUGGESTIONS = 5; // never suggest more than this: this is expected to be a reasonable
                                     // estimate of the number of topics occuring in each documents
 
-    protected String engineId;
+    protected String engineName;
 
     protected List<String> acceptedLanguages;
 
@@ -223,8 +230,14 @@ public class TopicClassificationEngine e
 
     protected String recallField;
 
+    // without OSGi
     protected TrainingSet trainingSet;
 
+    // with OSGi
+    protected ServiceTracker trainingSetTracker;
+
+    protected String trainingSetId;
+
     // the ENTRY_*_FIELD are basically a hack to use a single Solr core to make documents with partially
     // updateable stored fields: the logical document is splitted into two parts joined by entryIdField. The
     // first part has entryTypeField field with value METADATA_ENTRY and the second half has entryTypeField
@@ -259,8 +272,17 @@ public class TopicClassificationEngine e
         @SuppressWarnings("unchecked")
         Dictionary<String,Object> config = context.getProperties();
         this.context = context;
-        this.indexArchiveName = "default-topic-model";
+        indexArchiveName = "default-topic-model";
         configure(config);
+
+        // if training set is not null, track it
+        if (trainingSetId != null) {
+            String filter = String.format("(&(%s=%s)(%s=%s))", Constants.OBJECTCLASS,
+                TrainingSet.class.getName(), SolrTrainingSet.TRAINING_SET_NAME, trainingSetId);
+            trainingSetTracker = new ServiceTracker(context.getBundleContext(), context.getBundleContext()
+                    .createFilter(filter), null);
+            trainingSetTracker.open();
+        }
     }
 
     @Deactivate
@@ -268,11 +290,14 @@ public class TopicClassificationEngine e
         if (indexTracker != null) {
             indexTracker.close();
         }
+        if (trainingSetTracker != null) {
+            trainingSetTracker.close();
+        }
         context = null;
     }
 
     public void configure(Dictionary<String,Object> config) throws ConfigurationException {
-        engineId = getRequiredStringParam(config, ENGINE_ID);
+        engineName = getRequiredStringParam(config, EnhancementEngine.PROPERTY_NAME);
         entryIdField = getRequiredStringParam(config, ENTRY_ID_FIELD);
         modelEntryIdField = getRequiredStringParam(config, MODEL_ENTRY_ID_FIELD);
         conceptUriField = getRequiredStringParam(config, CONCEPT_URI_FIELD);
@@ -287,11 +312,12 @@ public class TopicClassificationEngine e
         falseNegativesField = getRequiredStringParam(config, FALSE_NEGATIVES_FIELD);
         positiveSupportField = getRequiredStringParam(config, POSITIVE_SUPPORT_FIELD);
         negativeSupportField = getRequiredStringParam(config, NEGATIVE_SUPPORT_FIELD);
-        configureSolrCore(config, SOLR_CORE, engineId + "-model");
+        configureSolrCore(config, SOLR_CORE, engineName + "-model");
 
         // optional fields, can be null
         broaderField = (String) config.get(BROADER_FIELD);
         primaryTopicUriField = (String) config.get(PRIMARY_TOPIC_URI_FIELD);
+        trainingSetId = (String) config.get(TRAINING_SET_ID);
         Object orderParamValue = config.get(ORDER);
         if (orderParamValue != null) {
             order = (Integer) orderParamValue;
@@ -373,13 +399,8 @@ public class TopicClassificationEngine e
     // classifier API
 
     @Override
-    public String getSchemeId() {
-        return engineId;
-    }
-
-    @Override
     public String getName() {
-        return engineId;
+        return engineName;
     }
 
     @Override
@@ -438,7 +459,7 @@ public class TopicClassificationEngine e
             if ("unknown handler: /mlt".equals(e.getCause().getMessage())) {
                 String message = String.format("SolrServer with id '%s' for topic engine '%s' lacks"
                                                + " configuration for the MoreLikeThisHandler", solrCoreId,
-                    engineId);
+                    engineName);
                 throw new ClassifierException(message, e);
             } else {
                 throw new ClassifierException(e);
@@ -540,7 +561,7 @@ public class TopicClassificationEngine e
             QueryResponse response = solrServer.query(query);
             if (response.getResults().size() >= MAX_ROOTS) {
                 log.warn(String.format("TopicClassifier '%s' has more than %d registered topic roots."
-                                       + " Some roots might be ignored.", engineId, MAX_ROOTS));
+                                       + " Some roots might be ignored.", engineName, MAX_ROOTS));
             }
             for (SolrDocument result : response.getResults()) {
                 rootConcepts.add(result.getFirstValue(conceptUriField).toString());
@@ -644,8 +665,19 @@ public class TopicClassificationEngine e
     }
 
     @Override
+    public TrainingSet getTrainingSet() {
+        if (trainingSet != null) {
+            return trainingSet;
+        }
+        if (trainingSetTracker != null) {
+            return (TrainingSet) trainingSetTracker.getService();
+        }
+        return null;
+    }
+
+    @Override
     public boolean isUpdatable() {
-        return trainingSet != null;
+        return getTrainingSet() != null;
     }
 
     @Override
@@ -720,7 +752,7 @@ public class TopicClassificationEngine e
                     if (incr) {
                         Date lastModelUpdate = (Date) result.getFirstValue(modelUpdateDateField);
                         if (lastModelUpdate != null
-                            && !trainingSet.hasChangedSince(impactedTopics, lastModelUpdate)) {
+                            && !getTrainingSet().hasChangedSince(impactedTopics, lastModelUpdate)) {
                             continue;
                         }
                     }
@@ -767,7 +799,7 @@ public class TopicClassificationEngine e
         StringBuffer sb = new StringBuffer();
         int offset = 0;
         do {
-            examples = trainingSet.getPositiveExamples(impactedTopics, examples.nextOffset);
+            examples = getTrainingSet().getPositiveExamples(impactedTopics, examples.nextOffset);
             for (Example example : examples.items) {
                 if ((cvFoldCount != 0) && (offset % cvFoldCount == cvFoldIndex)) {
                     // we are performing a cross validation session and this example belong to the test
@@ -822,10 +854,10 @@ public class TopicClassificationEngine e
     }
 
     protected void checkTrainingSet() throws TrainingSetException {
-        if (trainingSet == null) {
-            throw new TrainingSetException(
-                    String.format("TopicClassificationEngine %s has no registered"
-                                  + " training set hence cannot be updated.", engineId));
+        if (getTrainingSet() == null) {
+            throw new TrainingSetException(String.format("TopicClassificationEngine %s has no registered"
+                                                         + " training set hence cannot be updated.",
+                engineName));
         }
     }
 
@@ -841,7 +873,7 @@ public class TopicClassificationEngine e
 
     protected Dictionary<String,Object> getCanonicalConfiguration(EmbeddedSolrServer server) {
         Hashtable<String,Object> config = new Hashtable<String,Object>();
-        config.put(TopicClassificationEngine.ENGINE_ID, engineId + "-evaluation");
+        config.put(EnhancementEngine.PROPERTY_NAME, engineName + "-evaluation");
         config.put(TopicClassificationEngine.ENTRY_ID_FIELD, "entry_id");
         config.put(TopicClassificationEngine.ENTRY_TYPE_FIELD, "entry_type");
         config.put(TopicClassificationEngine.MODEL_ENTRY_ID_FIELD, "model_entry_id");
@@ -904,7 +936,7 @@ public class TopicClassificationEngine e
 
         cvIterations = cvIterations <= 0 ? cvFoldCount : cvFoldCount;
         log.info(String.format("Performing evaluation %d-fold CV iteration %d/%d on classifier %s",
-            cvFoldCount, cvFoldIndex + 1, cvIterations, engineId));
+            cvFoldCount, cvFoldIndex + 1, cvIterations, engineName));
         long start = System.currentTimeMillis();
         FileUtils.deleteQuietly(evaluationFolder);
         evaluationFolder.mkdir();
@@ -960,7 +992,7 @@ public class TopicClassificationEngine e
                     offset = 0;
                     Batch<Example> examples = Batch.emtpyBatch(Example.class);
                     do {
-                        examples = trainingSet.getPositiveExamples(topics, examples.nextOffset);
+                        examples = getTrainingSet().getPositiveExamples(topics, examples.nextOffset);
                         for (Example example : examples.items) {
                             if (!(offset % foldCount == foldIndex)) {
                                 // this example is not part of the test fold, skip it
@@ -994,7 +1026,7 @@ public class TopicClassificationEngine e
                     offset = 0;
                     examples = Batch.emtpyBatch(Example.class);
                     do {
-                        examples = trainingSet.getNegativeExamples(topics, examples.nextOffset);
+                        examples = getTrainingSet().getNegativeExamples(topics, examples.nextOffset);
                         for (Example example : examples.items) {
                             if (!(offset % foldCount == foldIndex)) {
                                 // this example is not part of the test fold, skip it
@@ -1042,7 +1074,7 @@ public class TopicClassificationEngine e
         float averageF1 = 0.0f;
         long stop = System.currentTimeMillis();
         log.info(String.format("Finished CV iteration %d/%d on classifier %s in %fs. F1-score = %f",
-            cvFoldIndex + 1, cvFoldCount, engineId, (stop - start) / 1000.0, averageF1));
+            cvFoldIndex + 1, cvFoldCount, engineName, (stop - start) / 1000.0, averageF1));
         return updatedTopics;
     }
 
@@ -1176,4 +1208,20 @@ public class TopicClassificationEngine e
         }
         return sum;
     }
+
+    @Override
+    public List<String> getChainNames() throws InvalidSyntaxException, ChainException {
+        List<String> chainNames = new ArrayList<String>();
+        BundleContext bundleContext = context.getBundleContext();
+        ServiceReference[] references = bundleContext.getServiceReferences(Chain.class.getName(), null);
+        if (references != null) {
+            for (ServiceReference ref : references) {
+                Chain chain = (Chain) bundleContext.getService(ref);
+                if (chain.getEngines().contains(getName())) {
+                    chainNames.add(chain.getName());
+                }
+            }
+        }
+        return chainNames;
+    }
 }
\ No newline at end of file

Modified: incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/ConfiguredSolrCoreTracker.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/ConfiguredSolrCoreTracker.java?rev=1305620&r1=1305619&r2=1305620&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/ConfiguredSolrCoreTracker.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/ConfiguredSolrCoreTracker.java Mon Mar 26 21:47:08 2012
@@ -93,7 +93,15 @@ public abstract class ConfiguredSolrCore
      *         tracker.
      */
     public SolrServer getActiveSolrServer() {
-        return solrServer != null ? solrServer : indexTracker.getService();
+        SolrServer result = solrServer != null ? solrServer : indexTracker.getService();
+        if (result == null) {
+            if (solrCoreId != null) {
+                throw new RuntimeException("No Solr Core registered with id: " + solrCoreId);
+            } else {
+                throw new RuntimeException("No Solr Core registered");
+            }
+        }
+        return result;
     }
 
     protected void configureSolrCore(Dictionary<String,Object> config,
@@ -147,6 +155,9 @@ public abstract class ConfiguredSolrCore
                 ZipArchiveInputStream zis = new ZipArchiveInputStream(archiveUrl.openStream());
                 indexMetadata = managedSolrServer.updateIndex(indexName, zis, indexArchiveName);
             }
+            if (!indexMetadata.isActive()) {
+                managedSolrServer.activateIndex(indexName);
+            }
             indexReference = indexMetadata.getIndexReference();
         }
         return indexReference;

Modified: incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/TopicClassifier.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/TopicClassifier.java?rev=1305620&r1=1305619&r2=1305620&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/TopicClassifier.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/TopicClassifier.java Mon Mar 26 21:47:08 2012
@@ -20,9 +20,11 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.stanbol.enhancer.servicesapi.ChainException;
 import org.apache.stanbol.enhancer.servicesapi.EngineException;
 import org.apache.stanbol.enhancer.topic.training.TrainingSet;
 import org.apache.stanbol.enhancer.topic.training.TrainingSetException;
+import org.osgi.framework.InvalidSyntaxException;
 
 /**
  * Service interface for suggesting hierarchical concepts from a specific scheme (a.k.a. taxonomy, thesaurus
@@ -31,10 +33,10 @@ import org.apache.stanbol.enhancer.topic
 public interface TopicClassifier {
 
     /**
-     * @return the short id identifying this classifier / scheme: can be used as URL path component to publish
-     *         the service.
+     * The short name of the training set. Can be used as the URI component to identify the training set in
+     * the Web management interface or in RDF descriptions of the service.
      */
-    public String getSchemeId();
+    String getName();
 
     /**
      * @return list of language codes for text that can be automatically classified by the service.
@@ -112,6 +114,12 @@ public interface TopicClassifier {
     void removeConcept(String conceptUri) throws ClassifierException;
 
     /**
+     * @return the training set registered for this classifier (either set explicitly using setTrainingSet or
+     *         configured through OSGi properties).
+     */
+    public TrainingSet getTrainingSet();
+
+    /**
      * Register a training set to use to build the statistical model of the classifier.
      */
     void setTrainingSet(TrainingSet trainingSet);
@@ -152,5 +160,11 @@ public interface TopicClassifier {
      * Get a classification report with various accuracy metrics (precision, recall and f1-score) along with
      * the example ids of some mistakes (false positives or false negatives).
      */
-    ClassificationReport getPerformanceEstimates(String topic) throws ClassifierException;
+    ClassificationReport getPerformanceEstimates(String concept) throws ClassifierException;
+
+    /**
+     * Return the list of names of chains where the classifier is currently registered as an enhancement
+     * engine.
+     */
+    List<String> getChainNames() throws InvalidSyntaxException, ChainException;
 }

Modified: incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/SolrTrainingSet.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/SolrTrainingSet.java?rev=1305620&r1=1305619&r2=1305620&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/SolrTrainingSet.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/SolrTrainingSet.java Mon Mar 26 21:47:08 2012
@@ -58,15 +58,15 @@ import org.slf4j.LoggerFactory;
  */
 @Component(metatype = true, immediate = true, configurationFactory = true, policy = ConfigurationPolicy.REQUIRE)
 @Service
-@Properties(value = {@Property(name = SolrTrainingSet.TRAINING_SET_ID),
+@Properties(value = {@Property(name = SolrTrainingSet.TRAINING_SET_NAME),
                      @Property(name = SolrTrainingSet.SOLR_CORE),
-                     @Property(name = SolrTrainingSet.EXAMPLE_ID_FIELD),
-                     @Property(name = SolrTrainingSet.EXAMPLE_TEXT_FIELD),
-                     @Property(name = SolrTrainingSet.TOPICS_URI_FIELD),
-                     @Property(name = SolrTrainingSet.MODIFICATION_DATE_FIELD)})
+                     @Property(name = SolrTrainingSet.EXAMPLE_ID_FIELD, value = "id"),
+                     @Property(name = SolrTrainingSet.EXAMPLE_TEXT_FIELD, value = "text"),
+                     @Property(name = SolrTrainingSet.TOPICS_URI_FIELD, value = "topics"),
+                     @Property(name = SolrTrainingSet.MODIFICATION_DATE_FIELD, value = "modification_dt")})
 public class SolrTrainingSet extends ConfiguredSolrCoreTracker implements TrainingSet {
 
-    public static final String TRAINING_SET_ID = "org.apache.stanbol.enhancer.topic.trainingset.id";
+    public static final String TRAINING_SET_NAME = "org.apache.stanbol.enhancer.topic.trainingset.id";
 
     public static final String SOLR_CORE = "org.apache.stanbol.enhancer.engine.topic.solrCore";
 
@@ -93,14 +93,17 @@ public class SolrTrainingSet extends Con
 
     // TODO: make me configurable using an OSGi property
     protected int batchSize = 100;
-
-    protected String indexName = "default-topic-trainingset";
-
+    
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, bind = "bindManagedSolrServer", unbind = "unbindManagedSolrServer", strategy = ReferenceStrategy.EVENT, policy = ReferencePolicy.DYNAMIC)
     protected ManagedSolrServer managedSolrServer;
 
+    public String getName() {
+        return trainingSetId;
+    }
+    
     @Activate
     protected void activate(ComponentContext context) throws ConfigurationException, InvalidSyntaxException {
+        indexArchiveName = "default-topic-trainingset";
         @SuppressWarnings("unchecked")
         Dictionary<String,Object> config = context.getProperties();
         this.context = context;
@@ -116,7 +119,7 @@ public class SolrTrainingSet extends Con
 
     @Override
     public void configure(Dictionary<String,Object> config) throws ConfigurationException {
-        trainingSetId = getRequiredStringParam(config, TRAINING_SET_ID);
+        trainingSetId = getRequiredStringParam(config, TRAINING_SET_NAME);
         exampleIdField = getRequiredStringParam(config, EXAMPLE_ID_FIELD);
         exampleTextField = getRequiredStringParam(config, EXAMPLE_TEXT_FIELD);
         topicUrisField = getRequiredStringParam(config, TOPICS_URI_FIELD);

Modified: incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/TrainingSet.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/TrainingSet.java?rev=1305620&r1=1305619&r2=1305620&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/TrainingSet.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/topic/src/main/java/org/apache/stanbol/enhancer/topic/training/TrainingSet.java Mon Mar 26 21:47:08 2012
@@ -28,6 +28,12 @@ import org.apache.stanbol.enhancer.topic
 public interface TrainingSet {
 
     /**
+     * The short name of the training set. Can be used as the URI component to identify the training set in
+     * the Web management interface or in RDF descriptions of the service.
+     */
+    String getName();
+
+    /**
      * @return true if the training set can be updated using the {@code registerExample} API. If false that
      *         means that the component is a view on a remote datasource that has its own API for updates
      *         (e.g. the document repository of a CMS).

Modified: incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TopicEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TopicEngineTest.java?rev=1305620&r1=1305619&r2=1305620&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TopicEngineTest.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TopicEngineTest.java Mon Mar 26 21:47:08 2012
@@ -43,6 +43,7 @@ import org.apache.solr.client.solrj.embe
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.stanbol.commons.solr.utils.StreamQueryRequest;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
 import org.apache.stanbol.enhancer.topic.ClassificationReport;
 import org.apache.stanbol.enhancer.topic.ClassifierException;
 import org.apache.stanbol.enhancer.topic.EmbeddedSolrHelper;
@@ -121,7 +122,7 @@ public class TopicEngineTest extends Emb
         Hashtable<String,Object> config = getDefaultClassifierConfigParams();
         TopicClassificationEngine classifier = TopicClassificationEngine.fromParameters(config);
         assertNotNull(classifier);
-        assertEquals(classifier.engineId, "test-engine");
+        assertEquals(classifier.engineName, "test-engine");
         assertEquals(classifier.getActiveSolrServer(), classifierSolrServer);
         assertEquals(classifier.conceptUriField, "concept");
         assertEquals(classifier.similarityField, "classifier_features");
@@ -136,11 +137,11 @@ public class TopicEngineTest extends Emb
             fail("Should have raised a ConfigurationException");
         } catch (ConfigurationException e) {}
 
-        Hashtable<String,Object> configWithMissingEngineId = new Hashtable<String,Object>();
-        configWithMissingEngineId.putAll(config);
-        configWithMissingEngineId.remove(TopicClassificationEngine.ENGINE_ID);
+        Hashtable<String,Object> configWithMissingEngineName = new Hashtable<String,Object>();
+        configWithMissingEngineName.putAll(config);
+        configWithMissingEngineName.remove(EnhancementEngine.PROPERTY_NAME);
         try {
-            TopicClassificationEngine.fromParameters(configWithMissingEngineId);
+            TopicClassificationEngine.fromParameters(configWithMissingEngineName);
             fail("Should have raised a ConfigurationException");
         } catch (ConfigurationException e) {}
 
@@ -524,7 +525,7 @@ public class TopicEngineTest extends Emb
 
     protected Hashtable<String,Object> getDefaultClassifierConfigParams() {
         Hashtable<String,Object> config = new Hashtable<String,Object>();
-        config.put(TopicClassificationEngine.ENGINE_ID, "test-engine");
+        config.put(EnhancementEngine.PROPERTY_NAME, "test-engine");
         config.put(TopicClassificationEngine.ENTRY_ID_FIELD, "entry_id");
         config.put(TopicClassificationEngine.ENTRY_TYPE_FIELD, "entry_type");
         config.put(TopicClassificationEngine.MODEL_ENTRY_ID_FIELD, "model_entry_id");
@@ -547,7 +548,7 @@ public class TopicEngineTest extends Emb
     protected Hashtable<String,Object> getDefaultTrainingSetConfigParams() {
         Hashtable<String,Object> config = new Hashtable<String,Object>();
         config.put(SolrTrainingSet.SOLR_CORE, trainingSetSolrServer);
-        config.put(SolrTrainingSet.TRAINING_SET_ID, "test-training-set");
+        config.put(SolrTrainingSet.TRAINING_SET_NAME, "test-training-set");
         config.put(SolrTrainingSet.EXAMPLE_ID_FIELD, "id");
         config.put(SolrTrainingSet.EXAMPLE_TEXT_FIELD, "text");
         config.put(SolrTrainingSet.TOPICS_URI_FIELD, "topics");

Modified: incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TrainingSetTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TrainingSetTest.java?rev=1305620&r1=1305619&r2=1305620&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TrainingSetTest.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/TrainingSetTest.java Mon Mar 26 21:47:08 2012
@@ -268,7 +268,7 @@ public class TrainingSetTest extends Emb
     protected Hashtable<String,Object> getDefaultConfigParams() {
         Hashtable<String,Object> config = new Hashtable<String,Object>();
         config.put(SolrTrainingSet.SOLR_CORE, trainingsetSolrServer);
-        config.put(SolrTrainingSet.TRAINING_SET_ID, "test-training-set");
+        config.put(SolrTrainingSet.TRAINING_SET_NAME, "test-training-set");
         config.put(SolrTrainingSet.EXAMPLE_ID_FIELD, "id");
         config.put(SolrTrainingSet.EXAMPLE_TEXT_FIELD, "text");
         config.put(SolrTrainingSet.TOPICS_URI_FIELD, "topics");

Modified: incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/integration/TopicClassificationOSGiTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/integration/TopicClassificationOSGiTest.java?rev=1305620&r1=1305619&r2=1305620&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/integration/TopicClassificationOSGiTest.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/topic/src/test/java/org/apache/stanbol/enhancer/engine/topic/integration/TopicClassificationOSGiTest.java Mon Mar 26 21:47:08 2012
@@ -31,6 +31,7 @@ import javax.inject.Inject;
 import junit.framework.TestCase;
 
 import org.apache.stanbol.enhancer.engine.topic.TopicClassificationEngine;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
 import org.junit.Before;
 import org.ops4j.pax.exam.Option;
 import org.osgi.framework.BundleContext;
@@ -90,7 +91,7 @@ public class TopicClassificationOSGiTest
     }
 
     // Disabled integration test because SCR configuration factory init is crashing
-    //@Test
+    // @Test
     public void testTopicClassification() throws Exception {
         System.out.println("Running test on bundle: " + context.getBundle());
         ServiceReference reference = context.getServiceReference(ConfigurationAdmin.class.getName());
@@ -99,7 +100,7 @@ public class TopicClassificationOSGiTest
         Configuration config = configAdmin.createFactoryConfiguration(TopicClassificationEngine.class
                 .getName());
         Dictionary<String,String> parameters = new Hashtable<String,String>();
-        parameters.put(TopicClassificationEngine.ENGINE_ID, "testclassifier");
+        parameters.put(EnhancementEngine.PROPERTY_NAME, "testclassifier");
         // TODO: put the coreId of the solr server registered in @Before
         config.update(parameters);