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

Preliminary support for reasoning over SPARQL query results #569

Closed
5 tasks done
mmarx opened this issue Dec 14, 2024 · 0 comments
Closed
5 tasks done

Preliminary support for reasoning over SPARQL query results #569

mmarx opened this issue Dec 14, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request io
Milestone

Comments

@mmarx
Copy link
Member

mmarx commented Dec 14, 2024

We can already load EDB predicates from external sources. In theory, this could be used to query SPARQL endpoints such as the Wikidata Query Service. In practice, this results in unreadable, hardcoded IRIs and depends on the endpoint to send the results in the correct format.

Building upon #566 and #564, we can improve the ergonomics of such queries by adding a builtin and slightly generalising existing syntax, allowing, e.g.:

@import awards :- tsv{ resource=f"https://query.wikidata.org/sparql?query={URIENCODE(?query)}",
                       format=(iri, string)
                     },
               ?query = "SELECT ?award ?awardLabel WHERE { wd:Q42 wdt:P166 ?award . ?award rdfs:label ?awardLabel FILTER(LANG(?awardLabel) = \"en\")"
@mmarx mmarx added enhancement New feature or request io labels Dec 14, 2024
@mmarx mmarx added this to nemo Dec 14, 2024
@github-project-automation github-project-automation bot moved this to Todo in nemo Dec 14, 2024
mmarx added a commit that referenced this issue Jan 4, 2025
@mmarx mmarx self-assigned this Jan 7, 2025
@mmarx mmarx added this to the Release 0.7.0 milestone Jan 7, 2025
matzemathics added a commit that referenced this issue Jan 8, 2025
Addresses #569. Based on #564 and #566, so should be merged after those.

With this, we can run the following program:
```prolog
@import awards :- tsv{ resource=f"https://query.wikidata.org/sparql?query={URIENCODE(?query)}",
                       format=(any, string)
                     },
               ?query = """
    SELECT ?award ?awardLabel WHERE {
      wd:Q42 wdt:P166 ?award .
      ?award rdfs:label ?awardLabel FILTER(LANG(?awardLabel) = "en")
    }
    """.

@export awards :- csv{resource=""} .
```

This currently yields the following output:
```
[2025-01-04T00:15:11Z INFO  nemo::io::formats::dsv::writer] Starting data export
?award,"""?awardLabel"""
http://www.wikidata.org/entity/Q906455,"""Ditmar Award@en"""
http://www.wikidata.org/entity/Q2687578,"""Inkpot Award@en"""
[2025-01-04T00:15:11Z INFO  nemo::io::formats::dsv::writer] Finished export: processed 3 tuples (dropped 0)
```
@mmarx mmarx moved this from Todo to Done in nemo Jan 8, 2025
@mmarx mmarx closed this as completed Jan 8, 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 io
Projects
Status: Done
Development

No branches or pull requests

1 participant