Browse Source

Add parser to manage ISPC XRFmapping_XRAYLAB

Federica 2 years ago
parent
commit
2c24f81893

+ 356 - 0
CSV_to_RDF/ISPC/CSV_to_RDF_analysis_XRFmapping.ipynb

@@ -0,0 +1,356 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 59,
+   "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": 60,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import_dir = '/Users/federicaspinelli/Google Drive/OVI-CNR/CSV/corali/'\n",
+    "export_dir = '/Users/federicaspinelli/Google Drive/OVI-CNR/RDF/corali/'"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 61,
+   "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",
+    "\n",
+    "# Repositories\n",
+    "datiniCoords = RDFcoords('<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoSt005/scheda/IT-ASPO-ST00005->', 'dt:')\n",
+    "personAuthCoords = RDFcoords('<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-AU00002->', 'pa:')\n",
+    "# W3/CIDOC Predicates\n",
+    "hasTypeCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>', 'tp:')\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",
+    "carriedByCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>', 'cb:')\n",
+    "hasCurrentPermanentLocationCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P54_has_current_permanent_location>', 'ap:')\n",
+    "placeCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E53_Place>', 'pl:', 'E53')\n",
+    "hasTimeSpanCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P4_has_time-span>', 'hs:')\n",
+    "hasNoteCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P3_has_note>', 'no:')\n",
+    "hasCurrentOwnerCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P52_has_current_owner>', 'ow:')\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",
+    "timeSpanCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E52_Time-Span>', 'ts:', 'E52')\n",
+    "stringCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E62_String>', 'st:', 'E62')\n",
+    "tookPlaceCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P7_took_place_at>', 'tk:')\n",
+    "carriedByCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>', 'cb:')\n",
+    "consistCoords = RDFcoords('<http://cidoc-crm.org/cidoc-crm/7.1.1/P45_consists_of>', 'cf:')\n",
+    "cidocCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/>', 'crm:')\n",
+    "schemaCoords = RDFcoords('<http://schema.org/>', 'schema:')\n",
+    "personCoords = RDFcoords('<http://www.w3.org/ns/person#>', 'person:')\n",
+    "nsCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#>', 'rdf:')\n",
+    "materialCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E57_Material>', 'mt:', 'E57')\n",
+    "composedCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P46_is_composed_of>', 'cmp:')\n",
+    "dimensionsCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E54_Dimension>', 'dm:', 'E54')\n",
+    "hasDimensionsCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P43_has_dimension>', 'hd:')\n",
+    "hasConditionCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P44_has_condition>', 'hc:')\n",
+    "conditionCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E3_Condition_State>', 'cs:', 'E3')\n",
+    "\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 62,
+   "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": 63,
+   "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 ' + hasCurrentPermanentLocationCoords.prefix + ' ' + hasCurrentPermanentLocationCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + placeCoords.prefix + ' ' + placeCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasTimeSpanCoords.prefix + ' ' + hasTimeSpanCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + timeSpanCoords.prefix + ' ' + timeSpanCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasNoteCoords.prefix + ' ' + hasNoteCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + stringCoords.prefix + ' ' + stringCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + tookPlaceCoords.prefix + ' ' + tookPlaceCoords.uri + closeLine)        \n",
+    "    output.write('@prefix ' + carriedByCoords.prefix + ' ' + carriedByCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + consistCoords.prefix + ' ' + consistCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + cidocCoords.prefix + ' ' + cidocCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + schemaCoords.prefix + ' ' + schemaCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + materialCoords.prefix + ' ' + materialCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + creationCoords.prefix + ' ' + creationCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + composedCoords.prefix + ' ' + composedCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + dimensionsCoords.prefix + ' ' + dimensionsCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasDimensionsCoords.prefix + ' ' + hasDimensionsCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasCurrentOwnerCoords.prefix + ' ' + hasCurrentOwnerCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasConditionCoords.prefix + ' ' + hasConditionCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + conditionCoords.prefix + ' ' + conditionCoords.uri + closeLine)\n",
+    "    \n",
+    "    \n",
+    "    output.write('\\n')\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 64,
+   "metadata": {
+    "tags": []
+   },
+   "outputs": [],
+   "source": [
+    "filePrefix = 'data_'\n",
+    "fileType = 'maxref'\n",
+    "max_entries = 100000000\n",
+    "\n",
+    "with open(import_dir + filePrefix + fileType + '.csv', newline=\"\") as csv_file, open(export_dir + filePrefix + fileType + '.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",
+    "        if (row['ID'] != ''): \n",
+    "            e16placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"E16\" + \">\"  \n",
+    "            # E42 Identifier\n",
+    "            e25mplaceHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25_m>\"\n",
+    "            e22placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259>\"\n",
+    "            e42placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"E16_\" + identifierCoords.code + \">\"\n",
+    "            line = triple(e16placeHolder, 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, '\\\"MAXRF Manuscript, local\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            # E25 Title\n",
+    "            e35placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"E35\" + \">\"\n",
+    "            line = triple(e16placeHolder, identifiedByCoords.prefix, e35placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e35placeHolder, hasTypeCoords.prefix, titleCoords.prefix) +  closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e35placeHolder, labelCoords.prefix, '\\\"Marlay cutting It. 13A\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            # E28 Format\n",
+    "            e28placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E28>\"\n",
+    "            line = triple(e16placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P94_has_created>', e28placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e28placeHolder, labelCoords.prefix, '\\\"Dataset XRF imaging\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e5528placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"_E28\" + typeCoords.code + \">\"\n",
+    "            line = triple(e28placeHolder, hasTypeCoords.prefix, e5528placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e5528placeHolder, labelCoords.prefix, '\\\"EDF\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e55281placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"_E281\" + typeCoords.code + \">\"\n",
+    "            line = triple(e28placeHolder, hasTypeCoords.prefix, e55281placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55281placeHolder, labelCoords.prefix, '\\\"TIFF\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            # E16 Measurement\n",
+    "            tecPlaceholder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_>\"\n",
+    "            line = triple(e16placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder, labelCoords.prefix, '\\\"Scanning X-ray fluorescence spectroscopy (MAXRF)\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder, hasTypeCoords.prefix, '\\\"DESCRIPTIONS AND NOTES\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            tecPlaceholder1 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_1>\"\n",
+    "            line = triple(e16placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder1) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder1, labelCoords.prefix, '\\\"XRF Imaging\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder1 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_1_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder1, hasTypeCoords.prefix, '\\\"TYPE\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            tecPlaceholder2 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_2>\"\n",
+    "            line = triple(e16placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder2) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder2, labelCoords.prefix, '\\\"X-ray Fluorescence\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder2 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_2_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder2, hasTypeCoords.prefix, '\\\"TYPE\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            tecPlaceholder3 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_3>\"\n",
+    "            line = triple(e16placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder3) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder3, labelCoords.prefix, '\\\"Infrared reflectography  Near-infrared imaging  Optical microscopy  Raman spectroscopy  UV-vis-NIR reflectance spectroscopy  X-ray fluorescence spectroscopy\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder2 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_3_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder3, hasTypeCoords.prefix, '\\\"PRELIMINARY ANALYSIS\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            tecPlaceholder4 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_4>\"\n",
+    "            line = triple(e16placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder4) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder4, labelCoords.prefix, '\\\"In-situ scientific investigation of the original pigments, the painting technique and the artistic process employed by artist\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder2 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_4_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder4, hasTypeCoords.prefix, '\\\"METHOD\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            tecPlaceholder5 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_5>\"\n",
+    "            line = triple(e16placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder5) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder5, labelCoords.prefix, '\\\"LANDIS-X MA-XRF scanner\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder5 = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tec_5_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder5, hasTypeCoords.prefix, '\\\"PHYSICAL TOOL\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "\n",
+    "            \n",
+    "\n",
+    "            e57placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E16\" + materialCoords.code + \">\"  \n",
+    "            line = triple(e16placeHolder, consistCoords.prefix, e57placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, hasTypeCoords.prefix, materialCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, hasTypePCoords.prefix, '\\\"Keywords\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, labelCoords.prefix, '\\\"pictorial pigments  pictorial surface  restoration materials \\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(consistCoords.prefix, labelCoords.prefix, '\\\"consist of\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            # E60 NUMBER OF PART/COMPONENT\n",
+    "            e60placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"E60>\"\n",
+    "            line = triple(e16placeHolder, composedCoords.prefix, e60placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e60placeHolder, labelCoords.prefix, '\\\"2\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e60placeHolder, hasTypeCoords.prefix, '\\\"NUMBER OF PART/COMPONENT\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e53placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + placeCoords.code + \">\"\n",
+    "            line = triple(e16placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>', e53placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            \n",
+    "            line = triple(e53placeHolder, labelCoords.prefix, '\\\"ISPC X-rayLAB, Catania, Italy\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e5553placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + placeCoords.code + \"_\" + typeCoords.code + \">\"\n",
+    "            line = triple(e53placeHolder, hasTypeCoords.prefix, e5553placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e5553placeHolder, labelCoords.prefix, '\\\"PEOPLE/INSTITUTIONS INVOLVED IN THE ANALYSIS\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e531placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + placeCoords.code + \"_1>\"\n",
+    "            line = triple(e16placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>', e531placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e531placeHolder, labelCoords.prefix, '\\\"The Department of Manuscripts and Printed Books, Fitzwilliam Museum, Cambridge\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e55531placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + placeCoords.code + \"_1\" + typeCoords.code + \">\"\n",
+    "            line = triple(e531placeHolder, hasTypeCoords.prefix, e55531placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55531placeHolder, labelCoords.prefix, '\\\"PEOPLE/INSTITUTIONS INVOLVED IN THE INTERPRETATION\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            \n",
+    "        output.write('\\n')\n",
+    "        # Limit number of entries processed (if desired)\n",
+    "        if(ii>max_entries):\n",
+    "            break"
+   ]
+  }
+ ],
+ "metadata": {
+  "interpreter": {
+   "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
+  },
+  "kernelspec": {
+   "display_name": "Python 3.9.0 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
+}

+ 344 - 0
CSV_to_RDF/ISPC/CSV_to_RDF_illumination.ipynb

@@ -0,0 +1,344 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "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": 2,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import_dir = '/Users/federicaspinelli/Google Drive/OVI-CNR/CSV/corali/'\n",
+    "export_dir = '/Users/federicaspinelli/Google Drive/OVI-CNR/RDF/corali/'"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "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",
+    "\n",
+    "# Repositories\n",
+    "datiniCoords = RDFcoords('<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoSt005/scheda/IT-ASPO-ST00005->', 'dt:')\n",
+    "personAuthCoords = RDFcoords('<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-AU00002->', 'pa:')\n",
+    "# W3/CIDOC Predicates\n",
+    "hasTypeCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>', 'tp:')\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",
+    "carriedByCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>', 'cb:')\n",
+    "hasCurrentPermanentLocationCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P54_has_current_permanent_location>', 'ap:')\n",
+    "placeCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E53_Place>', 'pl:', 'E53')\n",
+    "hasTimeSpanCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P4_has_time-span>', 'hs:')\n",
+    "hasNoteCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P3_has_note>', 'no:')\n",
+    "hasCurrentOwnerCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P52_has_current_owner>', 'ow:')\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",
+    "timeSpanCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E52_Time-Span>', 'ts:', 'E52')\n",
+    "stringCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E62_String>', 'st:', 'E62')\n",
+    "tookPlaceCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P7_took_place_at>', 'tk:')\n",
+    "carriedByCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>', 'cb:')\n",
+    "consistCoords = RDFcoords('<http://cidoc-crm.org/cidoc-crm/7.1.1/P45_consists_of>', 'cf:')\n",
+    "cidocCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/>', 'crm:')\n",
+    "schemaCoords = RDFcoords('<http://schema.org/>', 'schema:')\n",
+    "personCoords = RDFcoords('<http://www.w3.org/ns/person#>', 'person:')\n",
+    "nsCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#>', 'rdf:')\n",
+    "materialCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E57_Material>', 'mt:', 'E57')\n",
+    "composedCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P46_is_composed_of>', 'cmp:')\n",
+    "dimensionsCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E54_Dimension>', 'dm:', 'E54')\n",
+    "hasDimensionsCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P43_has_dimension>', 'hd:')\n",
+    "hasConditionCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P44_has_condition>', 'hc:')\n",
+    "conditionCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E3_Condition_State>', 'cs:', 'E3')\n",
+    "\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "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": 5,
+   "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 ' + hasCurrentPermanentLocationCoords.prefix + ' ' + hasCurrentPermanentLocationCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + placeCoords.prefix + ' ' + placeCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasTimeSpanCoords.prefix + ' ' + hasTimeSpanCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + timeSpanCoords.prefix + ' ' + timeSpanCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasNoteCoords.prefix + ' ' + hasNoteCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + stringCoords.prefix + ' ' + stringCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + tookPlaceCoords.prefix + ' ' + tookPlaceCoords.uri + closeLine)        \n",
+    "    output.write('@prefix ' + carriedByCoords.prefix + ' ' + carriedByCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + consistCoords.prefix + ' ' + consistCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + cidocCoords.prefix + ' ' + cidocCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + schemaCoords.prefix + ' ' + schemaCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + materialCoords.prefix + ' ' + materialCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + creationCoords.prefix + ' ' + creationCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + composedCoords.prefix + ' ' + composedCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + dimensionsCoords.prefix + ' ' + dimensionsCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasDimensionsCoords.prefix + ' ' + hasDimensionsCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasCurrentOwnerCoords.prefix + ' ' + hasCurrentOwnerCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasConditionCoords.prefix + ' ' + hasConditionCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + conditionCoords.prefix + ' ' + conditionCoords.uri + closeLine)\n",
+    "    output.write('\\n')\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {
+    "tags": []
+   },
+   "outputs": [
+    {
+     "ename": "NameError",
+     "evalue": "name 'e73placeHolder' is not defined",
+     "output_type": "error",
+     "traceback": [
+      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
+      "\u001b[0;32m/var/folders/_n/1ldwyw1s547dcpvn3485fr7r0000gn/T/ipykernel_16200/872495697.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m     24\u001b[0m             \u001b[0;31m# E25 Title\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     25\u001b[0m             \u001b[0me35placeHolder\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"E25m_\"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"E35\"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\">\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m             \u001b[0mline\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtriple\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me73placeHolder\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0midentifiedByCoords\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprefix\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0me35placeHolder\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mcloseLine\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     27\u001b[0m             \u001b[0moutput\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     28\u001b[0m             \u001b[0mline\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtriple\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me35placeHolder\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhasTypeCoords\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprefix\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtitleCoords\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprefix\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m  \u001b[0mcloseLine\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+      "\u001b[0;31mNameError\u001b[0m: name 'e73placeHolder' is not defined"
+     ]
+    }
+   ],
+   "source": [
+    "filePrefix = 'data_'\n",
+    "fileType = 'maxref'\n",
+    "max_entries = 100000000\n",
+    "\n",
+    "with open(import_dir + filePrefix + fileType + '.csv', newline=\"\") as csv_file, open(export_dir + filePrefix + fileType + 'min.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",
+    "        if (row['ID'] != ''): \n",
+    "            e73placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259\" + \"_E25m\" + informationObjectCoords.code + \">\"\n",
+    "            \n",
+    "            e25mplaceHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25_m>\"\n",
+    "            # E42 Identifier\n",
+    "            e22placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259>\"\n",
+    "            e42placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"E25m_\" + identifierCoords.code + \">\"\n",
+    "            #line = triple(e25mplaceHolder, 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, '\\\"Historiated initial S from a Gradual\\\"') + closeLine\n",
+    "            #output.write(line)\n",
+    "            # E25 Title\n",
+    "            e35placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"E25m_\" + \"E35\" + \">\"\n",
+    "            line = triple(e73placeHolder, identifiedByCoords.prefix, e35placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e35placeHolder, hasTypeCoords.prefix, titleCoords.prefix) +  closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e35placeHolder, labelCoords.prefix, '\\\"Presentation in the Temple\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e35placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P139_has_alternative_form>', '\\\"Marlay cutting It. 13A\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e57placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25m\" + materialCoords.code + \">\"  \n",
+    "            line = triple(e25mplaceHolder, consistCoords.prefix, e57placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, hasTypeCoords.prefix, materialCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, labelCoords.prefix, '\\\"Parchment, mounted on cardboard\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(consistCoords.prefix, labelCoords.prefix, '\\\"consist of\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            # E73 Information Object\n",
+    "            line = triple(e25mplaceHolder, carriesCoords.prefix, e73placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e73placeHolder, hasTypeCoords.prefix, informationObjectCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e73placeHolder, labelCoords.prefix, '\\\"Information object: Presentation in the Temple\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            # E65 Creation\n",
+    "            e65placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259\" + \"_E25m_\" + creationCoords.code + \">\"\n",
+    "            line = triple(e73placeHolder, wasBroughtCoords.prefix, e65placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e65placeHolder, hasTypeCoords.prefix, creationCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e65placeHolder, labelCoords.prefix, '\\\"Creation of Presentation in the Temple\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            # E52    \n",
+    "            e52placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25m_\" + creationCoords.code + \"_\" + timeSpanCoords.code + \">\"\n",
+    "            line = triple(e65placeHolder, hasTimeSpanCoords.prefix, e52placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e52placeHolder, hasTypeCoords.prefix, timeSpanCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e52placeHolder, labelCoords.prefix, '\\\"1370-1375\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            PC14placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25m_PC14\" + \">\"     \n",
+    "            e39placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25m_E39\" + \">\"\n",
+    "            line = triple(e65placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P01_has_domain>', PC14placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(PC14placeHolder, labelCoords.prefix, \"\\\"Author of the creation\\\"\") + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(PC14placeHolder, hasTypeCoords.prefix, '<http://www.cidoc-crm.org/cidoc-crm/PC14_carried_out_by>') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(PC14placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P02_has_range>', e39placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e39placeHolder, labelCoords.prefix, \"\\\"Don Silvestro dei Gherarducci\\\"\") + closeLine\n",
+    "            output.write(line)\n",
+    "            e39placeHolder2=\"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25m_E39_2\" + \">\"\n",
+    "            line = triple(e39placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P139_has_alternative_form>', e39placeHolder2) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e39placeHolder2, labelCoords.prefix, \"\\\"Silvestro dei Gherarducci\\\"\") + closeLine\n",
+    "            output.write(line)\n",
+    "            E55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25m_E39_E55\" + \">\"\n",
+    "            line = triple(PC14placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P14.1_in_the_role_of>', E55placeHolder) + closeLine\n",
+    "            line = triple(E55placeHolder, hasTypeCoords.prefix, '<http://www.cidoc-crm.org/cidoc-crm/E39_Actor>') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(E55placeHolder, labelCoords.prefix, \"\\\"Author\\\"\" ) + closeLine\n",
+    "            output.write(line)\n",
+    "            e53placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25m_\" + creationCoords.code + \"_\" + placeCoords.code + \">\"\n",
+    "            line = triple(e65placeHolder, tookPlaceCoords.prefix, e53placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e53placeHolder, hasTypeCoords.prefix, placeCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e53placeHolder, labelCoords.prefix, '\\\"Florence\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25m_\" + creationCoords.code + \"_\" + placeCoords.code + \"_\" + typeCoords.code + \">\"\n",
+    "            line = triple(e53placeHolder, hasTypePCoords.prefix, e55placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55placeHolder, labelCoords.prefix, '\\\"Origin\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e73placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P67_refers_to>', '\\\"The initial S introduced the Mass for the feast of the Purification of the Virgin (2 February) in Corale 2, a Gradual made for the monastery of Santa Maria degli Angeli in Florence in 1370-1375. As in many medieval and Renaissance images, the Purification of the Virgin, indicated by the white dove in Joseph’s hands, is conflated with the Circumcision of Christ. Mary and Joseph have entrusted the infant Christ to Simeon and Anna, while the priest behind, knife in hand, is ready to perform the circumcision. Painted by Don Silvestro dei Gherarducci, the image reveals his debt to Sienese painting. The model for the composition is Ambrogio Lorenzetti’s eponymous altarpiece completed in 1342 for the Crescentius Chapel in Siena Cathedral (now in the Uffizi, Florence). The tiled floor imparts a sense of depth to the pictorial space. The intricate designs on the haloes, each displaying a different pattern, emulate the innovative punchwork of Sienese artists from the early 1300s. Three different blue pigments were used in this image: most blue areas were painted with ultramarine, occasionally shaded with an organic red dye which yields a purplish hue, visible in the temple’s walls and in the folds of Anna’s mantle. Ultramarine was also used for the blue leaves in the border, but azurite was added in the dark blue areas, and the leaves were outlined with indigo.\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            # E54\n",
+    "            e54placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25m\" + dimensionsCoords.code + \">\"\n",
+    "            line = triple(e25mplaceHolder, hasDimensionsCoords.prefix, e54placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e54placeHolder, hasTypeCoords.prefix, dimensionsCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e54placeHolder, labelCoords.prefix, '\\\"300 x 270 mm\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            # E22 - P52 - E74\n",
+    "            E74placeHolder = '<http://fitzmuseum.cam.ac.uk/>'\n",
+    "            line = triple(e25mplaceHolder, '<http://www.cidoc-crm.org/cidoc-crm/P52_has_current_owner>', E74placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(E74placeHolder, labelCoords.prefix, \"\\\"Fitzwilliam Museum, University of Cambridge\\\"\") + closeLine\n",
+    "            output.write(line)\n",
+    "            \n",
+    "        output.write('\\n')\n",
+    "        # Limit number of entries processed (if desired)\n",
+    "        if(ii>max_entries):\n",
+    "            break"
+   ]
+  }
+ ],
+ "metadata": {
+  "interpreter": {
+   "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
+  },
+  "kernelspec": {
+   "display_name": "Python 3.9.0 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
+}

+ 549 - 0
CSV_to_RDF/ISPC/CSV_to_RDF_manuscript.ipynb

@@ -0,0 +1,549 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 91,
+   "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": 92,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import_dir = '/Users/federicaspinelli/Google Drive/OVI-CNR/CSV/corali/'\n",
+    "export_dir = '/Users/federicaspinelli/Google Drive/OVI-CNR/RDF/corali/'"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 93,
+   "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",
+    "\n",
+    "# Repositories\n",
+    "datiniCoords = RDFcoords('<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoSt005/scheda/IT-ASPO-ST00005->', 'dt:')\n",
+    "personAuthCoords = RDFcoords('<http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-AU00002->', 'pa:')\n",
+    "# W3/CIDOC Predicates\n",
+    "hasTypeCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>', 'tp:')\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",
+    "carriedByCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>', 'cb:')\n",
+    "hasCurrentPermanentLocationCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P54_has_current_permanent_location>', 'ap:')\n",
+    "placeCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E53_Place>', 'pl:', 'E53')\n",
+    "hasTimeSpanCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P4_has_time-span>', 'hs:')\n",
+    "hasNoteCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P3_has_note>', 'no:')\n",
+    "hasCurrentOwnerCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P52_has_current_owner>', 'ow:')\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",
+    "timeSpanCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E52_Time-Span>', 'ts:', 'E52')\n",
+    "stringCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E62_String>', 'st:', 'E62')\n",
+    "tookPlaceCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P7_took_place_at>', 'tk:')\n",
+    "carriedByCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>', 'cb:')\n",
+    "consistCoords = RDFcoords('<http://cidoc-crm.org/cidoc-crm/7.1.1/P45_consists_of>', 'cf:')\n",
+    "cidocCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/>', 'crm:')\n",
+    "schemaCoords = RDFcoords('<http://schema.org/>', 'schema:')\n",
+    "personCoords = RDFcoords('<http://www.w3.org/ns/person#>', 'person:')\n",
+    "nsCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#>', 'rdf:')\n",
+    "materialCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E57_Material>', 'mt:', 'E57')\n",
+    "composedCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P46_is_composed_of>', 'cmp:')\n",
+    "dimensionsCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E54_Dimension>', 'dm:', 'E54')\n",
+    "hasDimensionsCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P43_has_dimension>', 'hd:')\n",
+    "hasConditionCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/P44_has_condition>', 'hc:')\n",
+    "conditionCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/E3_Condition_State>', 'cs:', 'E3')\n",
+    "\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 94,
+   "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": 95,
+   "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 ' + hasCurrentPermanentLocationCoords.prefix + ' ' + hasCurrentPermanentLocationCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + placeCoords.prefix + ' ' + placeCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasTimeSpanCoords.prefix + ' ' + hasTimeSpanCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + timeSpanCoords.prefix + ' ' + timeSpanCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasNoteCoords.prefix + ' ' + hasNoteCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + stringCoords.prefix + ' ' + stringCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + tookPlaceCoords.prefix + ' ' + tookPlaceCoords.uri + closeLine)        \n",
+    "    output.write('@prefix ' + carriedByCoords.prefix + ' ' + carriedByCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + consistCoords.prefix + ' ' + consistCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + cidocCoords.prefix + ' ' + cidocCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + schemaCoords.prefix + ' ' + schemaCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + materialCoords.prefix + ' ' + materialCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + creationCoords.prefix + ' ' + creationCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + composedCoords.prefix + ' ' + composedCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + dimensionsCoords.prefix + ' ' + dimensionsCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasDimensionsCoords.prefix + ' ' + hasDimensionsCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasCurrentOwnerCoords.prefix + ' ' + hasCurrentOwnerCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + hasConditionCoords.prefix + ' ' + hasConditionCoords.uri + closeLine)\n",
+    "    output.write('@prefix ' + conditionCoords.prefix + ' ' + conditionCoords.uri + closeLine)\n",
+    "    \n",
+    "    \n",
+    "    output.write('\\n')\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 96,
+   "metadata": {
+    "tags": []
+   },
+   "outputs": [],
+   "source": [
+    "filePrefix = 'data_'\n",
+    "fileType = 'corali'\n",
+    "max_entries = 100000000\n",
+    "\n",
+    "with open(import_dir + filePrefix + fileType + '.csv', newline=\"\") as csv_file, open(export_dir + filePrefix + fileType + '.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",
+    "        # E42 Identifier\n",
+    "        e22placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259>\"\n",
+    "        if(row['segnatura'] != ''):\n",
+    "            e42placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259\" + \"_\" + identifierCoords.code + \">\"\n",
+    "            line = triple(e22placeHolder, 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, '\\\"Segnatura: ' + row['segnatura'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E22 Man Made Object\n",
+    "        if(row['segnatura'] != ''):\n",
+    "            line = triple(e22placeHolder, hasTypeCoords.prefix, manMadeObjectCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e22placeHolder, labelCoords.prefix, '\\\"Documento fisico: ' + row['nome'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        \n",
+    "        # E73 Information Object\n",
+    "            e73placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259\" + \"_\" + informationObjectCoords.code + \">\"\n",
+    "            line = triple(e22placeHolder, carriesCoords.prefix, e73placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e73placeHolder, hasTypeCoords.prefix, informationObjectCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e73placeHolder, labelCoords.prefix, '\\\"Contenuto informativo: ' + row['nome'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E65 Creation\n",
+    "            e65placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259\" + \"_\" + creationCoords.code + \">\"\n",
+    "            line = triple(e73placeHolder, wasBroughtCoords.prefix, e65placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e65placeHolder, hasTypeCoords.prefix, creationCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e65placeHolder, labelCoords.prefix, '\\\"Creazione di ' + row['nome'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E52    \n",
+    "        if(row['datazione'] != ''):\n",
+    "            e52placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + creationCoords.code + \"_\" + timeSpanCoords.code + \">\"\n",
+    "            line = triple(e65placeHolder, hasTimeSpanCoords.prefix, e52placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e52placeHolder, hasTypeCoords.prefix, timeSpanCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e52placeHolder, labelCoords.prefix, '\\\"' + row['datazione'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E52 E62 \n",
+    "        if(row['nota_datazione'] != ''):\n",
+    "            e62placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + creationCoords.code + \"_\" + timeSpanCoords.code + \"_\" + stringCoords.code + \">\"\n",
+    "            line = triple(e52placeHolder, hasNoteCoords.prefix, e62placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e62placeHolder, labelCoords.prefix, '\\\"' + row['nota_datazione'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e62placeHolder, hasTypeCoords.prefix, stringCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + creationCoords.code + \"_\" + timeSpanCoords.code + \"_\" + stringCoords.code + \"_\" + typeCoords.code + \">\"\n",
+    "            line = triple(e62placeHolder, hasTypePCoords.prefix, e55placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55placeHolder, labelCoords.prefix, '\\\"Nota datazione\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E53 Place\n",
+    "        if(row['luogo_copia'] != ''):\n",
+    "                e53placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + creationCoords.code + \"_\" + placeCoords.code + \">\"\n",
+    "                line = triple(e65placeHolder, tookPlaceCoords.prefix, e53placeHolder) + closeLine\n",
+    "                output.write(line)\n",
+    "                line = triple(e53placeHolder, hasTypeCoords.prefix, placeCoords.prefix) + closeLine\n",
+    "                output.write(line)\n",
+    "                line = triple(e53placeHolder, labelCoords.prefix, '\\\"' + row['luogo_copia'] + '\\\"') + closeLine\n",
+    "                output.write(line)\n",
+    "                e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + creationCoords.code + \"_\" + placeCoords.code + \"_\" + typeCoords.code + \">\"\n",
+    "                line = triple(e65placeHolder, hasTypePCoords.prefix, e55placeHolder) + closeLine\n",
+    "                output.write(line)\n",
+    "                line = triple(e55placeHolder, labelCoords.prefix, '\\\"Luogo di copia\\\"') + closeLine\n",
+    "                output.write(line)\n",
+    "        # E57 Material\n",
+    "        if(row['supporto'] != ''):\n",
+    "            e57placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + materialCoords.code + \"_\" + row['supporto'] + \">\"  \n",
+    "            line = triple(e22placeHolder, consistCoords.prefix, e57placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, hasTypeCoords.prefix, materialCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, hasTypePCoords.prefix, '\\\"Supporto\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, labelCoords.prefix, '\\\"' + row['supporto'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(consistCoords.prefix, labelCoords.prefix, '\\\"consist of\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E57 Material\n",
+    "        if(row['tipologia_supporto'] != ''):\n",
+    "            e57placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + materialCoords.code + \"_\" + row['supporto'] + \"E55>\"  \n",
+    "            line = triple(e22placeHolder, consistCoords.prefix, e57placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, hasTypeCoords.prefix, materialCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, hasTypePCoords.prefix, '\\\"Tipologia supporto\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e57placeHolder, labelCoords.prefix, '\\\"' + row['tipologia_supporto'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(consistCoords.prefix, labelCoords.prefix, '\\\"consist of\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E22 descrizione_fascicolazione\n",
+    "        if(row['descrizione_fascicolazione'] != ''):\n",
+    "            e60placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"fascicolazione>\"\n",
+    "            line = triple(e22placeHolder, composedCoords.prefix, e60placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e60placeHolder, labelCoords.prefix, '\\\"' + row['descrizione_fascicolazione'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e60placeHolder, hasTypeCoords.prefix, '\\\"Descrizione fascicolazione\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E55 descrizione_tecnica descrizione_tecnica_specchio, descrizione_tecnica_rigatura\n",
+    "        if row['descrizione_tecnica_specchio']:\n",
+    "            tecPlaceholder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tecnica_specchio>\"\n",
+    "            line = triple(e22placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder, labelCoords.prefix, '\\\"' + row['descrizione_tecnica_specchio'] + '\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tecnica_specchio_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder, hasTypeCoords.prefix, '\\\"Descrizione tecnica\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E55 descrizione_tecnica_rigatura\n",
+    "        if row['descrizione_tecnica_rigatura']:\n",
+    "            tecPlaceholder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tecnica_rigatura>\"\n",
+    "            line = triple(e22placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder, labelCoords.prefix, '\\\"' + row['descrizione_tecnica_rigatura'] + '\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"tecnica_rigatura_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder, hasTypeCoords.prefix, '\\\"Descrizione tecnica\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E55 descrizione_fisica_paleografia\n",
+    "        if row['descrizione_fisica_paleografia']:\n",
+    "            tecPlaceholder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"descrizione_fisica_paleografia>\"\n",
+    "            line = triple(e22placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder, labelCoords.prefix, '\\\"' + row['descrizione_fisica_paleografia'] + '\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"descrizione_fisica_paleografia_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder, hasTypeCoords.prefix, '\\\"Descrizione paleografica\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E55 nota descrizione_fisica_paleografia\n",
+    "        if row['nota_descrizione_fisica_paleografia']:\n",
+    "            tecPlaceholder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"nota_descrizione_fisica_paleografia>\"\n",
+    "            line = triple(e22placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder, labelCoords.prefix, '\\\"' + row['nota_descrizione_fisica_paleografia'] + '\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"nota_descrizione_fisica_paleografia_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder, hasTypeCoords.prefix, '\\\"Nota descrizione paleografica\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # descrizione_legatura\n",
+    "        if row['descrizione_legatura']:\n",
+    "            tecPlaceholder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"descrizione_legatura>\"\n",
+    "            line = triple(e22placeHolder, cidocCoords.prefix + 'P32_used_general_technique', tecPlaceholder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(tecPlaceholder, labelCoords.prefix, '\\\"' + row['descrizione_legatura'] + '\\\"') + closeLine                \n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"descrizione_legatura_\" + typeCoords.code + \">\"\n",
+    "            line = triple(tecPlaceholder, hasTypeCoords.prefix, '\\\"Descrizione legatura\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E62\n",
+    "        if(row['nota_margine'] != ''):\n",
+    "            e62placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + stringCoords.code + \">\"\n",
+    "            line = triple(e22placeHolder, hasNoteCoords.prefix, e62placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e62placeHolder, labelCoords.prefix, '\\\"' + row['nota_margine'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + stringCoords.code + \"_\" + typeCoords.code + \">\"\n",
+    "            line = triple(e62placeHolder, hasTypePCoords.prefix, e55placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55placeHolder, labelCoords.prefix, '\\\"Nota a margine\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E54\n",
+    "        if(row['dimensione_altezza_larghezza_spessore'] != ''):\n",
+    "            e54placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + dimensionsCoords.code + \">\"\n",
+    "            line = triple(e22placeHolder, hasDimensionsCoords.prefix, e54placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e54placeHolder, hasTypeCoords.prefix, dimensionsCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e54placeHolder, labelCoords.prefix, '\\\"' + row['dimensione_altezza_larghezza_spessore'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        \n",
+    "        # E22 - P62 - E1\n",
+    "        if row['descrizione_decorazioni'] != '':\n",
+    "                e1placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"description\" + \">\"\n",
+    "                line = triple(e22placeHolder,\n",
+    "                          cidocCoords.prefix + 'P62_depicts',\n",
+    "                          e1placeHolder) + closeLine\n",
+    "                output.write(line)\n",
+    "                line = triple(e1placeHolder,\n",
+    "                            nsCoords.prefix + 'type',\n",
+    "                            cidocCoords.prefix + 'E1_CRM_Entity') + closeLine\n",
+    "                output.write(line)\n",
+    "                line = triple(e1placeHolder,\n",
+    "                            labelCoords.prefix, '\\\"' + row['descrizione_decorazioni'] + '\\\"') + closeLine\n",
+    "                output.write(line)\n",
+    "                line = triple(e1placeHolder,\n",
+    "                            cidocCoords.prefix + 'P2_has_type',\n",
+    "                            '\\\"Descrizione decorazione\\\"') + closeLine\n",
+    "        # E22 - P52 - E74\n",
+    "        E74placeHolder = '<http://www.mirabileweb.it/search-place/italia-toscana-firenze-s-maria-degli-angeli-monast-place/1044/6129>'\n",
+    "        line = triple(e22placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P51_has_former_or_current_owner>', E74placeHolder) + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(E74placeHolder, labelCoords.prefix, \"\\\"Firenze, S. Maria degli Angeli, monastero (sec. XIV terzo quarto-XIX in.)\\\"\") + closeLine\n",
+    "        output.write(line)\n",
+    "        # E22 - P52 - E74\n",
+    "        E74placeHolder = '<http://www.mirabileweb.it/search-place/italia-toscana-firenze-s-maria-degli-angeli-monast-place/1044/6129_L>'\n",
+    "        line = triple(e22placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P52_has_current_owner>', E74placeHolder) + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(E74placeHolder, labelCoords.prefix, \"\\\"Firenze, Biblioteca Medicea Laurenziana\\\"\") + closeLine\n",
+    "        output.write(line)\n",
+    "        # E62\n",
+    "        if row['bioghist'] != '':\n",
+    "            e62placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + stringCoords.code + \"_H>\"\n",
+    "            line = triple(e22placeHolder, hasNoteCoords.prefix, e62placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e62placeHolder, labelCoords.prefix, '\\\"' + row['bioghist'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + stringCoords.code + \"_H_\"+typeCoords.code + \">\"\n",
+    "            line = triple(e62placeHolder, hasTypePCoords.prefix, e55placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55placeHolder, labelCoords.prefix, '\\\"Storia del manoscritto\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        if(row['consistenza'] != ''):\n",
+    "            e54placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E54\" + \">\"\n",
+    "            line = triple(e22placeHolder, hasDimensionsCoords.prefix, e54placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e54placeHolder, hasTypeCoords.prefix, dimensionsCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e54placeHolder, labelCoords.prefix, '\\\"'+ row['consistenza'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E3 Condition State\n",
+    "        e3placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + conditionCoords.code + \">\"\n",
+    "        line = triple(e3placeHolder, labelCoords.prefix, '\\\"Stato di conservazione\\\"') + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e3placeHolder, hasTypeCoords.prefix, conditionCoords.prefix) + closeLine\n",
+    "        output.write(line)\n",
+    "        if(row['conservazione'] != ''):\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + conditionCoords.code + \"_\" + typeCoords.code + \"_\" + row['conservazione'] + \">\"  \n",
+    "            line = triple(e22placeHolder, hasConditionCoords.prefix, e55placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55placeHolder, hasTypePCoords.prefix, e3placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55placeHolder, hasTypeCoords.prefix, typeCoords.prefix) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55placeHolder, labelCoords.prefix, '\\\"'+ row['conservazione'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        # E62\n",
+    "        if(row['nota'] != ''):\n",
+    "            e62placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + stringCoords.code + \"N>\"\n",
+    "            line = triple(e22placeHolder, hasNoteCoords.prefix, e62placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e62placeHolder, labelCoords.prefix, '\\\"' + row['nota'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + stringCoords.code + \"_N_\" + typeCoords.code + \">\"\n",
+    "            line = triple(e62placeHolder, hasTypePCoords.prefix, e55placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55placeHolder, labelCoords.prefix, '\\\"Nota\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        if(row['nota_1'] != ''):\n",
+    "            e62placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + stringCoords.code + \"N1>\"\n",
+    "            line = triple(e22placeHolder, hasNoteCoords.prefix, e62placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e62placeHolder, labelCoords.prefix, '\\\"' + row['nota_1'] + '\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "            e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + stringCoords.code + \"_N1_\" + typeCoords.code + \">\"\n",
+    "            line = triple(e62placeHolder, hasTypePCoords.prefix, e55placeHolder) + closeLine\n",
+    "            output.write(line)\n",
+    "            line = triple(e55placeHolder, labelCoords.prefix, '\\\"Nota\\\"') + closeLine\n",
+    "            output.write(line)\n",
+    "        \n",
+    "        # E22 P65 E34\n",
+    "        e25placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25>\"\n",
+    "        line = triple(e22placeHolder,\n",
+    "                          cidocCoords.prefix + 'P56_bears_feature',\n",
+    "                          e25placeHolder) + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e25placeHolder,\n",
+    "                          nsCoords.prefix + 'type',\n",
+    "                          cidocCoords.prefix + 'E25_Man-Made_Feature') + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e25placeHolder,\n",
+    "                          labelCoords.prefix,\n",
+    "                          '\\\"f. 42 \\\"') + closeLine\n",
+    "        output.write(line)\n",
+    "        e25fplaceHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25_f>\"\n",
+    "        line = triple(e25placeHolder,\n",
+    "                          cidocCoords.prefix + 'P56_bears_feature',\n",
+    "                          e25fplaceHolder) + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e25fplaceHolder,\n",
+    "                          nsCoords.prefix + 'type',\n",
+    "                          cidocCoords.prefix + 'E25_Man-Made_Feature') + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e25fplaceHolder,\n",
+    "                          labelCoords.prefix,\n",
+    "                          '\\\"Historiated initial S from a Gradual\\\"') + closeLine\n",
+    "        output.write(line)\n",
+    "        e25mplaceHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_E25_m>\"\n",
+    "        line = triple(e25fplaceHolder,\n",
+    "                          cidocCoords.prefix + 'P56_bears_feature',\n",
+    "                          e25mplaceHolder) + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e25mplaceHolder,\n",
+    "                          nsCoords.prefix + 'type',\n",
+    "                          cidocCoords.prefix + 'E25_Man-Made_Feature') + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e25mplaceHolder,\n",
+    "                          labelCoords.prefix,\n",
+    "                          '\\\"Presentation in the Temple\\\"') + closeLine\n",
+    "        output.write(line)\n",
+    "        e55placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"E25m_\" + typeCoords.code + \">\"\n",
+    "        line = triple(e25mplaceHolder, hasTypePCoords.prefix, e55placeHolder) + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e55placeHolder, labelCoords.prefix, '\\\"Illumination\\\"') + closeLine\n",
+    "        output.write(line)\n",
+    "        # E16 \n",
+    "        e16placeHolder = \"<http://www.mirabileweb.it/manuscript/firenze-biblioteca-medicea-laurenziana-corali-2-manoscript/31259_\" + \"E16\" + \">\"\n",
+    "        line = triple(e16placeHolder, '<http://www.cidoc-crm.org/cidoc-crm/P39_measured>', e25mplaceHolder) + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e16placeHolder, nsCoords.prefix + 'type', cidocCoords.prefix + 'E16_Measurement') + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e16placeHolder, labelCoords.prefix, '\\\"Analytical Technique XRF Imaging\\\"') + closeLine\n",
+    "        output.write(line)\n",
+    "        line = triple(e22placeHolder, hasTypePCoords.prefix, '\\\"Corali \\\"') + closeLine\n",
+    "        output.write(line)\n",
+    "\n",
+    "        output.write('\\n')\n",
+    "        # Limit number of entries processed (if desired)\n",
+    "        if(ii>max_entries):\n",
+    "            break"
+   ]
+  }
+ ],
+ "metadata": {
+  "interpreter": {
+   "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
+  },
+  "kernelspec": {
+   "display_name": "Python 3.9.0 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
+}