YalderLangDetector extends LanguageDetector { @Override public LanguageDetector loadModels() throws IOException { models = ModelLoader.loadModelsFromResources(); detector = new HashLanguageDetector(models); return this; } YalderLangDetector(); @Override LanguageDetector loadModels(); @Override LanguageDetector loadModels(Set<String> languages); @Override void addText(char[] cbuf, int off, int len); @Override List<LanguageResult> detectAll(); @Override boolean hasModel(String language); @Override void reset(); @Override LanguageDetector setPriors(Map<String, Float> languageProbabilities); @Override boolean hasEnoughText();  }
@Test public void test() throws Exception { AutoDetectParser parser = new AutoDetectParser(); LanguageDetector detector = new YalderLangDetector().loadModels(); LanguageHandler handler = new LanguageHandler(detector); Metadata metadata = new Metadata(); try (InputStream stream = YalderLangDetectorTest.class.getResourceAsStream("/test-es.txt")) { parser.parse(stream, handler, metadata); } LanguageResult result = handler.getLanguage(); assertEquals("es", result.getLanguage()); assertEquals(LanguageConfidence.HIGH, result.getConfidence()); }