public static double readCorpus(Trie dictTrie,String filepath,
                             HashSet<String> wrongWords
            ) throws IOException {
        BufferedReader reader;
        reader = new BufferedReader((new FileReader(filepath)));

        StringTokenizer lineTokenizer;

        String line;
        String word;
        double numWords = 0;

        TrieNode node;
        Pattern pattern = Pattern.compile("^[A-Za-z]*$");
        Matcher matcher;

        while((line = reader.readLine()) != null)
        {
            lineTokenizer = new StringTokenizer(line," ");
            if(lineTokenizer.countTokens() != 0) {
                word = lineTokenizer.nextToken().toLowerCase();
                matcher = pattern.matcher(word);
                if(matcher.matches()){
                    // records how many words are found
                    numWords++;

                    node = dictTrie.search(word);
                    if (node == null) {
                        // if the query can not be found in
                        // dictionary, then add it into the
                        // HashSet
                        wrongWords.add(word);
                    } else {
                        // if the word is found in dictionary,
                        // add its frequency
                        node.addFrequency();
                    }
                }
            }
        }
        reader.close();

        return numWords;
    }