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

Support resource path syntax #348

Open
tpluscode opened this issue Mar 29, 2023 · 1 comment
Open

Support resource path syntax #348

tpluscode opened this issue Mar 29, 2023 · 1 comment

Comments

@tpluscode
Copy link
Contributor

Defined in: https://w3c.github.io/N3/spec/#paths

Here is an example of a concise rule which drops the unnecessary intermediate variables using the ! for resource paths:

@prefix string: <http://www.w3.org/2000/10/swap/string#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix : <https://example.com/> .

:this :badUrl <http://wrong.com/foo> .

{
  :this :badUrl ?badUrl .


  ?goodUrl log:uri ("http://good.stuff/" ( ?badUrl!log:uri "/(\\w+)$" )!string:scrape)!string:concatenation .
}
=>
{
  :this :goodUrl ?goodUrl .
} .

It fails to parse and would be equivalent to

@prefix string: <http://www.w3.org/2000/10/swap/string#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix : <https://example.com/> .

:this :badUrl <http://wrong.com/foo> .

{
  :this :badUrl ?badUrl .

  ?badUrl log:uri ?badUrlStr .
  ( ?badUrlStr "/(\\w+)$" ) string:scrape ?foo .
  ("http://good.stuff/" ?foo) string:concatenation ?gooUrlStr .
  
  ?goodUrl log:uri ?gooUrlStr .
}
=>
{
  :this :goodUrl ?goodUrl .
} .
@jeswr
Copy link
Collaborator

jeswr commented Mar 29, 2023

Already have this implemented that syntax the v2 branch :), the primary issue was ! and ^ not being recognised at the end of lists. I am working towards having full spec compliance for that updated N3 specification. Will close the issue after v2 release

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

No branches or pull requests

2 participants