PosTagger { public static AnalysisEngineDescription getDescription(String languageCode) throws ResourceInitializationException { String modelPath = String.format("/models/%s-pos-maxent.bin", languageCode); return AnalysisEngineFactory.createEngineDescription( opennlp.uima.postag.POSTagger.class, opennlp.uima.util.UimaUtil.MODEL_PARAMETER, ExternalResourceFactory.createExternalResourceDescription( POSModelResourceImpl.class, PosTagger.class.getResource(modelPath).toString()), opennlp.uima.util.UimaUtil.SENTENCE_TYPE_PARAMETER, Sentence.class.getName(), opennlp.uima.util.UimaUtil.TOKEN_TYPE_PARAMETER, Token.class.getName(), opennlp.uima.util.UimaUtil.POS_FEATURE_PARAMETER, "pos"); }  static AnalysisEngineDescription getDescription(String languageCode);  }
@Test public void test() throws Exception { AnalysisEngine engine = AnalysisEngineFactory.createEngine(PosTagger.getDescription("en")); this.tokenBuilder.buildTokens( this.jCas, "The brown fox jumped quickly over the lazy dog.", "The brown fox jumped quickly over the lazy dog ."); engine.process(this.jCas); List<String> expected = Arrays.asList("DT JJ NN VBD RB IN DT JJ NN .".split(" ")); List<String> actual = new ArrayList<String>(); for (Token token : JCasUtil.select(this.jCas, Token.class)) { actual.add(token.getPos()); } Assert.assertEquals(expected, actual); }