Project:Import Wikidata Entities: Difference between revisions

From MaRDI portal
Created page with "This page documents how to copy over entities existing in Wikidata into the portal."
 
No edit summary
Tag: Manual revert
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page documents how to copy over entities existing in Wikidata into the portal.
This page documents how to copy over entities existing in Wikidata into the portal.
# Access the mardi-importer container. Follow the steps in [[Project:Access_Docker_container]] if necessary.
# Navigate into <code>/mardi_importer/mardi_importer/scripts</code>
# Create a new python file or directly edit <code>sandbox.py</code>
# Use the <code>import_entities</code> method from MardiIntegrator to import Wikidata entities. You just have to pass the identifier from Wikidata that you want to import.<syntaxhighlight lang="python">
from mardi_importer.integrator import MardiIntegrator
mc = MardiIntegrator()
mc.import_entities('Q5')
</syntaxhighlight> The <code>import_entities</code> method can also accept a list of identifiers.<syntaxhighlight lang="python">
from mardi_importer.integrator import MardiIntegrator
mc = MardiIntegrator()
mc.import_entities(['Q5', 'Q6', 'Q7'])
</syntaxhighlight>The <code>import_entities</code> 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.
# Execute the script: <code>python3 sandbox.py</code>

Latest revision as of 14:17, 16 April 2024

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