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

In topic aspect, add panel on organizations associated with authors publishing on the topic #625

Closed
Daniel-Mietchen opened this issue Jan 15, 2019 · 5 comments

Comments

@Daniel-Mietchen
Copy link
Collaborator

@Daniel-Mietchen Daniel-Mietchen commented Jan 15, 2019

Here we go for Zika:

# #defaultView:Graph
SELECT ?citing_organization ?citing_organizationLabel ?cited_organization ?cited_organizationLabel
WITH {
  SELECT DISTINCT ?citing_organization ?cited_organization WHERE {
    ?citing_author (wdt:P108|wdt:P1416) ?citing_organization . 
    ?cited_author (wdt:P108|wdt:P1416) ?cited_organization . 

    ?citing_work wdt:P50 ?citing_author . 
    ?citing_work wdt:P921 wd:Q202864 .
    ?cited_work wdt:P921 wd:Q202864  .
    ?citing_work wdt:P2860 ?cited_work . 
    ?cited_work wdt:P50 ?cited_author .  
    FILTER (?citing_work != ?cited_work)
    FILTER NOT EXISTS {
      ?citing_work wdt:P50 ?author .
      ?citing_work wdt:P2860 ?cited_work .
      ?cited_work  wdt:P50 ?author .
    }
  }
} AS %results
WHERE {
  INCLUDE %results
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }        
 }

Probably worth thinking about encoding the frequency of interaction in the colour of the arrows, and defining some cut-offs.

@Daniel-Mietchen Daniel-Mietchen added this to To do in Organizations via automation Jan 15, 2019
@Daniel-Mietchen Daniel-Mietchen added this to To do in Authors via automation Jan 15, 2019
@Daniel-Mietchen Daniel-Mietchen added this to To do in Topics via automation Jan 15, 2019
@Daniel-Mietchen

This comment has been minimized.

Copy link
Collaborator Author

@Daniel-Mietchen Daniel-Mietchen commented Jan 15, 2019

An alternative option would be a map, though I don't know how the co-authorship could be usefully visualized there.

Anyway, first try:

# #defaultView:Map
SELECT DISTINCT ?citing_organization ?citing_organizationLabel ?citing_geo ?cited_organization ?cited_organizationLabel ?cited_geo
WITH {
  SELECT DISTINCT ?citing_organization ?cited_organization WHERE {
    ?citing_author (wdt:P108|wdt:P1416) ?citing_organization . 
    ?cited_author (wdt:P108|wdt:P1416) ?cited_organization . 

    ?citing_work wdt:P50 ?citing_author . 
    ?citing_work wdt:P921 wd:Q183368 .
    ?cited_work wdt:P921 wd:Q183368  .
    ?citing_work wdt:P2860 ?cited_work . 
    ?cited_work wdt:P50 ?cited_author .  
    FILTER (?citing_work != ?cited_work)
    FILTER NOT EXISTS {
      ?citing_work wdt:P50 ?author .
      ?citing_work wdt:P2860 ?cited_work .
      ?cited_work  wdt:P50 ?author .
    }
  }
} AS %results
WHERE {
  INCLUDE %results
  ?citing_organization wdt:P625 ?citing_geo .          
  ?cited_organization wdt:P625 ?cited_geo .          
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }        
 }
@Daniel-Mietchen

This comment has been minimized.

Copy link
Collaborator Author

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

Here is a simpler version, simply listing organizations by number of affiliatd authors known to have published on the target topic:

SELECT ?count ?institution ?institutionLabel 
WITH {
  SELECT (COUNT(DISTINCT ?researcher) AS ?count) ?institution WHERE {
    ?researcher ( wdt:P108 | wdt:P463 | wdt:P1416 ) / wdt:P361* ?institution .
    ?institution wdt:P2427 ?grid .
    ?item wdt:P50 ?researcher ;
          wdt:P921 wd:Q202864 .
  } 
  GROUP BY ?institution
} AS %result
WHERE {
  INCLUDE %result
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,ep,fr,jp,nl,no,ru,sv,zh" . } 
} 
ORDER BY DESC(?count)
LIMIT 200 
@Daniel-Mietchen

This comment has been minimized.

Copy link
Collaborator Author

@Daniel-Mietchen Daniel-Mietchen commented Dec 14, 2019

I played around a bit more with the map variants of this query.

This version works fine:

