0

I have a Python function for calling the Microsoft Academic API evaluate method. The function currently takes in the author name and returns citation count:

import requests

def get_author_CC(subscription_key, author_name):
    url = 'https://api.labs.cognitive.microsoft.com/academic/v1.0/evaluate'
    params = {
        "expr": f"Composite(AA.AuN=='{author_name}')",
        "attributes": "ECC,CC",
        'count': 10000
    }
    headers = {'Ocp-Apim-Subscription-Key': subscription_key}

    r = requests.get(url, params=params, headers=headers).json().get('entities')
    
    return sum([ld.get('ECC') for ld in r])

Since I know the affiliation of several of the authors I am interested in querying for, I would like to add the affiliation parameter to the request. However, I am not quite understanding how to go about doing that. I have tried this:

import requests

def get_author_CC(subscription_key, author_name, affiliation):
    url = 'https://api.labs.cognitive.microsoft.com/academic/v1.0/evaluate'
    params = {
        "expr": f"Composite(AA.AuN=='{author_name}', Ty==5, AfN=='{affiliation}')",
        "attributes": "ECC,CC",
        'count': 10000
    }
    headers = {'Ocp-Apim-Subscription-Key': subscription_key}

    r = requests.get(url, params=params, headers=headers).json().get('entities')
    
    return sum([ld.get('ECC') for ld in r])

but that returned errors, so obviously that wasn't quite right.

As an example, one author I am looking at is laurens van der maaten who has about 40,000+ citation counts and is affiliated with Facebook. So the new function should still return 40,000+ citation counts but use the fact that she was at Facebook to narrow the search (especially useful for more common names).

Any help here is much appreciated. Thanks.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
acciolurker
  • 429
  • 4
  • 15

1 Answers1

1

Take a look at the query expression syntax page in the MAG docs; they cover this specific example. Format should look like:

Composite(And(AA.AuN='mike smith',AA.AfN='harvard university'))
Anonymous
  • 738
  • 4
  • 14
  • 36
Elizabeth
  • 26
  • 1