How to get data from wikidata using the QID URL

Viewed 402

I wanted to know how can I get data using QID URL. I have some names, I use falcon 2.0 entity linker curl command( change it into python script) to get information of its QID. Now I want to use that QID to access information about the persons gender( male or female) or alias or other information. Can someone give an idea how it should be approached. The code to get QID URL is given below. the link to falcon 2.0 is https://github.com/SDM-TIB/Falcon2.0.

import requests 
import json

response_list=[] 
person_names=[]

if __name__ == '__main__':


   limit=100
   with open(filename, 'r') as in_file:
       in_reader = in_file.readlines()
       for data in in_reader:
           if limit > 0:
               person_names.append(data.rstrip()) 
               limit -=1
           else :
               break
               
               
   """
   Url of post request and header of type json create linking against each line of text.
   """
   
   
   url="https://labs.tib.eu/falcon/falcon2/api?mode=long"
   headers = {'Content-type': 'application/json'}
   for name in person_names:
       data = {"text":name }
       data_json = json.dumps(data)
       response = requests.post(url, data=data_json, headers=headers)
       print(response.content)

It gives output as http://www.wikidata.org/entity/Q42493 for the entity.

1 Answers
Related