Classification API

Classification is an interface-based framework. The classes provide the following functionalities:

The interface used to train and classify is shown first, followed by the interfaces it references.


1 /**
2 * Client classification interface.
3 */
4 public interface IClassifierProcessor {
5 /**
6 * Set local options for the classifier.
7 * <p/>
8 * This method allows a user to change or initialize an option at runtime.
9 * <p/>
10 * Changes to model-specific options will not be applied until a new model is created.
11 *
12 * @param options the options to add to the local options map.
13 */
14 void setOptions(Map<String, Object> options);
15
16
/**
17 * Get information about the classifier processor.
18 *
19 * @return information about the classifier processor
20 */
21 IClassifierProcessorInfo getClassifierProcessorInfo();
22
23
/**
24 * Get the model manager for this classifier.
25 * <p/>
26 * Provides programmatic access for model management.
27 *
28 * @return the model manager
29 */
30 IModelManager getModelManager();
31
32
/**
33 * Train the classifier.
34 * <p/>
35 * Trains the classifier with positive examples.
36 * <p/>
37 * If a classifier does not support iterative training, it should re-create its model on each invocation.
38 *
39 * @param classToEntityList Map[String=Class's unique id, List of entities for the class]
40 * @throws ClassifierTrainingException type if an error occurs during training.
41 * {@link DuplicateEntityIdException} if a duplicate entity id is encountered, training data is being retained by
42 * the classifier, and {@link DuplicateEntityIdTrainingAction#THROW_EXCEPTION} is set.
43 * If an exception is thrown the state of the underlying memory model is implementation dependent.
44 */
45 void train(Map<String, ? extends List<? extends IEntity>> classToEntityList);
46
47
/**
48 * Remove training from the classifier.
49 * <p/>
50 * Removes examples that were previously added to the model.
51 * <p/>
52 * Not all classifiers may support training removal. If training removal is not supported, the classifier
53 * should always return 0.
54 * <p/>
55 * If a classifier does not support iterative training removal, it should re-create its model on each invocation.
56 *
57 * @param entityIdToRemove ids of previously trained entities that are to be removed from the model
58 * @return the number of entries that were removed from the model
59 */
60 int unTrain(String... entityIdToRemove);
61
62
/**
63 * Classify the entities.
64 *
65 * @param entities collection to be classified
66 * @return classified results - never null
67 */
68 IClassifierResults classify(List<? extends IEntity> entities);
69
70
/**
71 * Get the class labels being used by the classifier
72 * <p/>
73 * If called before a classifier has been trained, an empty set will be returned.
74 *
75 * @return the current class labels - may be empty, never null
76 */
77 Set<String> getClassLabels();
78
79
/**
80 * Remove class labels and all associated training from the model.
81 * <p/>
82 * All classifiers may not support the removal of class labels.
83 *
84 * @param labels the class labels to remove from the model
85 * @return the class labels that were actually removed. This will be the same as the unique labels passed to the
86 * method, unless the model either does not contain the label, or the classifier does not support the
87 * removal of class labels. If non-empty, the set is modifiable.
88 */
89 Set<String> removeClassLabels(String... labels);
90 }

1 /**
2 * Used to access information about a classifier processor.
3 */
4 public interface IClassifierProcessorInfo {
5 /**
6 * Get the classifier processor's id
7 *
8 * @return uniquely identifies the classification engine. Never empty.
9 */
10 String getId();
11
12
/**
13 * Get the classifier processor's display name.
14 *
15 * @return the display name - never empty
16 */
17 String getDisplayName();
18
19
/**
20 * Get the type of classifier processor
21 *
22 * @return the processor type
23 */
24 ClassifierProcessorType getType();
25 }

1 /**
2 * Specifies the type of classifier processor.
3 * <p/>
4 * TextBased classifiers consume entities with any number of attributes whose values
5 * contain arbitrary text. TextBased classifiers have many text preprocessing options.
6 * <p/>
7 * Numeric classifiers consume entities whose attribute count, iteration order, and values
8 * map directly to a pre-defined schema. Numeric classifiers will typically be used in conjunction with
9 * {@link NumericClassifierHelper}.
10 */
11 public enum ClassifierProcessorType {
12 TextBased, Numeric}

