Example usage for opennlp.tools.cmdline TerminateToolException TerminateToolException

List of usage examples for opennlp.tools.cmdline TerminateToolException TerminateToolException

Introduction

In this page you can find the example usage for opennlp.tools.cmdline TerminateToolException TerminateToolException.

Prototype

public TerminateToolException(int code, String message, Throwable t) 

Source Link

Usage

From source file:es.ehu.si.ixa.pipe.nerc.train.InputOutputUtils.java

private static TrainingParameters loadTrainingParameters(String paramFile, boolean supportSequenceTraining) {

    TrainingParameters params = null;/*from   www. j  ava  2  s . c o m*/

    if (paramFile != null) {

        checkInputFile("Training Parameter", new File(paramFile));

        InputStream paramsIn = null;
        try {
            paramsIn = new FileInputStream(new File(paramFile));

            params = new opennlp.tools.util.TrainingParameters(paramsIn);
        } catch (IOException e) {
            throw new TerminateToolException(-1, "Error during parameters loading: " + e.getMessage(), e);
        } finally {
            try {
                if (paramsIn != null)
                    paramsIn.close();
            } catch (IOException e) {
                // sorry that this can fail
            }
        }

        if (!TrainUtil.isValid(params.getSettings())) {
            throw new TerminateToolException(1, "Training parameters file '" + paramFile + "' is invalid!");
        }

        if (!supportSequenceTraining && TrainUtil.isSequenceTraining(params.getSettings())) {
            throw new TerminateToolException(1, "Sequence training is not supported!");
        }
    }

    return params;
}