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

616 domain knowledge facts rules should be loadable via the rest api #624

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

bnouwt
Copy link
Collaborator

@bnouwt bnouwt commented Mar 3, 2025

No description provided.

bnouwt added 3 commits March 3, 2025 12:48
Also:
- created simple unit test for creating the rule.
@bnouwt bnouwt self-assigned this Mar 3, 2025
@bnouwt bnouwt linked an issue Mar 3, 2025 that may be closed by this pull request
@bnouwt bnouwt requested a review from Sophietje March 7, 2025 08:23
Copy link
Collaborator

@Sophietje Sophietje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two additional comments:

  1. I'd recommend adding some tests for edge cases:
    a) try to load an empty string/file
    b) try and load a file with erroneous syntax
    c) try and load a file with valid syntax but that contains something that we don't support (if that's even a thing, if so we should mention it in the docs)

  2. Do we support all syntax from Apache Jena's rule syntax? I saw something about the language tag somewhere. If not, we should include what syntax is supported in the documentation

@bnouwt
Copy link
Collaborator Author

bnouwt commented Mar 7, 2025

Two additional comments:

  1. I'd recommend adding some tests for edge cases:
    a) try to load an empty string/file
    b) try and load a file with erroneous syntax
    c) try and load a file with valid syntax but that contains something that we don't support (if that's even a thing, if so we should mention it in the docs)
  2. Do we support all syntax from Apache Jena's rule syntax? I saw something about the language tag somewhere. If not, we should include what syntax is supported in the documentation

Thanks for the review @Sophietje! A lot of good comments. Regarding the above comments:

1a) Added this case to eu.knowledge.engine.reasoner.api.JenaRuleConversionTest.
1b) This is already tested in eu.knowledge.engine.rest.api.TestDomainKnowledge.testDomainKnowledge().
1c) I've added tests and logic to deal with Builtin primitives which the TKE does not support.
2) I've added a tip about language tags in the documentation 👍

@bnouwt bnouwt requested a review from Sophietje March 7, 2025 20:28
:::

Loading the above domain knowledge into a smart connector will allow its reasoner to derive that every `saref:Sensor` in the network is also a `saref:Device` and whenever a device is requested using the graph pattern `?d rdf:type saref:Device` it will also return data from KIs with the `?s rdf:type saref:Sensor` graph pattern. The default domain knowledge for every smart connector created in a KE Runtime can be configured using the `ke.domain.knowledge.path` configuration property. See [configuration](https://github.com/TNO/knowledge-engine?tab=readme-ov-file#configuration) section for more info.

:::tip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this a warning? (see: https://docusaurus.io/docs/next/markdown-features/admonitions for the options that are available)

if (stringRows.size() > 0) {
if (stringRows.size() > 0)

{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe but this bracket on the same line (l.182) as the if-statement, as we do that for the other if-statements as well

// deal with parse exceptions.
var response = new ResponseMessage();
response.setMessageType("error");
response.setMessage("The provided doman knowledge should parse correctly: " + pe.getMessage());
response.setMessage("The provided doman knowledge should parse correctly: " + e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "doman" -> "domain"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Domain knowledge (facts + rules) should be loadable via the REST API.
2 participants