#defaultView:Map
SELECT ?organization ?organizationLabel ?geo ?count ?layer
WITH {
  SELECT DISTINCT ?work WHERE {
  # Works on the topic
    ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) wd:Q202864 .
  }
  LIMIT 20000
} AS %works
WITH {
  SELECT DISTINCT ?organization ?geo (COUNT(DISTINCT ?work) AS ?count) WHERE {
    INCLUDE %works
    # Authors who have published works on the topic
    ?work wdt:P50 ?author . 
    ?author ( wdt:P108 | wdt:P463 | wdt:P1416 ) / wdt:P361* ?organization . 
    ?organization wdt:P625 ?geo .
  }
  GROUP BY ?organization ?geo
  ORDER BY DESC (?count)
  LIMIT 500
} AS %organizations
WHERE {
  INCLUDE %organizations
  BIND(IF( (?count < 1), "No results", IF((?count < 10), "1 ≤ results < 10 ", IF((?count < 100), "10 ≤ results < 100 results", IF((?count < 1000), "100 ≤ results < 1000", IF((?count < 10000), "1000 ≤ results < 10000", IF((?count < 100000), "10000 ≤ results < 100000", "100000 or more results") ) ) ) )) AS ?layer )
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }        
 }
ORDER BY DESC (?count)

However, when I tried to include this in #996 by way of adding


<h2 id="Map of organizations publishing works about the topic">Map of organizations publishing works about the topic</h2>

<div class="embed-responsive embed-responsive-4by3">
    <iframe class="embed-responsive-item" src="https://query.wikidata.org/embed.html#%23defaultView%3AMap%0ASELECT%20%3Forganization%20%3ForganizationLabel%20%3Fgeo%20%3Fcount%20%3Flayer%0AWITH%20%7B%0A%20%20SELECT%20DISTINCT%20%3Fwork%20WHERE%20%7B%0A%20%20%23%20Works%20on%20the%20topic%0A%20%20%20%20%3Fwork%20wdt%3AP921%20%2F%20(wdt%3AP361%2B%20%7C%20wdt%3AP1269%2B%20%7C%20(wdt%3AP31*%20%2F%20wdt%3AP279*)%20)%20wd%3A{{q}}%20.%0A%20%20%7D%0A%20%20LIMIT%2020000%0A%7D%20AS%20%25works%0AWITH%20%7B%0A%20%20SELECT%20DISTINCT%20%3Forganization%20%3Fgeo%20(COUNT(DISTINCT%20%3Fwork)%20AS%20%3Fcount)%20WHERE%20%7B%0A%20%20%20%20INCLUDE%20%25works%0A%20%20%20%20%23%20Authors%20who%20have%20published%20works%20on%20the%20topic%0A%20%20%20%20%3Fwork%20wdt%3AP50%20%3Fauthor%20.%20%0A%20%20%20%20%3Fauthor%20(%20wdt%3AP108%20%7C%20wdt%3AP463%20%7C%20wdt%3AP1416%20)%20%2F%20wdt%3AP361*%20%3Forganization%20.%20%0A%20%20%20%20%3Forganization%20wdt%3AP625%20%3Fgeo%20.%0A%20%20%7D%0A%20%20GROUP%20BY%20%3Forganization%20%3Fgeo%0A%20%20ORDER%20BY%20DESC%20(%3Fcount)%0A%20%20LIMIT%20200%0A%7D%20AS%20%25organizations%0AWHERE%20%7B%0A%20%20INCLUDE%20%25organizations%0A%20%20BIND(IF(%20(%3Fcount%20%3C%201)%2C%20%22No%20results%22%2C%20IF((%3Fcount%20%3C%2010)%2C%20%221%20%E2%89%A4%20results%20%3C%2010%20%22%2C%20IF((%3Fcount%20%3C%20100)%2C%20%2210%20%E2%89%A4%20results%20%3C%20100%20results%22%2C%20IF((%3Fcount%20%3C%201000)%2C%20%22100%20%E2%89%A4%20results%20%3C%201000%22%2C%20IF((%3Fcount%20%3C%2010000)%2C%20%221000%20%E2%89%A4%20results%20%3C%2010000%22%2C%20IF((%3Fcount%20%3C%20100000)%2C%20%2210000%20%E2%89%A4%20results%20%3C%20100000%22%2C%20%22100000%20or%20more%20results%22)%20)%20)%20)%20))%20AS%20%3Flayer%20)%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%20%20%20%20%20%20%20%20%0A%20%7D%0AORDER%20BY%20DESC%20(%3Fcount)%0A"</iframe>
</div>

to topics.html, the embedded map would not show. Not sure what the problem is here.

@Daniel-Mietchen

This comment has been minimized.

Copy link
Collaborator Author

@Daniel-Mietchen Daniel-Mietchen commented Jan 13, 2020

The problem mentioned above was a missing > before the </iframe>.

@Daniel-Mietchen

This comment has been minimized.

Copy link
Collaborator Author

@Daniel-Mietchen Daniel-Mietchen commented Jan 13, 2020

Fixed with f8664d2 .

Topics automation moved this from To do to Done Jan 13, 2020
Authors automation moved this from To do to Done Jan 13, 2020
Organizations automation moved this from To do to Done Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Topics
  
Done
Authors
  
Done
Organizations
  
Done
1 participant
You can’t perform that action at this time.