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

Consider using ASK queries as a way to estimate parameters for SELECT queries #617

Open
Daniel-Mietchen opened this Issue Jan 12, 2019 · 1 comment

Comments

Projects
1 participant
@Daniel-Mietchen
Copy link
Collaborator

Daniel-Mietchen commented Jan 12, 2019

e.g.

  • lengths of property paths,
  • LIMITs
  • thresholds
  • scores

@Daniel-Mietchen Daniel-Mietchen added this to To do in Meta via automation Jan 12, 2019

@Daniel-Mietchen 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

@Daniel-Mietchen

This comment has been minimized.

Copy link
Collaborator

Daniel-Mietchen commented Jan 20, 2019

A simple application would be

  • to check whether there are any results at all for an ASK query
    • if so, run the SELECT query and display its results
    • if not, do not run the SELECT query and do not display anything about it, except perhaps for a message along the lines of "There are currently no results for this query".

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