|
@@ -0,0 +1,393 @@
|
|
|
+{
|
|
|
+ "cells": [
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 19,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "# Utilities to read/write csv files\n",
|
|
|
+ "import csv\n",
|
|
|
+ "# Utilities to handle character encodings\n",
|
|
|
+ "import unicodedata\n",
|
|
|
+ "# Ordered Dicts\n",
|
|
|
+ "from collections import OrderedDict\n",
|
|
|
+ "\n",
|
|
|
+ "import json\n",
|
|
|
+ "\n",
|
|
|
+ "\n",
|
|
|
+ "# OPZIONAL IMPORTS\n",
|
|
|
+ "\n",
|
|
|
+ "# For timestamping/simple speed tests\n",
|
|
|
+ "from datetime import datetime\n",
|
|
|
+ "# Random number generator\n",
|
|
|
+ "from random import *\n",
|
|
|
+ "# System & command line utilities\n",
|
|
|
+ "import sys\n",
|
|
|
+ "# Json for the dictionary\n",
|
|
|
+ "import json"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 20,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "import_dir = '/Users/federicaspinelli/Google Drive/OVI-CNR/CSV/ASPO/gettatelli/'\n",
|
|
|
+ "export_dir = '/Users/federicaspinelli/Google Drive/OVI-CNR/RDF/ASPO/gettatelli/'"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 21,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "# Custom class to store URIs + related infos for the ontologies/repositories\n",
|
|
|
+ "\n",
|
|
|
+ "class RDFcoords:\n",
|
|
|
+ " def __init__(self, uri, prefix, code = None):\n",
|
|
|
+ " self.uri = uri\n",
|
|
|
+ " self.prefix = prefix\n",
|
|
|
+ " self.code = code\n",
|
|
|
+ "\n",
|
|
|
+ "# Repositories\n",
|
|
|
+ "datiniCoords = RDFcoords('<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoGT001/scheda/IT-ASPO-GT001->', 'dt:')\n",
|
|
|
+ "personAuthCoords = RDFcoords('<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001->', 'pa:')\n",
|
|
|
+ "# W3/CIDOC Predicates\n",
|
|
|
+ "hasTypeCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>', 'tp:')\n",
|
|
|
+ "hasNoteCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P3_has_note>', 'no:')\n",
|
|
|
+ "hasTypePCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P2_has_type>', 'te:')\n",
|
|
|
+ "carriesCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P128_carries>', 'ca:')\n",
|
|
|
+ "identifiedByCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by>', 'ib:')\n",
|
|
|
+ "labelCoords = RDFcoords('<http://www.w3.org/2000/01/rdf-schema#label>', 'lb:')\n",
|
|
|
+ "wasBroughtCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P92i_was_brought_into_existence_by>', 'wb:')\n",
|
|
|
+ "wasBornCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P98i_was_born>', 'wbc:')\n",
|
|
|
+ "diedCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P100i_died_in>', 'di:')\n",
|
|
|
+ "wasPresentCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P12i_was_present_at>', 'wp:')\n",
|
|
|
+ "carriedByCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>', 'cb:')\n",
|
|
|
+ "noteCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P3_has_note>', 'nt:')\n",
|
|
|
+ "hasTimeSpanCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P4_has_time-span>', 'hs:')\n",
|
|
|
+ "consistCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P45_consist_of>', 'cf:')\n",
|
|
|
+ "hasConditionCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P44_has_condition>', 'hc:')\n",
|
|
|
+ "foafCoords = RDFcoords('<http://xmlns.com/foaf/0.1/>', 'foaf:')\n",
|
|
|
+ "nsCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#>', 'rdf:')\n",
|
|
|
+ "\n",
|
|
|
+ "# CIDOC Objects\n",
|
|
|
+ "manMadeObjectCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E22_Man-Made_Object>', 'mo:', 'E22')\n",
|
|
|
+ "informationObjectCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E73_Information_Object>', 'io:', 'E73')\n",
|
|
|
+ "titleCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E35_Title>', 'ti:' ,'E35')\n",
|
|
|
+ "placeAppellationCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E44_Place_appellation>', 'pa:', 'E44')\n",
|
|
|
+ "identifierCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E42_Identifier>', 'id:', 'E42')\n",
|
|
|
+ "typeCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E55_Type>', 'ty:', 'E55')\n",
|
|
|
+ "creationCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E65_Creation>', 'cr:', 'E65')\n",
|
|
|
+ "personCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E21_Person>', 'ps:', 'E21')\n",
|
|
|
+ "stringCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E62_String>', 'st:', 'E62')\n",
|
|
|
+ "birthCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E67_Birth>', 'th:', 'E67')\n",
|
|
|
+ "deathCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E69_Death>', 'dh:', 'E69')\n",
|
|
|
+ "timeSpanCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E52_Time-Span>', 'ts:', 'E52')\n",
|
|
|
+ "materialCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E57_Material>', 'mt:', 'E57')\n",
|
|
|
+ "conditionCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E3_Condition_State>', 'cs:', 'E3')\n",
|
|
|
+ "entityCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E1_Entity>', 'ey:', 'E1')\n",
|
|
|
+ "refersCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P67_refers_to>', 'rt:')\n",
|
|
|
+ "refersHasTypeCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P67.1_type>', 'rh:')\n",
|
|
|
+ "\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 22,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "# Basic functions for triples / shortened triples in TTL format\n",
|
|
|
+ "\n",
|
|
|
+ "def triple(subject, predicate, object1):\n",
|
|
|
+ " line = subject + ' ' + predicate + ' ' + object1\n",
|
|
|
+ " return line\n",
|
|
|
+ "\n",
|
|
|
+ "def doublet(predicate, object1):\n",
|
|
|
+ " line = ' ' + predicate + ' ' + object1\n",
|
|
|
+ " return line\n",
|
|
|
+ "\n",
|
|
|
+ "def singlet(object1):\n",
|
|
|
+ " line = ' ' + object1\n",
|
|
|
+ " return line\n",
|
|
|
+ "\n",
|
|
|
+ "# Line endings in TTL format\n",
|
|
|
+ "continueLine1 = ' ;\\n'\n",
|
|
|
+ "continueLine2 = ' ,\\n'\n",
|
|
|
+ "closeLine = ' .\\n'"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 23,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "def writeTTLHeader(output):\n",
|
|
|
+ " output.write('@prefix ' + datiniCoords.prefix + ' ' + datiniCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + personAuthCoords.prefix + ' ' + personAuthCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + hasTypeCoords.prefix + ' ' + hasTypeCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + hasTypePCoords.prefix + ' ' + hasTypePCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + manMadeObjectCoords.prefix + ' ' + manMadeObjectCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + carriesCoords.prefix + ' ' + carriesCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + informationObjectCoords.prefix + ' ' + informationObjectCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + identifiedByCoords.prefix + ' ' + identifiedByCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + titleCoords.prefix + ' ' + titleCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + labelCoords.prefix + ' ' + labelCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + identifierCoords.prefix + ' ' + identifierCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + wasBroughtCoords.prefix + ' ' + wasBroughtCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + typeCoords.prefix + ' ' + typeCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + carriedByCoords.prefix + ' ' + carriedByCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + personCoords.prefix + ' ' + personCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + stringCoords.prefix + ' ' + stringCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + noteCoords.prefix + ' ' + noteCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + wasBornCoords.prefix + ' ' + wasBornCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + diedCoords.prefix + ' ' + diedCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + wasPresentCoords.prefix + ' ' + wasPresentCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + birthCoords.prefix + ' ' + birthCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + deathCoords.prefix + ' ' + deathCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + hasTimeSpanCoords.prefix + ' ' + hasTimeSpanCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + timeSpanCoords.prefix + ' ' + timeSpanCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + materialCoords.prefix + ' ' + materialCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + consistCoords.prefix + ' ' + consistCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + conditionCoords.prefix + ' ' + conditionCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + hasConditionCoords.prefix + ' ' + hasConditionCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + refersCoords.prefix + ' ' + refersCoords.uri + closeLine) \n",
|
|
|
+ " output.write('@prefix ' + entityCoords.prefix + ' ' + entityCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + refersHasTypeCoords.prefix + ' ' + refersHasTypeCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + hasNoteCoords.prefix + ' ' + hasNoteCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + creationCoords.prefix + ' ' + creationCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + foafCoords.prefix + ' ' + foafCoords.uri + closeLine)\n",
|
|
|
+ " output.write('@prefix ' + nsCoords.prefix + ' ' + nsCoords.uri + closeLine)\n",
|
|
|
+ "\n",
|
|
|
+ " output.write('\\n')\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 24,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "filePrefix = 'data_'\n",
|
|
|
+ "fileType = 'item'\n",
|
|
|
+ "max_entries = 1000000000\n",
|
|
|
+ "\n",
|
|
|
+ "with open(import_dir + filePrefix + fileType + '.csv', newline=\"\") as csv_file, open(export_dir + filePrefix + fileType + '_person.ttl', 'w') as output:\n",
|
|
|
+ " reader = csv.DictReader(csv_file)\n",
|
|
|
+ " writeTTLHeader(output)\n",
|
|
|
+ " first = True\n",
|
|
|
+ " ii = 0\n",
|
|
|
+ " for row in reader:\n",
|
|
|
+ " # The index ii is used to process a limited number of entries for testing purposes\n",
|
|
|
+ " ii = ii+1\n",
|
|
|
+ " # Skip the first line as it carries info we don't want to triplify\n",
|
|
|
+ " if(first):\n",
|
|
|
+ " first = False\n",
|
|
|
+ " continue\n",
|
|
|
+ " \n",
|
|
|
+ " e21placeHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '>'\n",
|
|
|
+ " e22placeHolder = \"<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoGT001/scheda/\" + row['id'] + \">\"\n",
|
|
|
+ " e65placeHolder = \"<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoGT001/scheda/\" + row['id'] + \"/\" + creationCoords.code + \">\"\n",
|
|
|
+ "\n",
|
|
|
+ " line = triple(e65placeHolder, refersCoords.prefix, e21placeHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " e55placeHolder = '<http://www.archiviodistato.prato.it/gettatello' + \">\"\n",
|
|
|
+ " line = triple(e21placeHolder, hasTypePCoords.prefix, e55placeHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e55placeHolder, labelCoords.prefix, '\\\"Gettatello\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " \n",
|
|
|
+ " # If the 'persname' property is not empty for the given entry, write down triples\n",
|
|
|
+ " bambino = ''\n",
|
|
|
+ " if(row['cognome_bambino'] != ''):\n",
|
|
|
+ " bambino = bambino + row['cognome_bambino'] + ' '\n",
|
|
|
+ " if(row['nome_bambino'] != ''):\n",
|
|
|
+ " bambino = bambino + row['nome_bambino']\n",
|
|
|
+ " if(bambino != ''):\n",
|
|
|
+ " line = triple(e21placeHolder, hasTypeCoords.prefix, personCoords.prefix) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e21placeHolder, foafCoords.prefix + 'givenName', '\\\"' + bambino + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e21placeHolder, labelCoords.prefix, '\\\"' + bambino + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " e62placeHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') +'/E62>'\n",
|
|
|
+ " line = triple(e21placeHolder, noteCoords.prefix, e62placeHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e62placeHolder, hasTypeCoords.prefix, stringCoords.prefix) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e62placeHolder, labelCoords.prefix, '\\\"Fonte: Archivio di Stato di Prato - Fondo Ospedale della Misericordia e Dolce\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ "\n",
|
|
|
+ " #Matricola Bambino\n",
|
|
|
+ " e42placeHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E42>'\n",
|
|
|
+ " if(row['matricola'] != ''):\n",
|
|
|
+ " line = triple(e21placeHolder, identifiedByCoords.prefix, e42placeHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e42placeHolder, hasTypeCoords.prefix, identifierCoords.prefix) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e42placeHolder, labelCoords.prefix, '\\\"Matricola: ' + row['matricola'] + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " \n",
|
|
|
+ " #Nascita\n",
|
|
|
+ " if row['data_nascita'] != '':\n",
|
|
|
+ " e67placeHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E67>'\n",
|
|
|
+ " line = triple(e21placeHolder, wasBornCoords.prefix, e67placeHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e67placeHolder, hasTypeCoords.prefix, birthCoords.prefix) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e67placeHolder, labelCoords.prefix, '\\\"Nascita di ' + bambino + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ "\n",
|
|
|
+ " e52NplaceHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E52_N>'\n",
|
|
|
+ " \n",
|
|
|
+ " line = triple(e67placeHolder, hasTimeSpanCoords.prefix, e52NplaceHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52NplaceHolder, hasTypeCoords.prefix, timeSpanCoords.prefix ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52NplaceHolder, labelCoords.prefix, '\\\"' + row['data_nascita'] + '\\\"' ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ "\n",
|
|
|
+ " #Morte\n",
|
|
|
+ " if row['data_morte'] != '':\n",
|
|
|
+ " e69placeHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E69>'\n",
|
|
|
+ " line = triple(e21placeHolder, diedCoords.prefix, e69placeHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e69placeHolder, hasTypeCoords.prefix, deathCoords.prefix) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e69placeHolder, labelCoords.prefix, '\\\"Morte di ' + bambino + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " \n",
|
|
|
+ " e52MplaceHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E52_M>'\n",
|
|
|
+ " \n",
|
|
|
+ " line = triple(e69placeHolder, hasTimeSpanCoords.prefix, e52MplaceHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52MplaceHolder, hasTypeCoords.prefix, timeSpanCoords.prefix ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52MplaceHolder, labelCoords.prefix, '\\\"' + row['data_morte'] + '\\\"' ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " \n",
|
|
|
+ " #Ritrovamento\n",
|
|
|
+ " if row['data_ritrovamento'] != '':\n",
|
|
|
+ " e5placeHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E5_R>'\n",
|
|
|
+ " line = triple(e5placeHolder, labelCoords.prefix, '\\\"Ritrovamento\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e21placeHolder, wasPresentCoords.prefix, e5placeHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " e5RplaceHolder = '<http://www.archiviodistato.prato.it/gettatelli_ritrovamento>'\n",
|
|
|
+ " line = triple(e5RplaceHolder, nsCoords.prefix + 'type', '\\\"Ritrovamento\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e5placeHolder, hasTypeCoords.prefix, '\\\"Ritrovamento di ' + bambino + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ "\n",
|
|
|
+ " e52RplaceHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E52_R>'\n",
|
|
|
+ " line = triple(e5placeHolder, hasTimeSpanCoords.prefix, e52RplaceHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52RplaceHolder, hasTypeCoords.prefix, timeSpanCoords.prefix ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52RplaceHolder, labelCoords.prefix, '\\\"' + row['data_ritrovamento'] + '\\\"' ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ "\n",
|
|
|
+ " #Ricongiungimento\n",
|
|
|
+ " if row['data_ricongiungimento'] != '':\n",
|
|
|
+ " e5placeHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E5_RC>'\n",
|
|
|
+ " line = triple(e21placeHolder, wasPresentCoords.prefix, e5placeHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " e5RCplaceHolder = '<http://www.archiviodistato.prato.it/gettatelli_ricongiungimento>'\n",
|
|
|
+ " line = triple(e5RCplaceHolder, nsCoords.prefix + 'type', '\\\"Ricongiungimento\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e5placeHolder, labelCoords.prefix, '\\\"Ricongiungimento\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e5placeHolder, hasTypeCoords.prefix, '\\\"Ricongiungimento di ' + bambino + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ "\n",
|
|
|
+ " e52RCplaceHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E52_RC>' \n",
|
|
|
+ " line = triple(e5placeHolder, hasTimeSpanCoords.prefix, e52RCplaceHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52RCplaceHolder, hasTypeCoords.prefix, timeSpanCoords.prefix ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52RCplaceHolder, labelCoords.prefix, '\\\"' + row['data_ricongiungimento'] + '\\\"' ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " \n",
|
|
|
+ " #Adozione\n",
|
|
|
+ " if row['data_adozione'] != '':\n",
|
|
|
+ " e5placeHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E5_A>'\n",
|
|
|
+ " line = triple(e21placeHolder, wasPresentCoords.prefix, e5placeHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " e5AplaceHolder = '<http://www.archiviodistato.prato.it/gettatelli_adozione>'\n",
|
|
|
+ " line = triple(e5AplaceHolder, nsCoords.prefix + 'type', '\\\"Adozione\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e5placeHolder, labelCoords.prefix, '\\\"Adozione\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e5placeHolder, hasTypeCoords.prefix, '\\\"Adozione di ' + bambino + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ "\n",
|
|
|
+ " e52AplaceHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E52_A>'\n",
|
|
|
+ " line = triple(e5placeHolder, hasTimeSpanCoords.prefix, e52AplaceHolder) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52AplaceHolder, hasTypeCoords.prefix, timeSpanCoords.prefix ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52AplaceHolder, labelCoords.prefix, '\\\"' + row['data_adozione'] + '\\\"' ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ "\n",
|
|
|
+ " #Anno unico\n",
|
|
|
+ " e52UplaceHolder = '<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-GT001-' + row['id'].replace('IT-ASPO-GT001-', '') + '/E52_U>'\n",
|
|
|
+ " line = triple(e52UplaceHolder, refersCoords.prefix, e21placeHolder, ) + closeLine\n",
|
|
|
+ " output.write(line) \n",
|
|
|
+ " line = triple(e52UplaceHolder, hasTimeSpanCoords.prefix, '\\\"' + row['data_periodo'] + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52UplaceHolder, labelCoords.prefix, '\\\"' + row['data_periodo'] + '\\\"') + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ " line = triple(e52UplaceHolder, hasTypeCoords.prefix, timeSpanCoords.prefix ) + closeLine\n",
|
|
|
+ " output.write(line)\n",
|
|
|
+ "\n",
|
|
|
+ " output.write('\\n')\n",
|
|
|
+ " #\n",
|
|
|
+ " #\n",
|
|
|
+ " # Limit number of entries processed (if desired)\n",
|
|
|
+ " if(ii>max_entries):\n",
|
|
|
+ " break\n",
|
|
|
+ " "
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": []
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "metadata": {
|
|
|
+ "interpreter": {
|
|
|
+ "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
|
|
|
+ },
|
|
|
+ "kernelspec": {
|
|
|
+ "display_name": "Python 3.7.3 64-bit",
|
|
|
+ "name": "python3"
|
|
|
+ },
|
|
|
+ "language_info": {
|
|
|
+ "codemirror_mode": {
|
|
|
+ "name": "ipython",
|
|
|
+ "version": 3
|
|
|
+ },
|
|
|
+ "file_extension": ".py",
|
|
|
+ "mimetype": "text/x-python",
|
|
|
+ "name": "python",
|
|
|
+ "nbconvert_exporter": "python",
|
|
|
+ "pygments_lexer": "ipython3",
|
|
|
+ "version": "3.9.0"
|
|
|
+ },
|
|
|
+ "metadata": {
|
|
|
+ "interpreter": {
|
|
|
+ "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "nbformat": 4,
|
|
|
+ "nbformat_minor": 2
|
|
|
+}
|