Skip to content

Commit

Permalink
Remove statements that would result in uncompacted index fields
Browse files Browse the repository at this point in the history
Before this, when new fields were added in the GND source data,
they would result in non-compacted URI field names, since they are
not in the context. This is checked by `checkCompactedProperties.sh`
for the test index, and production indexing is blocked if there are
uncompacted fields. With this change, we remove the statements that
would result in such fields instead and log that as an error.
  • Loading branch information
fsteeg committed Feb 6, 2024
1 parent b077073 commit b0c88f6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/apps/Convert.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,16 @@ private static Model preprocess(Model model, String id, Set<String> deprecated)
String sameAsSchema = "http://schema.org/sameAs";
String preferredName = ELEMENTSET + "gnd#preferredNameFor";
String variantName = ELEMENTSET + "gnd#variantNameFor";
String type = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
String rdfSyntax = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
String type = rdfSyntax + "type";
String label = "http://www.w3.org/2000/01/rdf-schema#label";
String gnd = ELEMENTSET + "gnd#";
String collection = ELEMENTSET + "dnb#isDescribedIn";
String deprecatedUri = ELEMENTSET + "dnb#deprecatedUri";
String describedBy = "http://www.w3.org/2007/05/powder-s#describedby";
Set<Statement> toRemove = new HashSet<>();
Set<Statement> toAdd = new HashSet<>();
String contextAsString = context.toString();
model.listStatements().forEachRemaining(statement -> {
String s = statement.getSubject().toString();
String p = statement.getPredicate().toString();
Expand Down Expand Up @@ -219,6 +221,9 @@ private static Model preprocess(Model model, String id, Set<String> deprecated)
toAdd.add(model.createStatement(statement.getSubject(), statement.getPredicate(),
model.createResource(newType)));
}
} else if (!toRemove.contains(statement) && !p.startsWith(rdfSyntax) && !contextAsString.contains(p)) {
Logger.error("Skipping statement, predicate not found in context: {}", statement);
toRemove.add(statement);
}
});
toRemove.stream().forEach(e -> model.remove(e));
Expand Down

0 comments on commit b0c88f6

Please sign in to comment.