@Test
public void testEngineDe() throws IOException, EngineException {
ContentItem ci = ciFactory.createContentItem(new StringSource(de_text));
Assert.assertNotNull(ci);
AnalysedText at = atFactory.createAnalysedText(ci, ci.getBlob());
Assert.assertNotNull(at);
ci.getMetadata().add(new TripleImpl(ci.getUri(), DC_LANGUAGE, new PlainLiteralImpl("de")));
Assert.assertEquals("de", EnhancementEngineHelper.getLanguage(ci));
//Add some Tokens with POS annotations to test the usage of
//existing POS annotations by the lemmatizer
Token verbrachten = at.addToken(de_verbStart,de_verbStart+de_verb.length());
verbrachten.addAnnotation(POS_ANNOTATION, Value.value(
new PosTag("V",LexicalCategory.Verb), de_verbProb));
Token schonen = at.addToken(de_adjectiveStart,de_adjectiveStart+de_adjective.length());
schonen.addAnnotation(POS_ANNOTATION, Value.value(
new PosTag("ADJ",LexicalCategory.Adjective), de_adjectiveProb));
Token urlaub = at.addToken(de_nounStart,de_nounStart+de_noun.length());
urlaub.addAnnotation(POS_ANNOTATION, Value.value(
new PosTag("NC",LexicalCategory.Noun), de_nounProb));
Assert.assertEquals("Can not enhance Test ContentItem",
EnhancementEngine.ENHANCE_ASYNC,engine.canEnhance(ci));
//compute the enhancements
try {
engine.computeEnhancements(ci);
} catch (EngineException e) {
RemoteServiceHelper.checkServiceUnavailable(e);
return; //deactivate test
}
//now validate the enhancements
boolean foundVerb = false;
boolean foundAdjective = false;
boolean foundNoun = false;
for(Iterator<Token> tokens = at.getTokens(); tokens.hasNext();){
Token token = tokens.next();
log.info("Token: {}",token);
List<Value<MorphoFeatures>> mfs = token.getAnnotations(NlpAnnotations.MORPHO_ANNOTATION);
if(de_verb.equals(token.getSpan())){
foundVerb = !mfs.isEmpty();