Skip to content

Commit

Permalink
Merge branch 'release/29.x'
Browse files Browse the repository at this point in the history
* release/29.x:
  #4219 - Improve speed of importing a large KB
  #4217 - Speed up properties list loading on KB page
  • Loading branch information
reckart committed Sep 30, 2023
2 parents 8e2fdc4 + 1c9f184 commit 6008c3b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 48 deletions.
4 changes: 0 additions & 4 deletions inception/inception-kb/NOTICE.txt

This file was deleted.

4 changes: 4 additions & 0 deletions inception/inception-kb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-sparqlbuilder</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-common-transaction</artifactId>
</dependency>
<dependency>
<groupId>org.cyberborean</groupId>
<artifactId>rdfbeans</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.lucene.index.IndexFormatTooNewException;
import org.eclipse.rdf4j.common.iteration.Iterations;
import org.eclipse.rdf4j.common.transaction.IsolationLevels;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.ValueFactory;
Expand Down Expand Up @@ -617,6 +618,7 @@ public void importData(KnowledgeBase kb, String aFilename, InputStream aIS)

// Load files into the repository
try (RepositoryConnection conn = getConnection(kb)) {
conn.setIsolationLevel(IsolationLevels.NONE);
// If the RDF file contains relative URLs, then they probably start with a hash.
// To avoid having two hashes here, we drop the hash from the base prefix configured
// by the user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static java.util.stream.Stream.concat;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.and;
import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.bind;
import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.function;
import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.notEquals;
import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.or;
Expand Down Expand Up @@ -115,7 +116,6 @@
import de.tudarmstadt.ukp.inception.kb.graph.KBHandle;
import de.tudarmstadt.ukp.inception.kb.graph.KBObject;
import de.tudarmstadt.ukp.inception.kb.model.KnowledgeBase;
import de.tudarmstadt.ukp.inception.kb.querybuilder.backport.Bind;

/**
* Build queries against the KB.
Expand Down Expand Up @@ -1177,7 +1177,7 @@ private GraphPattern withLabelMatchingAnyOf_RDF4J_FTS(String[] aValues)
.has(FTS_LUCENE, bNode(LUCENE_QUERY, literalOf(fuzzyQuery)) //
.andHas(LUCENE_PROPERTY, VAR_MATCH_TERM_PROPERTY)
.andHas(LUCENE_SNIPPET, var("snippet")))
.and(new Bind(
.and(bind(
function(REPLACE,
function(REPLACE, var("snippet"), literalOf("</B>"),
literalOf("")),
Expand Down Expand Up @@ -1827,9 +1827,10 @@ private GraphPattern isPropertyPattern()

// An item is a property if ...
// ... it is explicitly defined as being a property
propertyPatterns.add(VAR_SUBJECT.has(
PropertyPathBuilder.of(typeOfProperty).then(pSubClass).zeroOrMore().build(),
propertyPatterns.add(VAR_SUBJECT.has(typeOfProperty, propertyIri));
propertyPatterns.add(VAR_SUBJECT.has(PropertyPathBuilder.of(pSubClass).oneOrMore().build(),
propertyIri));
// propertyPatterns.add(VAR_SUBJECT.has(typeOfProperty, propertyIri));
// ... it has any subproperties
propertyPatterns.add(bNode().has(subPropertyProperty, VAR_SUBJECT));
// ... it has any superproperties
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,16 @@ public void nonempty_WithEmptyKnowledgeBase_ShouldReturnTrue(Reification reifica
String[] expectedProps = { kb.getSubclassIri(), kb.getLabelIri(), kb.getDescriptionIri(),
kb.getTypeIri() };

assertEquals(listProperties.size(), 5);
assertThat(listIdentifier).as("Check that base properties are created")
assertThat(listProperties) //
.extracting(KBProperty::getIdentifier) //
.containsExactly( //
"http://www.w3.org/2000/01/rdf-schema#comment",
"http://www.w3.org/2000/01/rdf-schema#label",
"http://www.w3.org/2000/01/rdf-schema#subClassOf",
"http://www.w3.org/2000/01/rdf-schema#subPropertyOf",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
assertThat(listIdentifier) //
.as("Check that base properties are created") //
.contains(expectedProps);
}

Expand Down

0 comments on commit 6008c3b

Please sign in to comment.