Milos Bejda - All Things Automated

Using the Stanford Classifier with Node.js

The Stanford Classifier is a powerful classifying library that is freely available for anyone to use. Given the right amount of data, it can be used to classify blocks of texts with good accuracy. Lets get started with using the Stanford Classifier in Node.js.

Getting Started

Install the stanford-classifier Node.js module from the npm repository. The stanford-classifier Node.js module uses Stanford Classifier v3.5.2 internally and has node-java as a dependency. Your environment should have Java properly configured to work with node-java. You can learn more about node-java configurations here. To install the stanford-classifier run the following in the terminal:

Dataset

The classifier needs to be trained with pre-trained data. Without trained data, the classifier will not work as expected and will not be accurate. Regardless of which classification algorithm is being used, the classifier needs a robust dataset to yield accurate classifications. I built a small dataset that contains organization and band Twitter descriptions. The dataset can be used to train the stanford-classifier. It can be downloaded here.

Training And Classifying The Classifier

The train() method is used to train the stanford-classifier with a pre-trained dataset. Here is an example of how to use the train() method to train the stanford-classifier.