use of org.apache.stanbol.enhancer.engines.langid.LangIdEnhancementEngine in project stanbol by apache.
the class LangIdEngineTest method testEngine.
/**
* Test the engine and validates the created enhancements
* @throws EngineException
* @throws IOException
* @throws ConfigurationException
*/
@Test
public void testEngine() throws EngineException, IOException, ConfigurationException {
LangIdEnhancementEngine langIdEngine = new LangIdEnhancementEngine();
ComponentContext context = new MockComponentContext();
context.getProperties().put(EnhancementEngine.PROPERTY_NAME, "langid");
langIdEngine.activate(context);
ContentItem ci = ciFactory.createContentItem(new StringSource(text));
langIdEngine.computeEnhancements(ci);
HashMap<IRI, RDFTerm> expectedValues = new HashMap<IRI, RDFTerm>();
expectedValues.put(Properties.ENHANCER_EXTRACTED_FROM, ci.getUri());
expectedValues.put(Properties.DC_CREATOR, LiteralFactory.getInstance().createTypedLiteral(langIdEngine.getClass().getName()));
int textAnnotationCount = validateAllTextAnnotations(ci.getMetadata(), text, expectedValues);
assertEquals("A single TextAnnotation is expected", 1, textAnnotationCount);
// even through this tests do not validate service quality but rather
// the correct integration of the CELI service as EnhancementEngine
// we expect the "en" is detected for the parsed text
assertEquals("The detected language for text '" + text + "' MUST BE 'en'", "en", EnhancementEngineHelper.getLanguage(ci));
int entityAnnoNum = validateAllEntityAnnotations(ci.getMetadata(), expectedValues);
assertEquals("No EntityAnnotations are expected", 0, entityAnnoNum);
}
Aggregations