private void ChooseNewCorpus() {
        JFileChooser chooser = new JFileChooser();

        // prompts the user to choose a corpus
        chooser.setDialogTitle("Choose corpus");
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal = chooser.showOpenDialog(null);

        if(returnVal == JFileChooser.APPROVE_OPTION) {
            // prompts the user to choose a tagset
            String corpusPath = chooser.getSelectedFile().getPath();
            chooser.setDialogTitle("Choose tagset");
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            returnVal = chooser.showOpenDialog(null);

            if(returnVal == JFileChooser.APPROVE_OPTION) {
                // prompts the user to choose a simplified tagset
                String tagsetPath = chooser.getSelectedFile().getPath();
                chooser.setDialogTitle("Choose simple tagset");
                chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
                returnVal = chooser.showOpenDialog(null);

                // move the new files into the working directory and reinitialize Viterbi
                if(returnVal == JFileChooser.APPROVE_OPTION) {
                    try {
                        String simpleTagsetPath = chooser.getSelectedFile().getPath();

                        File source = new File(tagsetPath);
                        File destination = new File("corpus_tagset.txt");
                        source.renameTo(destination);

                        source = new File(simpleTagsetPath);
                        destination = new File("corpus_simple_tagset.txt");
                        source.renameTo(destination);

                        Viterbi.loadCorpusForTraining("corpus_tagset.txt", "corpus_simple_tagset.txt", corpusPath, "datafile.txt");
                        v = new Viterbi("corpus_tagset.txt", "corpus_simple_tagset.txt", "datafile.txt");
                        parser = new TextParser(v);
                    } catch (                IOException | WrongFormatException | POSNotFoundException ex) {
                        try {
                            // if the files are invalid, load the backup files
                            v = new Viterbi("backup/corpus_tagset.txt", "backup/corpus_simple_tagset.txt", "backup/datafile.txt");
                            parser = new TextParser(v);
                            JOptionPane.showMessageDialog(null, "Invalid files. Please choose again.", "Error", JOptionPane.PLAIN_MESSAGE);
                        }
                        catch (                IOException | WrongFormatException | POSNotFoundException ex2) {
                            Logger.getLogger(TextEditor.class.getName()).log(Level.SEVERE, null, ex2);
                        }
                    }
                }
            }
        }
    }