Split keywords

This commit is contained in:
Georgy Litvinov 2020-05-21 13:58:34 +02:00
parent 7137414a54
commit 9cb3dc4b8d

View file

@ -41,6 +41,7 @@ public class DocumentStructure {
this.elements = new HashMap<String, Resource>();
this.inputParts = new HashMap<String, DocumentPart>();
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);
@ -166,11 +167,27 @@ public class DocumentStructure {
if (isNotBlacklisted(name)) {
name = convertName(name);
if (isDefinedInOntology(resource,name)) {
Property property = m.createProperty(TS + name);
resource.addProperty( property, value);
if (name.equals("keywords")) {
addKeywords(resource, name, value);
} else {
Property property = m.createProperty(TS + name);
resource.addProperty( property, value);
}
}
}
}
private void addKeywords(Resource resource,String name, String value) {
String[] keywords = value.split(",");
for (int i = 0; i < keywords.length; i++) {
String keyword = keywords[i].trim();
if (!keyword.isEmpty()) {
Property property = m.createProperty(TS + name);
resource.addProperty( property, keyword);
}
}
}
private boolean isDefinedInOntology(Resource resource, String name) {
String nameSpace = resource.getNameSpace();
if (nameSpace.contains(TS + EXCERPT)) {