## org.apache.mahout.classifier.bayes.model
Class ClassifierContext

    java.lang.Object
      org.apache.mahout.classifier.bayes.model.ClassifierContext

    public class ClassifierContext

extends java.lang.Object

The Classifier Wrapper used for choosing the `Algorithm` and `Datastore`

Constructor Summary
`ClassifierContext(Algorithm algorithm, Datastore datastore)`

Method Summary
`ClassifierResult` `classifyDocument(java.lang.String[] document, java.lang.String defaultCategory)` Classify the document and return the Result
`ClassifierResult[]` `classifyDocument(java.lang.String[] document, java.lang.String defaultCategory, int numResults)` Classify the document and return the top `numResults`
`java.util.Collection<java.lang.String>` `getLabels()` Gets the labels in the given model
`void` `initialize()` Initializes the Context.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ClassifierContext

    public ClassifierContext(Algorithm algorithm,
                             Datastore datastore)

Method Detail

### initialize

    public void initialize()
                    throws InvalidDatastoreException

  Initializes the Context. Gets the necessary data and checks if the Datastore is valid

  Throws:
    `InvalidDatastoreException`

### classifyDocument

    public ClassifierResult classifyDocument(java.lang.String[] document,
                                             java.lang.String defaultCategory)
                                      throws InvalidDatastoreException

  Classify the document and return the Result

  Parameters:
    `document` - The document to classify
    `defaultCategory` - The default category to assign Ties are broken by comparing the category
  Returns:
    A Collection of `ClassifierResult`s.
  Throws:
    `InvalidDatastoreException`

### classifyDocument

    public ClassifierResult[] classifyDocument(java.lang.String[] document,
                                               java.lang.String defaultCategory,
                                               int numResults)
                                        throws InvalidDatastoreException

  Classify the document and return the top `numResults`

  Parameters:
    `document` - The document to classify
    `defaultCategory` - The default category to assign
    `numResults` - The maximum number of results to return, ranked by score. Ties are broken by comparing the category
  Returns:
    A Collection of `ClassifierResult`s.
  Throws:
    `InvalidDatastoreException`

### getLabels

    public java.util.Collection<java.lang.String> getLabels()
                                                     throws InvalidDatastoreException

  Gets the labels in the given model

  Returns:
    Collection of Labels
  Throws:
    `InvalidDatastoreException`

Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.