Grails plugin for text classification with bayes classifiers

2010/08/22 — Leave a comment

I just released the first version of the grails-bayes plugin on github.

The plugin brings very easy to use text classification via bayes classifiers to Grails. By default the plugin runs with a simple set up that contains one classifier for all trained text but allows to configure multiple classifiers, word listers (stemmers) by a grouping key.
It uses ci-bayes under the hood. ci-bayes allows using different implementation of classifiers (the algorithms on which the classification is based) and word listers (splitting up text into single parts that are the building blocks for the data collection for the classification). The plugin uses the FisherClassifierImpl as the default classifier and the SimpleWordLister as the default word lister.

Installation
Simply install via

grails install-plugin bayes

Basic usage

class MyController {
  def bayesClassifierService
  /**
   * Trains 'someText' to be of 'someCategory'
   */ 
  def train = {
    bayesClassifierService.train(params.someText, params.someCategory)
  }

/**
* Determine the classification of ‘someText’
*/
def classifyText = {
def classification = bayesClassifierService.classifyText(params.someText)
['classification':classification]
}
}

As you see you can train the classifier with

bayesClassifierService.train(String text, String category)

and then determine the classification of a text with

bayesClassifierService.classifyText(String classifyThis)

That’s it for the start. I will write up more on how to configure multiple classifiers and word listers soon.

pstehlik

Posts