Project:Import Wikidata Entities

From MaRDI portal
Revision as of 13:17, 16 April 2024 by EloiFerrer (talk | contribs)

This page documents how to copy over entities existing in Wikidata into the portal.

  1. Access the mardi-importer container. Follow the steps in Project:Access_Docker_container if necessary.
  2. Navigate into /mardi_importer/mardi_importer/scripts
  3. Create a new python file or directly edit sandbox.py
  4. Use the import_entities method from MardiIntegrator to import Wikidata entities. You just have to pass the identifier from Wikidata that you want to import.
    from mardi_importer.integrator import MardiIntegrator
    
    mc = MardiIntegrator()
    
    mc.import_entities('Q5')
    
    The import_entities method can also accept a list of identifiers.
    from mardi_importer.integrator import MardiIntegrator
    
    mc = MardiIntegrator()
    
    mc.import_entities(['Q5', 'Q6', 'Q7'])
    
    The import_entities method returns a list of the local IDs that are assigned when creating the item in the portal. If necessary, you can save or print those directly from your script.
  5. Execute the script: python3 sandbox.py

t