@Override
    public LanguageDetector loadModels() {
        // FUTURE when the "language-detector" project supports short profiles, check if
        // isShortText() returns true and switch to those.

        languages = DEFAULT_LANGUAGES;

        if (languageProbabilities != null) {
            detector = createDetector(DEFAULT_LANGUAGE_PROFILES, languageProbabilities);
        } else {
            detector = DEFAULT_DETECTOR;
        }

        return this;

    }
@Test
    @Timeout(5000)
    public void testOptimaizeRegexBug() throws Exception {
        //confirm TIKA-2777 doesn't affect langdetect's Optimaize
        LanguageDetector detector = new OptimaizeLangDetector().setShortText(false).loadModels();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 50000; i++) {
            sb.append('a');
        }
        detector.detect(sb.toString());
    }