use of org.apache.stanbol.enhancer.engines.dbpspotlight.spot.DBPSpotlightSpotEnhancementEngine in project stanbol by apache.
the class DBPSpotlightDisambiguateEnhancementTest method initTest.
@Before
public void initTest() throws IOException {
//create the contentItem for testing
ci = ciFactory.createContentItem(new StringSource(TEST_TEXT));
assertNotNull(ci);
textContentPart = ContentItemHelper.getBlob(ci, Collections.singleton("text/plain"));
assertNotNull(textContentPart);
//add the language of the text
ci.getMetadata().add(new TripleImpl(ci.getUri(), Properties.DC_LANGUAGE, new PlainLiteralImpl("en")));
assertEquals("en", EnhancementEngineHelper.getLanguage(ci));
LiteralFactory lf = LiteralFactory.getInstance();
//we need also to create a fise:TextAnnotation to test disambiguation
String selected = "Angela Merkel";
Language en = new Language("en");
IRI textAnnotation = EnhancementEngineHelper.createTextEnhancement(ci, new DBPSpotlightSpotEnhancementEngine());
Graph model = ci.getMetadata();
model.add(new TripleImpl(textAnnotation, Properties.ENHANCER_SELECTED_TEXT, new PlainLiteralImpl(selected, en)));
model.add(new TripleImpl(textAnnotation, Properties.ENHANCER_SELECTION_CONTEXT, new PlainLiteralImpl(TEST_TEXT, en)));
model.add(new TripleImpl(textAnnotation, Properties.ENHANCER_START, lf.createTypedLiteral(TEST_TEXT.indexOf(selected))));
model.add(new TripleImpl(textAnnotation, Properties.ENHANCER_END, lf.createTypedLiteral(TEST_TEXT.indexOf(selected) + selected.length())));
model.add(new TripleImpl(textAnnotation, Properties.DC_TYPE, OntologicalClasses.DBPEDIA_PERSON));
//validate that the created TextAnnotation is valid (test the test ...)
EnhancementStructureHelper.validateAllTextAnnotations(model, TEST_TEXT, null);
}
Aggregations