1 /**
2 * Handles model creation, initialization, loading, and persistence.
3 */
4 public interface IModelManager {
5 /**
6 * Loads the current model from the persistence store.
7 * <p/>
8 * Calling this method will replace the currently loaded model (if any).
9 */
10 void loadModel();
11
12
/**
13 * Save the current model in memory to the persistence store.
14 */
15 void saveModel();
16
17
/**
18 * Replaces the current memory model with a new, initialized instance.
19 * <p/>
20 * The instance will be initialized with new option settings (if any).
21 * <p/>
22 * The instance will not contain any training.
23 * <p/>
24 * Call {@link #saveModel()} after calling this method to replace the persisted model (if any).
25 */
26 void resetModel();
27
28
/**
29 * Obtain information about the model.
30 *
31 * @return the model's information object
32 */
33 IModelInfo getModelInfo();
34 }

1 /**
2 * Obtain information about the model.
3 */
4 public interface IModelInfo {
5 /**
6 * Get the class labels that have been trained by the model.
7 *
8 * @return an unmodifiable set of class labels, never null
9 */
10 Set<String> getLabels();
11
12
/**
13 * Get entity ids.
14 * <p/>
15 * Get the ids of the entities that have been used to train the model.
16 * <p/>
17 * Entity id retention is implementation specific and may not be supported or enable for
18 * a given model. Implementations that do not support entity id retention should return
19 * an empty set.
20 *
21 * @return an unmodifiable set of unique entity ids, may be empty, never null. If non-empty,
22 * the returned value is a live unmodifiable view of the entity id set.
23 */
24 Set<String> getEntityIds();
25
26
/**
27 * Get the number of instances used to train the model.
28 *
29 * @param classLabels the class labels
30 * @return the instance counts - one for each class label parameter, never null
31 */
32 int[] getTrainingCount(String... classLabels);
33
34
/**
35 * Get the weights assigned by the model.
36 * <p/>
37 * Weights are implementation dependent, but should have a relationship to the importance of
38 * the feature for the class.
39 * <p/>
40 * Weights can be negative.
41 * <p/>
42 * If a model does not contain any training for a given class or does not support this method it should return zero
43 * for all features of the class.
44 * <p/>
45 * Weight's must never be equal to {@link Double#NaN}.
46 *
47 * @param classLabels the class labels
48 * @param features the features
49 * @return matrix of [classLabel][feature] - never null
50 */
51 double[][] getWeights(String[] classLabels, String... features);
52
53
/**
54 * Get the features.
55 *
56 * @param classLabel the class label
57 * @return an unmodifiable set of features that have been trained for the class
58 */
59 Set<String> getFeatures(String classLabel);
60
61
/**
62 * Dumps a copy of the training data that is being retained by the model.
63 *
64 * @return a mutable map of the training data, or null if the model is not retaining training data.
65 * Key: Class label, Value: entities trained for the class
66 */
67 Map<String, List<IEntity>> dumpTrainingData();
68
69
/**
70 * Get the model's schema.
71 *
72 * @return the schema, or null if the implementation does not support a schema.
73 */
74 IEntitySchema getSchema();
75
76
/**
77 * Perform an action on the underlying model
78 * <p/>
79 * This method is provided to allow client code to obtain information about the
80 * underlying model that is not otherwise available.
81 * <p/>
82 * Using this method couples calling code to a specific implementation, so, it should only be used
83 * if absolutely necessary.
84 * <p/>
85 * This method should not be used to train or classify since it circumvents any preprocessing, caching, or metrics
86 * that may be performed or maintained by the framework.
87 *
88 * @param action the action to perform on the model
89 * @return value returned from {@link AbstractModelAction}, may be null.
90 * @throws IllegalArgumentException if the model is not of the expected type
91 */
92 <M, R> R nativeModelAction(AbstractModelAction<M, R> action);
93 }

