Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upConsider using ASK queries as a way to estimate parameters for SELECT queries #617
Comments
Daniel-Mietchen
added
SPARQL
performance
labels
Jan 12, 2019
Daniel-Mietchen
added this to To do
in Meta
via automation
Jan 12, 2019
Daniel-Mietchen
changed the title
Consider using ASK queries as a way to estimate paramaters for SELECT queries
Consider using ASK queries as a way to estimate parameters for SELECT queries
Jan 12, 2019
This comment has been minimized.
This comment has been minimized.
A simple application would be
As an example, consider the "Number of pages" panel: The current query there is #defaultView:BarChart
select ?year ?number_of_pages ?work_label where {
{
select ?year (sample(?pages) as ?number_of_pages) ?work_label where {
{
select (str(?year_) as ?year) (0 as ?pages) ("_" as ?work_label) where {
?year_item wdt:P31 wd:Q577 .
?year_item wdt:P585 ?date .
bind(year(?date) as ?year_)
{
select (min(?year_) as ?earliest_year) (max(?year_) as ?latest_year) where {
?work wdt:P50 wd:Q4693015 .
?work wdt:P577 ?publication_date .
bind(year(?publication_date) as ?year_)
}
}
filter (?year_ >= ?earliest_year && ?year_ <= ?latest_year)
}
}
union {
?work wdt:P50 wd:Q4693015 .
?work wdt:P1104 ?pages .
?work wdt:P577 ?date .
?work rdfs:label ?long_work_label . filter(lang(?long_work_label) = 'en')
bind(substr(?long_work_label, 1, 20) as ?work_label)
bind(str(year(?date)) as ?year)
}
}
group by ?year ?work ?work_label
order by ?year
}
} which we could precede by an ASK query, the simplest one would probably just be ASK {
{
select ?year (sample(?pages) as ?number_of_pages) ?work_label where {
{
select (str(?year_) as ?year) (0 as ?pages) ("_" as ?work_label) where {
?year_item wdt:P31 wd:Q577 .
?year_item wdt:P585 ?date .
bind(year(?date) as ?year_)
{
select (min(?year_) as ?earliest_year) (max(?year_) as ?latest_year) where {
?work wdt:P50 wd:Q4693015 .
?work wdt:P577 ?publication_date .
bind(year(?publication_date) as ?year_)
}
}
filter (?year_ >= ?earliest_year && ?year_ <= ?latest_year)
}
}
union {
?work wdt:P50 wd:Q4693015 .
?work wdt:P1104 ?pages .
?work wdt:P577 ?date .
?work rdfs:label ?long_work_label . filter(lang(?long_work_label) = 'en')
bind(substr(?long_work_label, 1, 20) as ?work_label)
bind(str(year(?date)) as ?year)
}
}
group by ?year ?work ?work_label
order by ?year
}
} though it probably makes sense to expand the ASK one a bit to make sure we have a more useful minimum amount of page number data (say, for at least 1/10 of the author's papers). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Daniel-Mietchen commentedJan 12, 2019
e.g.