WDscholia / scholia

Wikidata-based scholarly profiles
https://scholia.toolforge.org
Other
219 stars 78 forks source link

Recent publications by co-authors #82

Open Daniel-Mietchen opened 7 years ago

Daniel-Mietchen commented 7 years ago

In the author aspect, something like recent publications by former co-authors could be a useful discovery tool (shown here for Uta Frith):

SELECT DISTINCT ?work2 ?work2Label ?date 
(GROUP_CONCAT(DISTINCT ?author2Label; separator=", ") AS ?authorLabels) 
WHERE {
  ?work wdt:P50 wd:Q8219 .
  ?work wdt:P50 ?author1 .
  ?work wdt:P50 ?author2 .
  VALUES ?publication_type { wd:Q13442814 wd:Q571 wd:Q26973022}  # journal and conference articles, books, not (yet?) software
  ?work2 wdt:P31 ?publication_type;
         wdt:P50 ?author2 ;
         wdt:P577 ?date.
  MINUS { ?work2 wdt:P50 wd:Q8219 } .
  ?author2 rdfs:label ?author2Label . filter (lang(?author2Label) = 'en')
  ?work2 rdfs:label ?work2Label . filter (lang(?work2Label) = 'en')
} GROUP BY ?work2 ?work2Label ?date 
ORDER BY DESC (?date)

LIMIT 200
Daniel-Mietchen commented 5 years ago

The query barely runs through for Uta Frith, so I removed the VALUES part:

PREFIX target: <http://www.wikidata.org/entity/Q8219> 

SELECT DISTINCT ?work2 ?work2Label ?date 
(GROUP_CONCAT(DISTINCT ?author2Label; separator=", ") AS ?authorLabels) 
WHERE {
  ?work wdt:P50 target: .
  ?work wdt:P50 ?author1 .
  ?work wdt:P50 ?author2 .
  ?work2 wdt:P50 ?author2 ;
         wdt:P577 ?date.
  MINUS { ?work2 wdt:P50 target: } .
  ?author2 rdfs:label ?author2Label . filter (lang(?author2Label) = 'en')
  ?work2 rdfs:label ?work2Label . filter (lang(?work2Label) = 'en')
} GROUP BY ?work2 ?work2Label ?date 
ORDER BY DESC (?date)

LIMIT 200

Try it

This times out for people with large collaboration networks, so it would make sense to limit this to a maximum of co-authors.

fnielsen commented 5 years ago

This runs in two seconds:

SELECT
  ?date ?work ?workLabel 
  (GROUP_CONCAT(?author_string; separator=" // ") AS ?authors)
WHERE { 
  {
    SELECT (MAX(?date_) AS ?date) ?work 
    WHERE {
      BIND(wd:Q8219 AS ?target)
      [] wdt:P50 ?target, ?author_ .
      ?work wdt:P50 ?author_ ; 
            wdt:P577 ?date_ .
      MINUS { ?work wdt:P50 ?target } .
    }
    GROUP BY ?work 
    ORDER BY DESC (?date)
    LIMIT 200
  }
  hint:Query hint:optimizer "None" .
  ?work wdt:P50 ?author .
  ?author rdfs:label ?author_string . 
  FILTER (LANG(?author_string) = 'en')
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?date ?work ?workLabel 
ORDER BY DESC(?date)
Daniel-Mietchen commented 5 years ago

Tested this for