1 /**
2 * Defines a schema for entity attribute conversion.
3 */
4 public interface IEntitySchema {
5 /**
6 * Get the name of the schema.
7 * @return the schema's name
8 */
9 String getName();
10
11
/**
12 * Get the attribute descriptors.
13 * <p/>
14 * Each descriptor maps to its associated attribute within an entity.
15 * @return the list of attribute descriptors
16 */
17 List<IAttributeDescriptor> getAttributeDescriptors();
18 }

1 /**
2 * Identifies and converts an attribute.
3 */
4 public interface IAttributeDescriptor extends Serializable {
5 /**
6 * Get the text label for the attribute.
7 * @return the attribute's label
8 */
9 String getLabel();
10
11
/**
12 * Get the attribute's transformer.
13 * @return the attribute's transformer
14 */
15 ITransformer getTransformer();
16 }

1 /**
2 * Transforms an attribute's source to its numeric representation.
3 */
4 public interface ITransformer extends Serializable {
5 /**
6 * Get the value used to represent the source.
7 * @param source the source object - pass a null if the source value is unknown
8 * @return the value used to represent the source
9 */
10 double getValue(Object source);
11 }

1 /**
2 * Encapsulates the results returned from a classification processor.
3 */
4 public interface IClassifierResults {
5 /**
6 * Get an array of all classes.
7 * <p/>
8 * See {@link #getEntityToScores}.
9 *
10 * @return class array - will be empty if classifier was passed entities that contained no classifiable data.
11 */
12 String[] getClasses();
13
14
/**
15 * Get the map of entity to scores.
16 *
17 * @return entity to scores map. Will be an empty immutable map if classifier was passed entities that
18 * contained no classifiable data. If non-empty, scores array will be the same length as returned
19 * from {@link #getClasses}
20 */
21 Map<String, double[]> getEntityToScores();
22 }

1 /**
2 * Defines an object to be processed.
3 */
4 public interface IEntity {
5 /**
6 * Get the unique id for the entity.
7 *
8 * @return the entity's unique id
9 */
10 String getId();
11
12
/**
13 * Get the attributes for the entity.
14 *
15 * @return the entity's attributes
16 */
17 List<IAttribute> getAttributes();
18 }

1 /**
2 * Defines a feature of an {@link IEntity}.
3 */
4 public interface IAttribute {
5 /**
6 * The value of the attribute.
7 *
8 * @return the attribute's text, non-null.
9 */
10 String getValue();
11
12
/**
13 * Get the weight for the attribute.
14 *
15 * @return the attribute weight.
16 */
17 double getWeight();
18
19
/**
20 * Set a weight for the attribute.
21 *
22 * @param weight the attribute's weight.
23 */
24 void setWeight(double weight);
25 }


1 /**
2 * Factory class for Classifier Processors.
3 */
4 public interface IClassifierProcessorFactory {
5 /**
6 * Get supported classifier processor ids.
7 * <p/>
8 * @param type the type{s} of processors to return. Calling this method without any parameters
9 * will return the ids for all processors. NOTE: different processor types require different input data.
10 * @return a list of supported classifier processor ids
11 */
12 List<String> getProcessorIds(ClassifierProcessorType... type);
13
14
/**
15 * Get default classifier processor id.
16 * <p/>
17 *
18 * @return the default classifier processor id
19 */
20 String getDefaultProcessorId();
21
22
/**
23 * Gets an instance of the specified classifier processor.
24 * <p/>
25 * The same instance of the specified processor is returned each time this method is called.
26 * <p/>
27 * Use cases that only require a single classifier instance per <code>classifierProcessorId</code>
28 * should use this method since it insulates the code from implementation details regarding the
29 * classifier's model.
30 * <p/>
31 * Also see {@link #getProcessor(String, IPersistenceKey)}.
32 *
33 * @param classifierProcessorId the id for the classifier processor type
34 * @return the classifier processor instance
35 */
36 IClassifierProcessor getProcessor(String classifierProcessorId);
37
38
/**
39 * Gets an instance of the specified classifier processor.
40 * <p/>
41 * The same instance of the specified processor may be returned on subsequent method calls.
42 * <p/>
43 * Provides access to multiple classifier models per <code>classifierProcessorId</code>.
44 * <p/>
45 * Also see {@link #getProcessor(String)}.
46 *
47 * @param classifierProcessorId the id for the classifier processor type
48 * @param persistenceKey used to both find cached instances and facilitate creating new instances.
49 * @return the classifier processor instance
50 */
51 IClassifierProcessor getProcessor(String classifierProcessorId, IPersistenceKey persistenceKey);
52 }

