marf.Classification.Stochastic
Class MaxProbabilityClassifier

java.lang.Object
  extended bymarf.Storage.StorageManager
      extended bymarf.Classification.Classification
          extended bymarf.Classification.Stochastic.Stochastic
              extended bymarf.Classification.Stochastic.MaxProbabilityClassifier
All Implemented Interfaces:
java.lang.Cloneable, IClassification, IStorageManager, java.io.Serializable

public class MaxProbabilityClassifier
extends Stochastic

Maximum Probability Classification Module. Originally came with the LangIdentApp NLP application of Serguei Mokhov.

$Id: MaxProbabilityClassifier.java,v 1.24 2006/02/12 23:57:58 mokhov Exp $

Since:
0.3.0.2
Version:
$Revision: 1.24 $
Author:
Serguei Mokhov
See Also:
Serialized Form

Field Summary
protected  java.util.Vector oAvailLanguages
          A collection of available natural languages.
protected  StatisticalEstimator oStatisticalEstimator
          Local reference to some instance of a statistical estimator for probability computation.
 
Fields inherited from class marf.Classification.Classification
oFeatureExtraction, oResultSet, oTrainingSet
 
Fields inherited from class marf.Storage.StorageManager
bDumpOnNotFound, iCurrentDumpMode, oObjectToSerialize, strFilename
 
Fields inherited from interface marf.Classification.IClassification
MARF_INTERFACE_CODE_REVISION
 
Fields inherited from interface marf.Storage.IStorageManager
DUMP_BINARY, DUMP_CSV_TEXT, DUMP_GZIP_BINARY, DUMP_HTML, DUMP_SQL, DUMP_XML, MARF_INTERFACE_CODE_REVISION, STORAGE_FILE_EXTENSIONS
 
Constructor Summary
MaxProbabilityClassifier(IFeatureExtraction poFeatureExtraction)
          Implements Classification API.
MaxProbabilityClassifier(StatisticalEstimator poStatisticalEstimator)
          NLP constructor that takes directly a statistical estimator.
 
Method Summary
 void backSynchronizeObject()
          Add a piece of general StorageManager contract.
 boolean classify()
          Performs language classification.
 void dump()
          An object must know how dump itself or its data structures to a file.
static java.lang.String getMARFSourceCodeRevision()
          Retrieves class' revision.
 void init(StatisticalEstimator poStatisticalEstimator)
          Initializes the classifier with all member variables.
 void restore()
          An object must know how restore itself or its data structures from a file.
 boolean train()
          Performs training of underlying statistical estimator and goes through restore/dump cycle to save the available languages.
 
Methods inherited from class marf.Classification.Stochastic.Stochastic
getResult
 
Methods inherited from class marf.Classification.Classification
clone, getFeatureExtraction, getResultSet, getTrainingSetFilename, setFeatureExtraction
 
Methods inherited from class marf.Storage.StorageManager
dumpBinary, dumpCSV, dumpGzipBinary, dumpHTML, dumpSQL, dumpXML, enableDumpOnNotFound, equals, getDefaultExtension, getDefaultExtension, getDumpMode, getFilename, hashCode, restoreBinary, restoreCSV, restoreGzipBinary, restoreHTML, restoreSQL, restoreXML, setDumpMode, setFilename, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

oStatisticalEstimator

protected StatisticalEstimator oStatisticalEstimator
Local reference to some instance of a statistical estimator for probability computation.


oAvailLanguages

protected java.util.Vector oAvailLanguages
A collection of available natural languages.

Constructor Detail

MaxProbabilityClassifier

public MaxProbabilityClassifier(StatisticalEstimator poStatisticalEstimator)
NLP constructor that takes directly a statistical estimator.

Parameters:
poStatisticalEstimator - statistical estimator to use

MaxProbabilityClassifier

public MaxProbabilityClassifier(IFeatureExtraction poFeatureExtraction)
Implements Classification API.

Parameters:
poFeatureExtraction - FeatureExtraction module reference
Method Detail

init

public void init(StatisticalEstimator poStatisticalEstimator)
Initializes the classifier with all member variables.

Parameters:
poStatisticalEstimator - statistical estimator to use
Throws:
java.lang.IllegalArgumentException - if poStatisticalEstimator is null

train

public boolean train()
              throws ClassificationException
Performs training of underlying statistical estimator and goes through restore/dump cycle to save the available languages. Implements Classification API.

Specified by:
train in interface IClassification
Overrides:
train in class Stochastic
Returns:
true
Throws:
ClassificationException - should there be a problem with dump/restore

classify

public boolean classify()
                 throws ClassificationException
Performs language classification. Implements Classification API.

Specified by:
classify in interface IClassification
Overrides:
classify in class Stochastic
Returns:
true if classification was successful
Throws:
ClassificationException - if there was a problem with I/O or if there are no available languages

backSynchronizeObject

public void backSynchronizeObject()
Add a piece of general StorageManager contract. Resets available languages vector from the object-to-serialize reference.

Overrides:
backSynchronizeObject in class StorageManager
Since:
0.3.0.5
See Also:
StorageManager.restore()

dump

public void dump()
          throws StorageException
An object must know how dump itself or its data structures to a file. It only uses DUMP_GZIP_BINARY and DUMP_BINARY modes.

Specified by:
dump in interface IStorageManager
Overrides:
dump in class Classification
Throws:
StorageException - if saving to a file for some reason fails or the dump mode set to an unsupported value
Since:
0.3.0.5
See Also:
StorageManager.dumpGzipBinary(), StorageManager.dumpBinary(), backSynchronizeObject()

restore

public void restore()
             throws StorageException
An object must know how restore itself or its data structures from a file. Options are: Object serialization and CSV, HTML. Internally, the method calls all the restore*() methods based on the current dump mode.

Specified by:
restore in interface IStorageManager
Overrides:
restore in class Classification
Throws:
StorageException - if loading from a file for some reason fails or the dump mode set to an unsupported value
Since:
0.3.0.5
See Also:
IStorageManager.DUMP_GZIP_BINARY, IStorageManager.DUMP_BINARY, StorageManager.dumpGzipBinary(), StorageManager.dumpBinary(), backSynchronizeObject(), StorageManager.iCurrentDumpMode

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Retrieves class' revision.

Returns:
revision string


SourceForge Logo