LanguageIdentifier extends JCasAnnotator_ImplBase { @Override public void process(JCas aJCas) throws AnalysisEngineProcessException { String docText = aJCas.getDocumentText(); if (docText != null) { String result = categorizer.categorize(docText); aJCas.setDocumentLanguage(langName2ISO.get(result)); } }  @Override void process(JCas aJCas);  }
@Test public void testEnglish() throws Exception { AnalysisEngine ae = createEngine(LanguageIdentifier.class, createTypeSystemDescription()); JCas aJCas = ae.newJCas(); aJCas.setDocumentText("This is an english file."); ae.process(aJCas); assertEquals("en", aJCas.getDocumentLanguage()); }
@Test public void testGerman() throws Exception { AnalysisEngine ae = createEngine(LanguageIdentifier.class, createTypeSystemDescription()); JCas aJCas = ae.newJCas(); aJCas.setDocumentText("Das ist ein deutsches Dokument."); ae.process(aJCas); assertEquals("de", aJCas.getDocumentLanguage()); }