Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove statements that would result in uncompacted index fields #374

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading