Skip to content

Commit

Permalink
#4217 - Speed up properties list loading on KB page
Browse files Browse the repository at this point in the history
- Adjust the query for listing properties
- Improve unit test
- Remove backported code that is meanwhile available upstream and can be used
  • Loading branch information
reckart committed Sep 29, 2023
1 parent f9cc0e9 commit 68e47ef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 48 deletions.
4 changes: 0 additions & 4 deletions inception/inception-kb/NOTICE.txt

This file was deleted.

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 68e47ef

Please sign in to comment.