public TextReader(String fileName, WordType type) {
        switch (type) {
            case CATALAN:
                pattern = Pattern.compile("([\\p{L}]+([-\\'][\\p{L}]+)*)|([^\\p{L}-\\']*)");
                break;
            case LETTERS:
                pattern = Pattern.compile("([\\p{L}]+)|([^\\p{L}]*)");
                break;
            case LETTERSorHYPH:
                pattern = Pattern.compile("([\\p{L}-]+)|([^\\p{L}-]*)");
                break;
            case LETTERSorDIGITS:
                pattern = Pattern.compile("([\\p{L}\\p{Digit}]+)|([^\\p{L}\\p{Digit}]*)");
                break;
            case LETTERSorDIGITSorPUNCT:
                pattern = Pattern.compile("([\\p{L}\\p{Digit}\\p{Punct}]+)|" +
                        "([^\\p{L}\\p{Digit}\\p{Punct}]*)");
                break;
            default:
                pattern = Pattern.compile("([\\p{L}-]+)|([^\\p{L}]*)");
        }

        reader = open(fileName);
        try {
            if (reader.ready()) {
                matcher = pattern.matcher(reader.readLine());
            }
        } catch (IOException x) {
            System.err.println(x);
        }
    }