SentenceSplitter { public void train(InstanceList instList, Pipe dataPipe) { long s1 = System.currentTimeMillis(); model = new CRF(instList.getPipe(), (Pipe) null); model.addStatesForLabelsConnectedAsIn(instList); CRFTrainerByLabelLikelihood crfTrainer = new CRFTrainerByLabelLikelihood(model); boolean b = crfTrainer.train(instList); LOGGER.info("SentencesSplitter training: model converged: " + b); long s2 = System.currentTimeMillis(); model.getInputPipe().getDataAlphabet().stopGrowth(); trained = true; LOGGER.info("training time: " + (s2 - s1) / 1000 + " sec"); } SentenceSplitter(); Instance makePredictionData(ArrayList<String> lines, Pipe myPipe); Instance makePredictionData(File predictFile, Pipe myPipe); InstanceList makePredictionData(File[] predictFiles, Pipe myPipe); InstanceList makeTrainingData(File[] trainFiles, boolean useTokenOffset, boolean splitUnitsAfterPunctuation); void train(InstanceList instList, Pipe dataPipe); List<Unit> predict(List<String> lines, String postprocessingFilter); List<Unit> predict(Instance inst, String filterName); ArrayList<String> getLabelsFromLabelSequence(LabelSequence ls); void writeModel(String filename); void readModel(File file); void readModel(InputStream is); ArrayList<String> readFile(File myFile); CRF getModel();  }
@Test public void testTrain() throws Exception { File[] trainFiles = getTrainFiles(); SentenceSplitter sentenceSplitter = new SentenceSplitter(); InstanceList trainData = sentenceSplitter.makeTrainingData(trainFiles, false, false); Pipe trainPipe = trainData.getPipe(); sentenceSplitter.train(trainData, trainPipe); sentenceSplitter.writeModel(FILENAME_TRAIN_MODEL_OUTPUT); assertTrue(new File(FILENAME_TRAIN_MODEL_OUTPUT + ".gz").isFile()); }