Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
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

On /missing subpage for awards aspect, add papers with author name strings matching those of awardees #844

Open
Daniel-Mietchen opened this issue Oct 7, 2019 · 4 comments

Comments

@Daniel-Mietchen
Copy link
Collaborator

@Daniel-Mietchen Daniel-Mietchen commented Oct 7, 2019

similar to the one we have on a /missing page for authors

@Daniel-Mietchen

This comment has been minimized.

@Daniel-Mietchen

This comment has been minimized.

Copy link
Collaborator Author

@Daniel-Mietchen Daniel-Mietchen commented Oct 28, 2019

Here is a draft query for that:

SELECT
  (COUNT(?work) AS ?count) 
  ?author_name
  (CONCAT(
      'https://tools.wmflabs.org/author-disambiguator/?doit=Look+for+author&name=',
      ENCODE_FOR_URI(?author_name)) AS ?author_resolver_url)
WHERE {
  {
    SELECT DISTINCT ?author_name {
      ?recipient p:P166 ?award_statement . 
      ?award_statement ps:P166 wd:Q63208574 .
      
      ?recipient skos:altLabel | rdfs:label ?author_name_ .
      
      # The SELECT-DISTINCT-BIND trick here is due to Stanislav Kralin
      # https://stackoverflow.com/questions/53933564
      BIND (STR(?author_name_) AS ?author_name)
    }
  }
  OPTIONAL { ?work wdt:P2093 ?author_name . }
}
GROUP BY ?author_name 
ORDER BY DESC(?count)

It works fine for Fellow of the African Academy of Sciences (Q63208574) as in the example but times out for things like Nobel Prize in Physiology or Medicine (Q80061), so would need some further refinement.

@Daniel-Mietchen

This comment has been minimized.

Copy link
Collaborator Author

@Daniel-Mietchen Daniel-Mietchen commented Nov 29, 2019

I added a LIMIT, and the query now works fine for complex things like Nobel Prizes as well:

SELECT
  (COUNT(?work) AS ?count) 
  ?author_name
  (CONCAT(
      'https://tools.wmflabs.org/author-disambiguator/?doit=Look+for+author&name=',
      ENCODE_FOR_URI(?author_name)) AS ?author_resolver_url)
WHERE {
  {
    SELECT DISTINCT ?author_name {
      ?recipient p:P166 ?award_statement . 
      ?award_statement ps:P166 wd:Q80061 .
      
      ?recipient skos:altLabel | rdfs:label ?author_name_ .
      
      # The SELECT-DISTINCT-BIND trick here is due to Stanislav Kralin
      # https://stackoverflow.com/questions/53933564
      BIND (STR(?author_name_) AS ?author_name)
    }
    LIMIT 2000
  }
  OPTIONAL { ?work wdt:P2093 ?author_name . }
}
GROUP BY ?author_name 
ORDER BY DESC(?count)
@Daniel-Mietchen

This comment has been minimized.

Copy link
Collaborator Author

@Daniel-Mietchen Daniel-Mietchen commented Nov 30, 2019

Now with filtering for counts > 0:

SELECT
  (COUNT(?work) AS ?count) 
  ?author_name
  (CONCAT(
      'https://tools.wmflabs.org/author-disambiguator/?doit=Look+for+author&name=',
      ENCODE_FOR_URI(?author_name)) AS ?author_resolver_url)
WHERE {
  {
    SELECT DISTINCT ?author_name {
      ?recipient p:P166 ?award_statement . 
      ?award_statement ps:P166 wd:Q80061 .
      
      ?recipient skos:altLabel | rdfs:label ?author_name_ .
      
      # The SELECT-DISTINCT-BIND trick here is due to Stanislav Kralin
      # https://stackoverflow.com/questions/53933564
      BIND (STR(?author_name_) AS ?author_name)
    }
    LIMIT 2000
  }
  OPTIONAL { ?work wdt:P2093 ?author_name . }
}
GROUP BY ?author_name 
HAVING (?count > 0)
ORDER BY DESC(?count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.