From f6d83f0b944e4971fe4ba2ba2690ab4bf72532cb Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Wed, 3 Jun 2020 15:15:58 +0200 Subject: [PATCH] Separate from ontology --- .../java/w2phtml/rdf/DocumentStructure.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/main/java/w2phtml/rdf/DocumentStructure.java b/src/main/java/w2phtml/rdf/DocumentStructure.java index 9ba434f..2525636 100644 --- a/src/main/java/w2phtml/rdf/DocumentStructure.java +++ b/src/main/java/w2phtml/rdf/DocumentStructure.java @@ -32,6 +32,7 @@ public class DocumentStructure { private OntModel m; + private OntModel textOntology; private OntClass excerptClass; private OntClass elementClass; private OntClass itemClass; @@ -41,11 +42,12 @@ public class DocumentStructure { this.elements = new HashMap(); this.inputParts = new HashMap(); this.m = ModelFactory.createOntologyModel(); - m.read(DocumentStructure.class.getResource("/w2phtml/rdf/resources/text_structures.rdf").toString()); - this.excerptClass = m.createClass(TS + EXCERPT); - this.elementClass = m.createClass(TS + TOC_ELEMENT); - this.itemClass = m.createClass(TS + TOCITEM); - this.elenphClass = m.createClass(TS + ELENPHARTICLE); + this.textOntology = ModelFactory.createOntologyModel(); + //textOntology.read(DocumentStructure.class.getResource("/w2phtml/rdf/resources/text_structures.rdf").toString()); + this.excerptClass = textOntology.createClass(TS + EXCERPT); + this.elementClass = textOntology.createClass(TS + TOC_ELEMENT); + this.itemClass = textOntology.createClass(TS + TOCITEM); + this.elenphClass = textOntology.createClass(TS + ELENPHARTICLE); @@ -110,13 +112,11 @@ public class DocumentStructure { e.printStackTrace(); } } - } public void printModel(OutputStream os) { m.write(os,"RDF/XML-ABBREV"); } - private void addPart(DocumentPart docExcerpt) { inputParts.put(docExcerpt.getPath(), docExcerpt); } @@ -128,8 +128,6 @@ public class DocumentStructure { Property htmlExcerpt = m.createProperty(TS + "htmlExcerpt"); excerpt.addLiteral(htmlExcerpt, docExcerpt.getBody()); } - - return excerpt; } @@ -148,7 +146,6 @@ public class DocumentStructure { addMetadataProperties(element,docPart.getMetadata()); elements.put(docPart.getPath(), element); attachExcerpt(docPart, element); - } private void addMetadataProperties(Resource resource, HashMap> metadata) { @@ -161,7 +158,6 @@ public class DocumentStructure { } } } - } private void addMetadata(Resource resource, String name, String value) { if (isNotBlacklisted(name)) { @@ -173,7 +169,6 @@ public class DocumentStructure { Property property = m.createProperty(TS + name); resource.addProperty( property, value); } - } } } @@ -210,8 +205,7 @@ public class DocumentStructure { return true; } } - System.out.println(resource.getNameSpace() + " " + name); - System.out.println("rightNamespace " + TS + EXCERPT ); + System.out.println("Skip " + name + " for " + resource.getNameSpace()); return false; } private String convertName(String name) {