Commit 35a9b46a authored by acoburn's avatar acoburn
Browse files

Additional code refinement

parent aa1111ec
# Comma separated list of ontologies that should pulled in for entailment to be done on them
rdfs.ontologies=http://purl.org/dc/terms/,http://purl.org/dc/elements/1.1/,http://id.loc.gov/ontologies/bibframe/,http://www.w3.org/2004/02/skos/core#,http://www.w3.org/2000/01/rdf-schema#
rdfs.ontologies= \
http://purl.org/dc/terms/, \
http://www.w3.org/2004/02/skos/core#
......@@ -52,7 +52,7 @@ public class EntailmentServiceImpl implements EntailmentService {
private static final Lang DEFAULT_LANG = TURTLE;
private InfModel rdfsModel = createRDFSModel(createDefaultModel());
private InfModel schema = createRDFSModel(createDefaultModel());
static {
setDefaultHttpClient(create().setRedirectStrategy(new LaxRedirectStrategy()).build());
......@@ -69,7 +69,7 @@ public class EntailmentServiceImpl implements EntailmentService {
LOGGER.info("EntailmentServiceImpl: ontologies: {}", ontologies);
stream(ontologies.split(",")).peek(ont -> LOGGER.info("adding to rdfs model: {}", ont))
.map(String::trim).forEach(ont -> read(rdfsModel, ont));
.map(String::trim).forEach(ont -> read(schema, ont));
}
@Override
......@@ -77,22 +77,15 @@ public class EntailmentServiceImpl implements EntailmentService {
final String contentType, final String acceptType) {
final Model model = createDefaultModel();
read(model, input, contentTypeToLang(contentType.split(";")[0]));
// perform RDFS entailment over it by creating a RDFSModel
final InfModel fullModel = createRDFSModel(model);
// add the requested ontologies to the model, which does RDFS entailment over them.
fullModel.add(rdfsModel);
final Model entailed = createDefaultModel();
entailed.setNsPrefixes(model);
fullModel.listStatements()
createRDFSModel(schema, model).listStatements()
// We don't care about rdfs:Class and rdfs:Resource types
.filterDrop(s -> isRdfsClass(s) || isRdfsResource(s))
.filterDrop(t -> rdfsModel.contains(t.getSubject(), null))
.filterDrop(t -> schema.contains(t.getSubject(), null))
.forEachRemaining(entailed::add);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
......
......@@ -9,7 +9,7 @@
<cm:property-placeholder persistent-id="edu.amherst.acdc.services.entailment" update-strategy="reload" >
<cm:default-properties>
<cm:property name="rdfs.ontologies" value=""/>
<cm:property name="rdfs.ontologies" value="http://purl.org/dc/terms/,http://www.w3.org/2004/02/skos/core#"/>
</cm:default-properties>
</cm:property-placeholder>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment