@Override
  public void train(
      List<Pair<BufferedReader, String>> pTrainingData,
      IPreprocessor pPreprocessor,
      ICategoryMapper pMapper)
      throws Exception {

    mClassifier = DynamicLMClassifier.createNGramProcess(getCategories(), NUM_NGRAMS);
    System.out.println("TRAINING UNDERLYING CLASSIFIER");
    for (Pair<BufferedReader, String> datum : pTrainingData) {
      Classification classification = new Classification(pMapper.map(datum.snd));
      String data = pPreprocessor.transform(NLPUtils.toString(datum.fst));

      Classified<CharSequence> classified = new Classified<CharSequence>(data, classification);
      mClassifier.handle(classified);
    }
  }
 static void saveTrainingModel(DynamicLMClassifier mClassifier, String filename, String pos)
     throws IOException {
   System.out.println("-----Saving Model(" + pos + ") to <" + filename + ">-----");
   FileOutputStream fileOut = new FileOutputStream(filename);
   ObjectOutputStream objOut = new ObjectOutputStream(fileOut);
   mClassifier.compileTo(objOut);
   objOut.close();
 }
 @Override
 public String classify(String pInputData) throws IOException, Exception {
   return mClassifier.classify(preprocessor.transform(pInputData)).bestCategory();
 }