@SuppressWarnings("unchecked")
    private void loadClassifier(File modelDirectory, String modelPrefix) throws JChunkerException {
        ObjectInputStream classifierInputStream = null;
        
        try {
            classifierInputStream = new ObjectInputStream(new FileInputStream(new File(modelDirectory, modelPrefix + CLASSIFIER_FILE_EXTENSION)));
            
            // Get the classifier's class name.
            String classifierClassName = classifierInputStream.readUTF();
            
            // Load the classifier's class.
            Class<? extends Classifier> classifierClass = (Class<? extends Classifier>) Class.forName(classifierClassName);
            classifier = classifierClass.newInstance();
            
            // Load the classifier's model.
            classifier.loadModel(modelDirectory, modelPrefix);
        } catch (FileNotFoundException e) {
            throw new JChunkerException("The classifier settings file was not found.", e);
        } catch (IOException e) {
            throw new JChunkerException("An error occurred when loading the classifier's settings.", e);
        } catch (ClassNotFoundException e) {
            throw new JChunkerException("The classifier's class could not be found.", e);
        } catch (InstantiationException e) {
            throw new JChunkerException("The classifier's class could not be instantiated.", e);
        } catch (IllegalAccessException e) {
            throw new JChunkerException("The classifier's class was not accessed properly.", e);
        } finally {
            try {
                classifierInputStream.close();
            } catch (IOException e) {
                throw new JChunkerException("An error occurred when closing the classifier's settings file.", e);
            }
        }
    }