You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by "Aklakan (via GitHub)" <gi...@apache.org> on 2025/10/10 20:12:45 UTC

[PR] RDFS: testing/wrapping/benchmark framework. [jena]

Aklakan opened a new pull request, #3508:
URL: https://github.com/apache/jena/pull/3508

   GitHub issue resolved #3507
   
   Pull request Description: This is mainly infrastructure work to assess RDFS reasoning - and any future changes to it.
   
   * Fixed literals-in-subject inferences (easy fix).
   
   * Added testing framework that compares all combinations of invoking find(). (I hope I didn't overlook an existing system for that).
   * There is a disabled test in `AbstractTestRDFS_Extra` which fails. It uses `:directType rdfs:subPropertyOf rdf:type`.
   * Added infrastructure to ease wrapping `Match` implementations. Added `DatasetGraphWithGraphTransform` base class that can transform any Graph with a Match. For example, In my own code I used a wrapper for MatchRDFS to handle the ANY_ANY_ANY pattern with a distinct-reduce post-processing. I did not include this in this PR because maybe there are better ways to handle this.
   * Added initial benchmark class for the RDFS reasoner.
   ----
   
    - [x] Tests are included.
    - ~[ ] Documentation change and updates are provided for the [Apache Jena website](https://github.com/apache/jena-site/)~
    - [x] Commits have been squashed to remove intermediate development commit messages.
    - [x] Key commit messages start with the issue number (GH-xxxx)
   
   By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).
   
   ----
   
   See the [Apache Jena "Contributing" guide](https://github.com/apache/jena/blob/main/CONTRIBUTING.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-3507: RDFS testing/wrapping/benchmark framework. [jena]

Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3508:
URL: https://github.com/apache/jena/pull/3508#discussion_r2422852854


##########
jena-arq/src/main/java/org/apache/jena/rdfs/engine/ApplyRDFS.java:
##########
@@ -129,10 +129,12 @@ final private void range(X s, X p, X o, Output<X> out) {
                 return;
         }
         Set<X> x = setup.getRange(p);
-        x.forEach(c -> {
-            derive(o, rdfType, c, out);
-            subClass(o, rdfType, c, out);
-        });
+        if (!mapper.isLiteral(o)) {

Review Comment:
   The question is how to minimize materialization in this check. One can check for whether a NodeId is an inlined value and return early. But not sure if from the NodeId alone it can be decided whether its a literal or not.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-3507: RDFS testing/wrapping/benchmark framework. [jena]

Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3508:
URL: https://github.com/apache/jena/pull/3508#discussion_r2422852854


##########
jena-arq/src/main/java/org/apache/jena/rdfs/engine/ApplyRDFS.java:
##########
@@ -129,10 +129,12 @@ final private void range(X s, X p, X o, Output<X> out) {
                 return;
         }
         Set<X> x = setup.getRange(p);
-        x.forEach(c -> {
-            derive(o, rdfType, c, out);
-            subClass(o, rdfType, c, out);
-        });
+        if (!mapper.isLiteral(o)) {

Review Comment:
   The question is how to minimize materialization in this check. One can check for whether a NodeId is an inlined value and return early. But not sure if from the NodeId alone it can be decided whether it's a literal or not.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-3507: RDFS testing/wrapping framework. [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #3508:
URL: https://github.com/apache/jena/pull/3508#issuecomment-3655592190

   > Fixed literals-in-subject inferences due to range declarations (easy fix)
   
   To help me, where exactly is this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-3507: RDFS testing/wrapping framework. [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #3508:
URL: https://github.com/apache/jena/pull/3508#issuecomment-3655587551

   Please could you bring this up-to-date with 6.0.0? Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-3507: RDFS testing/wrapping framework. [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #3508:
URL: https://github.com/apache/jena/pull/3508#issuecomment-3666783673

    >  It uses :directType rdfs:subPropertyOf rdf:type.
   
   In the schema presumably.
   
   Subproperties of the RDFS vocabulary are not intended to be supported by this data-centric RDFS system (rdfs:subClassOf, rdfs:domain, rdfs:range).
   
   "messing around with the scaffolding"
   
   It ought to raise an error in all four cases.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] RDFS: testing/wrapping/benchmark framework. [jena]

Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3508:
URL: https://github.com/apache/jena/pull/3508#discussion_r2422035011


##########
jena-arq/src/test/java/org/apache/jena/rdfs/AbstractTestRDFS_Extra.java:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdfs;
+
+import java.util.List;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+
+public abstract class AbstractTestRDFS_Extra
+    extends AbstractTestRDFS_Find
+{
+     public AbstractTestRDFS_Extra(String testLabel) {
+        super(testLabel);
+     }
+
+     @TestFactory
+     @Disabled("Needs investigation!")
+     public List<DynamicTest> testSubPropertyOfRdfType01() {
+        String schemaStr = """
+            PREFIX :     <http://ex.org/>
+            PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+
+            :directType        rdfs:subPropertyOf rdf:type .
+        """;
+
+        String dataStr = """
+            PREFIX :     <http://ex.org/>
+
+            :fido :directType :Dog .
+        """;
+
+        return prepareRdfsFindTests(schemaStr, dataStr).build();
+     }

Review Comment:
   This produces the failing test cases.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-3507: RDFS testing/wrapping framework. [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs merged PR #3508:
URL: https://github.com/apache/jena/pull/3508


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-3507: RDFS testing/wrapping/benchmark framework. [jena]

Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on PR #3508:
URL: https://github.com/apache/jena/pull/3508#issuecomment-3393303877

   I added a test case that uses the infrastructure to perform a simple RDFS inference on the NodeId level. It's limited because it requires the ontology and the built-in properties to be present in the graph. Rdfs and owl terms would have to be pre-populated in the NodeTable. At least things can now be wired up in the way that seemed to be the intended one by having the generic X.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-3507: RDFS testing/wrapping/benchmark framework. [jena]

Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on code in PR #3508:
URL: https://github.com/apache/jena/pull/3508#discussion_r2422852854


##########
jena-arq/src/main/java/org/apache/jena/rdfs/engine/ApplyRDFS.java:
##########
@@ -129,10 +129,12 @@ final private void range(X s, X p, X o, Output<X> out) {
                 return;
         }
         Set<X> x = setup.getRange(p);
-        x.forEach(c -> {
-            derive(o, rdfType, c, out);
-            subClass(o, rdfType, c, out);
-        });
+        if (!mapper.isLiteral(o)) {

Review Comment:
   Perhaps the method needs to be `isNotLiteral`. I couldn't find a way to determine whether a NodeId is a literal without going through node.
   One can check whether its a non-short-string inline value though.
   Not sure if IRIs can be inlined.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org