1 /**
2 * Wrapper class for implementation dependent persistence key data.
3 * <p/>
4 * Implementations should always implement <code>Object.hashCode()</code>, <code>Object.equals()</code>,
5 * and <code>toString</code>.
6 */
7 public interface IPersistenceKey {
8 /**
9 * Get a key use to find the instance.
10 *
11 * @return the key
12 */
13 Object getValue();
14 }

1 /**
2 * Helper class for a {@link ClassifierProcessorType#Numeric} type classifier.
3 * <p/>
4 * This class does not persist the model. To do so programmatically, call the
5 * {@link com.sri.dolphin.learning.classification.model.IModelManager#saveModel()} method.
6 * The model manager can be accessed by calling [@link IClassifierProcessor#getModelManager()}.
7 */
8 public class NumericClassifierHelper {
13
14
/**
15 * Creates a classifier helper with a new schema.
16 * <p/>
17 * Any existing training will be removed from the classifier and its model will be initialized with
18 * the provided schema.
19 * @param classifierProcessor the classifier
20 * @param schema the schema
21 * @throws IllegalArgumentException if the classifier is not a type of {@link ClassifierProcessorType#Numeric} classifier.
22 */
23 public NumericClassifierHelper(IClassifierProcessor classifierProcessor, IEntitySchema schema) {
29
30
/**
31 * Creates a classifier helper using the classifiers existing schema.
32 * <p/>
33 * @param classifierProcessor the classifier
34 * @throws IllegalArgumentException if the classifier is not a type of {@link ClassifierProcessorType#Numeric} classifier
35 * or the classifier has not been assigned a schema.
36 */
37 public NumericClassifierHelper(IClassifierProcessor classifierProcessor) {
49
50
/**
51 * Convert column values into an entity.
52 * <p>
53 * Uses the {@link IAttributeDescriptor}s defined for the schema to convert the column values into
54 * entity attributes.
55 *
56 * @param id the entity id
57 * @param columnValues the column values
58 * @return the created entity
59 * @throws IllegalArgumentException if the number of column values do not match the number of
60 * attributes defined for the schema or if the column values differ from what is defined in the schema
61 */
62 public IEntity toEntity(String id, Object... columnValues) {
66
67
/**
68 * Get the classifier processor.
69 * @return the classifier processor used to construct this instance.
70 */
71 public IClassifierProcessor getClassifierProcessor() {
74
75
/**
76 * Get a UI component that graphically explains the reason for an entity's classification.
77 * <p/>
78 * If the classifier does not support a graphic presentation, an empty JPanel will be
79 * returned.
80 *
81 * @param entity the entity
82 * @return the Swing component
83 */
84 public JComponent explain(IEntity entity) {

Entity Processing

The framework provides a number of Entity preprocessing options that can be set using the Classification Options Management GUI that is descibed later in this document.

Coding Example

Text Based Classifiers

The following snippet from the classification example program ClassificationExample shows the classification API calls for text-based classifiers.

The example can be run by unzipping the deployable zip and executing the classify.bat file that is contained within the examples directory. The example runs all text-based classification algorithms and can output quite a bit of text. You may wish to redirect the output to a text file (i.e.: classify.bat > classify.out.txt) and view it in a text edtor.

See the JavaDoc for more information on the API.
 1     public static void main(String[] args) {
2 final String margin = " ";
3 IClassifierProcessorFactory factory = ClassifierProcessorFactoryLocator.getFactory();
4
5
List<String> processorIds = factory.getProcessorIds(ClassifierProcessorType.TextBased);
6 Map<String, List<IEntity>> trainingData = getTrainingData();
7 List<IEntity> dataToClassify = getEntitiesToClassifier();
8
9
logMsg("Available classifiers processors: " + processorIds);
10 logMsg("Default processor: [" + factory.getDefaultProcessorId() + ']');
11 logMsg("Training data");
12 logMsg(formatEntities(trainingData, margin));
13 logMsg("");
14 logMsg("Data to classify");
15 logMsg(formatEntities(dataToClassify, margin));
16 logMsg("");
17
18
for (String classifierProcessorId : factory.getProcessorIds(ClassifierProcessorType.TextBased)) {
19 logMsg("Using [" + classifierProcessorId + ']');
20 IClassifierProcessor processor = factory.getProcessor(classifierProcessorId);
21 // Remove any training from prior runs.
22 processor.getModelManager().resetModel();
23 processor.train(trainingData);
24 IClassifierResults results = processor.classify(dataToClassify);
25 logMsg(formatResults(dataToClassify, results, margin, processor));
26 logMsg("");
27 }
28 }
The following are snippets of console output from the example program:
Available classifiers processors: [naive-bayes, maxent]
Default processor: [naive-bayes]

Training data
Class: Cars
Entity{id='8', attributes=[Attribute{value='toyota', weight=1.0}]}
Entity{id='9', attributes=[Attribute{value='detroit', weight=1.0}]}
...
Class: The Roman Empire
Entity{id='5', attributes=[Attribute{value='The Roman Empire', weight=1.0},
Attribute{value='Romans', weight=1.0},
Attribute{value='Caesar', weight=1.0},
Attribute{value='Brutus', weight=1.0},
Attribute{value='Cassius', weight=1.0}]}
...
Data to classify
Entity{id='14', attributes=[Attribute{value='William Shakespeare', weight=1.0},
Attribute{value='Much Ado about Nothing', weight=1.0}]}
...

Using [naive-bayes]

Classes: [Cars, William Shakespeare, The Roman Empire]

Entity Id=14
Result{classLabel='William Shakespeare', score=1.0}
Result{classLabel='The Roman Empire', score=0.0}
Result{classLabel='Cars', score=0.0}
...
Entity Id=16
Result{classLabel='William Shakespeare', score=0.9233059256318519}
Result{classLabel='The Roman Empire', score=0.07669407436814817}
Result{classLabel='Cars', score=0.0}
...

Numeric Classifiers

The following snippet from the classification example program DecisionTreeExample shows the classification API calls using the decision tree classifier.

The example can be run by unzipping the deployable zip and executing the decisionTree.bat file that is contained within the examples directory.
A small GUI window will pop-up towards the end of the program that helps to explain the results displayed on the console output window.
 1 /**
2 * Example of using the Decision Tree classifier.
3 */
4 public class DecisionTreeExample {
5
6
public static void main(String[] args) {
7 // Create a schema that defines the columns for the rows of data that will be used to train and classify.
8 IEntitySchema schema = getSchema();
9
10
IClassifierProcessor classifierProcessor =
11 ClassifierProcessorFactoryLocator.getFactory().getProcessor(ClassifierConstants.DECISION_TREE_ID);
// The helper class simplifies coding when using a decision tree classifier.
12 NumericClassifierHelper nch = new NumericClassifierHelper(classifierProcessor, schema);
13 Map<String, List<IEntity>> trainingData = getTrainingData(nch);
14
15
classifierProcessor.train(trainingData);
16
17
// Classify the first Extremely Important entry contained in the training data set
18 IEntity entityToClassify = trainingData.get(E_IMPORTANT).get(0);
19
20
List<ResultsUtil.IResult> results = ClassifierUtil.classify(classifierProcessor, entityToClassify);
21
22
// Display the results of the classification
23 for (ResultsUtil.IResult result : results) {
24 System.out.println("Class Label=" + result.getClassLabel() + ", Score=" + result.getScore());
25 }
26
27
// Display a graphical explanation of the entity's classification
28 WindowFrame frame = WindowFrame.newInstance();
29 frame.getMainPanel().add(nch.explain(entityToClassify));
30 frame.display();
31 }
32
33
/**
34 * Converts the training examples into a training data map.
35 * <p/>
36 * Uses the {@link NumericClassifierHelper#toEntity(String, Object...)} method to convert
37 * a training data row into an entity for use by the classifier processor.
38 * @param nch the NumericClassifierHelper
39 * @return the class/entity map of training data
40 */
41 private static Map<String, List<IEntity>> getTrainingData(NumericClassifierHelper nch) {
...
57
private static IEntitySchema getSchema() {
58 return new EntitySchemaBuilder("MeetingImportance")
59 .addCategory("Location",
60 "unknown", "Room 100", "Room 200", "Room 300")
61 .addCategory("Type",
62 "other", "talk", "tech", "admin")
63 .addNumeric("Number Of Participants",
64 2, 5, 10, 20, 50)
65 .addBoolean("Host is Project Leader")
66 .addBoolean("Host is Senior Management")
67 .addBoolean("Project Leader is Attending")
68 .addBoolean("Senior Management is Attending")
69 .addBoolean("Visitor Is Attending")
70 .build();
71 }
73
// Define the classes to use to categorize the data
74 private static final String E_IMPORTANT = "EXTREMELY_IMPORTANT";
75 private static final String V_IMPORTANT = "VERY_IMPORTANT";
76 private static final String IMPORTANT = "IMPORTANT";
77 private static final String S_IMPORTANT = "SOMEWHAT_IMPORTANT";
78
79
private static Object[][] getTrainingExamples() {
80 return new Object[][]
81 // Column titles/abbreviations:
82 // Class Location Type NP HIPL HISM PLIA SMIA VIA
83 {
84 {IMPORTANT, "Room 100", "admin", 3, true, false, true, false, false},
85 {IMPORTANT, "Room 200", "tech", 3, true, false, true, false, false},
86 {V_IMPORTANT, "Room 100", "tech", 4, true, false, true, false, true},
87 {V_IMPORTANT, "Room 200", "tech", 10, true, false, true, false, true},
88 {E_IMPORTANT, "Room 100", "tech", 5, true, true, true, true, true},
89 {E_IMPORTANT, "Room 100", "tech", 50, true, true, true, true, true},
90 {E_IMPORTANT, "Room 100", "admin", 30, true, true, true, true, true},
91 {S_IMPORTANT, "Room 100", "talk", 20, true, true, true, true, false},
92 {S_IMPORTANT, "Room 200", "talk", 40, true, true, true, false, false},
93 {S_IMPORTANT, "Room 300", "talk", 3, false, false, false, false, false}
94
95
};
96 }
97 }
The following is the last portion of console output from running the above program:

DEBUG MinorThirdDecisionTreeClassifier - Classifier trained: class com.sri.dolphin.learning.classification.classifiers.decisiontree.MinorThirdDecisionTreeClassifier
    Schema: MeetingImportance
    Schema Features: [Location, Type, Number Of Participants, Host is Project Leader, Host is Senior Management, Project Leader is Attending, Senior Management is Attending, Visitor Is Attending]
    Class: EXTREMELY_IMPORTANT, Entities: 3
    Class: SOMEWHAT_IMPORTANT, Entities: 3
    Class: IMPORTANT, Entities: 2
    Class: VERY_IMPORTANT, Entities: 2

Class Label=EXTREMELY_IMPORTANT, Score=0.7741191162036944
Class Label=IMPORTANT, Score=0.07902667346496757
Class Label=VERY_IMPORTANT, Score=0.07902667346496757
Class Label=SOMEWHAT_IMPORTANT, Score=0.06782753686637023

See the JavaDoc for more information on the API.

Configuration

The framework is initialized using Spring configuration files. The following is the main configuration file.

 1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xmlns:util="http://www.springframework.org/schema/util"
5 xsi:schemaLocation="
6 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"
8 default-autowire="no" default-lazy-init="true">
9
10
<import resource="directories.xml"/>
11 <import resource="resources.xml"/>
12
13
<import resource="optionMap.xml"/>
14 <import resource="optionMapEntryDescriptors-textPrep.xml"/>
15 <import resource="classification-optionMapEntryDescriptors.xml"/>
16
17
<import resource="classification-parent-dir.xml"/>
18 <import resource="classification-naiveBayesProcessor.xml"/>
19 <import resource="classification-naiveBayes-optionMapEntryDescriptors.xml"/>
20 <import resource="classification-maxEntProcessor.xml"/>
21 <import resource="classification-maxEnt-optionMapEntryDescriptors.xml"/>
22 <import resource="classification-decisionTreeProcessor.xml"/>
23 <import resource="classification-decisionTree-optionMapEntryDescriptors.xml"/>
24
25
<import resource="classification-options-ui-display-controller.xml"/>
26
27
<!--
28 Alternate Caching implementations
29
30
<bean id="classification.processorCache" class="com.sri.dolphin.util.cache.SoftMapLruCache">
31 <constructor-arg value="4"/>
32 </bean>
33
34
<bean id="classification.processorCache" class="com.sri.dolphin.util.cache.LruCacheMap">
35 <constructor-arg value="4"/>
36 </bean>
37
38
// Turns off caching
39 <bean id="classification.processorCache" class="com.sri.dolphin.util.cache.NullCache"/>
40 -->
41
42
<bean id="classification.processorCache" class="com.sri.dolphin.util.cache.NullCache"/>
43
44
<bean id="classification.classifier-processor-factory"
45 class="com.sri.dolphin.learning.classification.ClassifierProcessorFactory"
46 init-method="init">
47 <property name="processorCache" ref="classification.processorCache">
48 <description>
49 The processor cache is only used if
50 IClassifierProcessorFactory.getProcessor(String classifierProcessorId, String modelKey) is called.
51 </description>
52 </property>
53 <property name="classifierProcessors">
54 <description>
55 The first entry in the list is the default.
56 </description>
57 <util:list value-type="com.sri.dolphin.learning.classification.AbstractClassifierProcessor">
58 <ref bean="classification-naiveBayesProcessor"/>
59 <ref bean="classification-maxEntProcessor"/>
60 <ref bean="classification-decisionTreeProcessor"/>
61 </util:list>
62 </property>
63 </bean>
64
65
<bean id="classification.processor" abstract="true"
66 class="com.sri.dolphin.learning.classification.AbstractClassifierProcessor" init-method="init">
67 <property name="languageResourceManager" ref="resources.languageManager"/>
68 </bean>
69
70
</beans>

Classification Options Management GUI

The Classification Options Management GUI is a small utility that allows a user to easily view all options that are available for a given algorithm and change their default settings.

The GUI can be run by unzipping the deployable zip and executing the classify-options-ui.bat file that is contained within the examples directory.

ClassificationOptionsGUI

The buttons at the bottom of the GUI perform the following actions:

Saved changes are persisted to an XML file that is used for subsequent classification requests.

A brief description of a field can be displayed by hovering the mouse cursor over a field's label.

Resource Editor GUI

The Resource Editor GUI is a small utility that allows a user to view and edit the resource files supported by the framework.

The resource files are used by the framework for Entity preprocessing if the Standard tokenizer is selected and the specific resource feature is enabled. The following resource file types are currently supported: stopwords, stoplabels, wordAliases, and textReplacements. Documentation on each resource file type is contained at the top of the English version of  the resource file.

The GUI can be run by unzipping the deployable zip and executing the resource-editor-ui.bat file that is contained within the examples directory.



The user selects the language using the drop-down list at the top left of the screen and the resource type from the drop-down list at the top right.

The buttons at the bottom of the GUI perform the following actions:

If the text contained in the editor has been modified, both drop-down lists will be disabled, and the Save and Reset buttons will be enabled.  The user can Undo or Redo text modifications using the options from the Edit menu. The editor will not allow a resource file to be saved if it would fail validation.