OptimaizeLangDetector extends LanguageDetector { @Override public LanguageDetector loadModels() { languages = DEFAULT_LANGUAGES; if (languageProbabilities != null) { detector = createDetector(DEFAULT_LANGUAGE_PROFILES, languageProbabilities); } else { detector = DEFAULT_DETECTOR; } return this; } OptimaizeLangDetector(); @Override LanguageDetector loadModels(); @Override LanguageDetector loadModels(Set<String> languages); @Override boolean hasModel(String language); @Override LanguageDetector setPriors(Map<String, Float> languageProbabilities); @Override void reset(); @Override void addText(char[] cbuf, int off, int len); @Override List<LanguageResult> detectAll(); @Override boolean hasEnoughText();  }
@Test(timeout = 5000) public void testOptimaizeRegexBug() throws Exception { 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()); }