use of org.apache.clerezza.commons.rdf.RDFTerm in project stanbol by apache.
the class ContentItemBackendTest method testEnhancements.
@Test
public void testEnhancements() throws LDPathParseException {
String path = "fn:enhancement(.)";
Collection<RDFTerm> result = ldpath.pathQuery(ci.getUri(), path, null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 7);
for (RDFTerm r : result) {
assertTrue(r instanceof IRI);
log.info("Entity: {}", r);
}
//and with a filter
path = "fn:enhancement(.)[rdf:type is fise:TextAnnotation]";
result = ldpath.pathQuery(ci.getUri(), path, null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 3);
// assertTrue(result.contains(new IRI("http://dbpedia.org/resource/Bob_Marley")));
path = "fn:enhancement(.)/dc:language";
result = ldpath.pathQuery(ci.getUri(), path, null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 1);
RDFTerm r = result.iterator().next();
assertTrue(r instanceof Literal);
assertEquals("en", ((Literal) r).getLexicalForm());
}
use of org.apache.clerezza.commons.rdf.RDFTerm in project stanbol by apache.
the class ContentItemBackendTest method testContent.
@Test
public void testContent() throws LDPathParseException {
Collection<RDFTerm> result = ldpath.pathQuery(ci.getUri(), "fn:content(\"text/plain\")", null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 1);
RDFTerm r = result.iterator().next();
assertTrue(r instanceof Literal);
String content = ((Literal) r).getLexicalForm();
assertEquals(content, textContent);
result = ldpath.pathQuery(ci.getUri(), "fn:content(\"text/html\")", null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 1);
r = result.iterator().next();
assertTrue(r instanceof Literal);
content = ((Literal) r).getLexicalForm();
assertEquals(content, htmlContent);
}
use of org.apache.clerezza.commons.rdf.RDFTerm in project stanbol by apache.
the class ContentItemBackendTest method testTextAnnotationFunctionWithoutParsedContext.
@Test
public void testTextAnnotationFunctionWithoutParsedContext() throws LDPathParseException {
String path = "fn:textAnnotation()/fise:selected-text";
Collection<RDFTerm> result = ldpath.pathQuery(ci.getUri(), path, null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 2);
Set<String> expectedValues = new HashSet<String>(Arrays.asList("Bob Marley", "Paris"));
for (RDFTerm r : result) {
assertTrue(r instanceof Literal);
assertTrue(expectedValues.remove(((Literal) r).getLexicalForm()));
}
assertTrue(expectedValues.isEmpty());
//test with a filter for the type
//same as the 1st example bat rather using an ld-path construct for
//filtering for TextAnnotations representing persons
path = "fn:textAnnotation()[dc:type is dbpedia-ont:Person]/fise:selected-text";
result = ldpath.pathQuery(ci.getUri(), path, null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 1);
RDFTerm r = result.iterator().next();
assertTrue(r instanceof Literal);
assertEquals(((Literal) r).getLexicalForm(), "Bob Marley");
}
use of org.apache.clerezza.commons.rdf.RDFTerm in project stanbol by apache.
the class ContentItemBackendTest method testEntityAnnotation.
@Test
public void testEntityAnnotation() throws LDPathParseException {
String path = "fn:entityAnnotation(.)/fise:entity-reference";
Collection<RDFTerm> result = ldpath.pathQuery(ci.getUri(), path, null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 4);
Set<IRI> expectedValues = new HashSet<IRI>(Arrays.asList(new IRI("http://dbpedia.org/resource/Paris"), new IRI("http://dbpedia.org/resource/Bob_Marley"), new IRI("http://dbpedia.org/resource/Centre_Georges_Pompidou"), new IRI("http://dbpedia.org/resource/Paris,_Texas")));
for (RDFTerm r : result) {
assertTrue(r instanceof IRI);
log.info("Entity: {}", r);
assertTrue(expectedValues.remove(r));
}
assertTrue(expectedValues.isEmpty());
//and with a filter
path = "fn:entityAnnotation(.)[fise:entity-type is dbpedia-ont:Person]/fise:entity-reference";
result = ldpath.pathQuery(ci.getUri(), path, null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 1);
assertTrue(result.contains(new IRI("http://dbpedia.org/resource/Bob_Marley")));
}
use of org.apache.clerezza.commons.rdf.RDFTerm in project stanbol by apache.
the class ContentItemBackendTest method testEntityAnnotationWithoutParsedContext.
@Test
public void testEntityAnnotationWithoutParsedContext() throws LDPathParseException {
String path = "fn:entityAnnotation()/fise:entity-reference";
Collection<RDFTerm> result = ldpath.pathQuery(ci.getUri(), path, null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 4);
Set<IRI> expectedValues = new HashSet<IRI>(Arrays.asList(new IRI("http://dbpedia.org/resource/Paris"), new IRI("http://dbpedia.org/resource/Bob_Marley"), new IRI("http://dbpedia.org/resource/Centre_Georges_Pompidou"), new IRI("http://dbpedia.org/resource/Paris,_Texas")));
for (RDFTerm r : result) {
assertTrue(r instanceof IRI);
log.info("Entity: {}", r);
assertTrue(expectedValues.remove(r));
}
assertTrue(expectedValues.isEmpty());
//and with a filter
path = "fn:entityAnnotation()[fise:entity-type is dbpedia-ont:Person]/fise:entity-reference";
result = ldpath.pathQuery(ci.getUri(), path, null);
assertNotNull(result);
assertFalse(result.isEmpty());
assertTrue(result.size() == 1);
assertTrue(result.contains(new IRI("http://dbpedia.org/resource/Bob_Marley")));
}
Aggregations