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

feat: support CURIES in config #60

Open
cmdoret opened this issue Dec 17, 2024 · 4 comments
Open

feat: support CURIES in config #60

cmdoret opened this issue Dec 17, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@cmdoret
Copy link
Member

cmdoret commented Dec 17, 2024

due to the lack of inference, tripsu configs can be very redundant.
To reduce this redundancy, we could support compact uris using something like this in the config file:

prefixes:
  "schema": "<https://schema.org/>"
  "ex": "<http://example.org/>"

nodes:
  of_type:
    - "schema:Person"
    - "schema:Organization"

objects:
  on_type_predicate:
    "schema:Person":
        - "schema:birthPlace"
  on_predicate:
     - "ex:password"
     - "ex:email"
     - "ex:userName"
@cmdoret cmdoret changed the title feat: support cURIes feat: support CURIES Dec 17, 2024
@cmdoret cmdoret changed the title feat: support CURIES feat: support CURIES in config Feb 13, 2025
@supermaxiste
Copy link
Member

When looking for crates to carry out the task, I first checked sophia and the only thing I found was about IRIs: https://docs.rs/sophia_iri/0.9.0/sophia_iri/index.html
Otherwise there seems to be a (relatively new) crate dedicated to cURIs: https://lib.rs/crates/curies

Unless there's a strong opinion, I'd go for the second option since it seems to be fitting the cause (even though very very new).

@supermaxiste
Copy link
Member

Expand ont eh Rules struct with an optional prefixes field.
Have impl on Rules struct to:

  • Expand cURIes when prefixes are there (+test)
  • Throw an error when cURIes are there but no prefixes are provided (+test)

Important: be consistent in the formatting of the URI, CURIES crate doesn't use <>, https://biopragmatics.github.io/curies.rs/getting-started/#loading-prefix-maps

@supermaxiste
Copy link
Member

Switch from curies to https://github.com/endoli/curie.rs/tree/main

@supermaxiste
Copy link
Member

I made some pretty decent progress on this feature and I have to admit that it looks easier in theory than in practice.

This is the high-level flow of the PR so far:

flowchart TD    
    return(Return expanded cURIs)
    flow(Normal tripsu flow)
    rules.yaml --> has_valid_curies_and_uris
    has_valid_curies_and_uris --> |no| Error
    has_valid_curies_and_uris --> |yes| return
    return --> flow
Loading

The code for has_valid_curies_and_uris is in place with a bunch of functions to:

  1. Make sure full URIs are compliant with sophia_iri:IRI
  2. Make sure cURIes are "expandable" based on the prefixes provided

The missing pieces and to dos are the following:

  • A .filter function for Rules to select cURIes or URIs depending on the downstream code
  • Tests for:
    1. No prefixes provided, cURIes in the config --> FAIL
    2. Prefixes provided, cURIes using an undefined prefix --> FAIL
    3. Prefixes provided, no cURIes in the config --> PASS
    4. Prefixes provided, cURIes using them --> PASS
    5. Valid URIs in the config --> PASS
    6. Invalid URIs in the config --> FAIL

@supermaxiste supermaxiste self-assigned this Mar 27, 2025
@supermaxiste supermaxiste added the enhancement New feature or request label Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants