|
@@ -1,270 +0,0 @@
|
|
|
-
|
|
|
-import csv
|
|
|
-
|
|
|
-import unicodedata
|
|
|
-
|
|
|
-from collections import OrderedDict
|
|
|
-
|
|
|
-import json
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-from datetime import datetime
|
|
|
-
|
|
|
-from random import *
|
|
|
-
|
|
|
-import sys
|
|
|
-
|
|
|
-import json
|
|
|
-
|
|
|
-import_dir = '/Users/alessiaspadi/Documents/RESTORE/temp_MPP/tabelle/Datini/mod/'
|
|
|
-export_dir = '/Users/alessiaspadi/Documents/RESTORE/temp_MPP/tabelle/Datini/mod/E21_'
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-class RDFcoords:
|
|
|
- def __init__(self, uri, prefix, code = None):
|
|
|
- self.uri = uri
|
|
|
- self.prefix = prefix
|
|
|
- self.code = code
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-museoCoords = RDFcoords('<http://palazzopretorio.comune.prato.it/it/le-opere/alcuni-capolavori/>', 'mpp:')
|
|
|
-autCoords = RDFcoords('<http://palazzopretorio.comune.prato.it/it/opere/autori/>', 'aut:')
|
|
|
-
|
|
|
-cidocCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/>', 'crm:')
|
|
|
-aatCoords = RDFcoords('<http://vocab.getty.edu/aat/>', 'aat:')
|
|
|
-nsCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#>', 'rdf:')
|
|
|
-schemaCoords = RDFcoords('<http://www.w3.org/2000/01/rdf-schema#>', 'rdfs:')
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-def triple(subject, predicate, object1):
|
|
|
- line = subject + ' ' + predicate + ' ' + object1
|
|
|
- return line
|
|
|
-
|
|
|
-def doublet(predicate, object1):
|
|
|
- line = ' ' + predicate + ' ' + object1
|
|
|
- return line
|
|
|
-
|
|
|
-def singlet(object1):
|
|
|
- line = ' ' + object1
|
|
|
- return line
|
|
|
-
|
|
|
-
|
|
|
-continueLine1 = ' ;\n'
|
|
|
-continueLine2 = ' ,\n'
|
|
|
-closeLine = ' .\n'
|
|
|
-
|
|
|
-def writeTTLHeader(output):
|
|
|
- output.write('@prefix ' + museoCoords.prefix + ' ' + museoCoords.uri + closeLine)
|
|
|
- output.write('@prefix ' + autCoords.prefix + ' ' + autCoords.uri + closeLine)
|
|
|
- output.write('@prefix ' + cidocCoords.prefix + ' ' + cidocCoords.uri + closeLine)
|
|
|
- output.write('@prefix ' + aatCoords.prefix + ' ' + aatCoords.uri + closeLine)
|
|
|
- output.write('@prefix ' + schemaCoords.prefix + ' ' + schemaCoords.uri + closeLine)
|
|
|
- output.write('@prefix ' + nsCoords.prefix + ' ' + nsCoords.uri + closeLine)
|
|
|
-
|
|
|
- output.write('\n')
|
|
|
-
|
|
|
-
|
|
|
-filePrefix = 'AR20AUT_'
|
|
|
-fileType = 'Datini'
|
|
|
-max_entries = 1000000000
|
|
|
-
|
|
|
-with open(import_dir + filePrefix + fileType + '.csv', newline="") as csv_file, open(
|
|
|
- export_dir + filePrefix + fileType + '.ttl', 'w') as output:
|
|
|
- reader = csv.DictReader(csv_file)
|
|
|
- writeTTLHeader(output)
|
|
|
- first = True
|
|
|
- ii = 0
|
|
|
- for row in reader:
|
|
|
-
|
|
|
- ii = ii + 1
|
|
|
-
|
|
|
- url = row['URL']
|
|
|
-
|
|
|
-
|
|
|
- e21placeHolder = autCoords.prefix + url
|
|
|
- e62placeHolder = autCoords.prefix + url + '_E62'
|
|
|
- e41placeHolder = autCoords.prefix + url + '_E41'
|
|
|
- e42placeHolder = autCoords.prefix + url + '_E42'
|
|
|
- e67placeHolder = autCoords.prefix + url + '_E67'
|
|
|
- e69placeHolder = autCoords.prefix + url + '_E69'
|
|
|
-
|
|
|
-
|
|
|
- line = triple(e21placeHolder, nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E21_Person') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e21placeHolder, schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['AUTN'] + ', ' + row['AUTA'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e21placeHolder, cidocCoords.prefix + 'P3_has_note',
|
|
|
- e62placeHolder) + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
- line = triple(e62placeHolder, nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E62') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e62placeHolder, schemaCoords.prefix + 'label',
|
|
|
- '\"Fonte: Museo di Palazzo Pretorio - Collezione Datini\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- line = triple(e21placeHolder, cidocCoords.prefix + 'P1_is_identified_by',
|
|
|
- e42placeHolder) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e42placeHolder, nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E42_Identifier') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e42placeHolder, schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['AUTH'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- '''line = triple(e21placeHolder, cidocCoords.prefix + 'P1_is_identified_by',
|
|
|
- e41placeHolder) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e41placeHolder, nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E41_Appellation') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e41placeHolder, schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['AUTN'] + '\"') + closeLine
|
|
|
- output.write(line)'''
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if row['AUTU'] != '':
|
|
|
- group = []
|
|
|
- if '/' in row['AUTU']:
|
|
|
- group = row['AUTU'].split('/')
|
|
|
- else:
|
|
|
- group.append(row['AUTU'])
|
|
|
-
|
|
|
- for gr in group:
|
|
|
- gg = gr.replace(' ', '')
|
|
|
- e74placeHolder = museoCoords.prefix + gg
|
|
|
- line = triple(e21placeHolder,
|
|
|
- cidocCoords.prefix + 'P107i_is_current_or_former_member_of',
|
|
|
- e74placeHolder) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e74placeHolder,
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E74_Group') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e74placeHolder,
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['AUTU'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- line = triple(e21placeHolder,
|
|
|
- cidocCoords.prefix + 'P98i_was_born',
|
|
|
- e67placeHolder) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e67placeHolder,
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E67_Birth') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e67placeHolder,
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"Nascita di ' + row['AUTN'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
- line = triple(e21placeHolder,
|
|
|
- cidocCoords.prefix + 'P100i_died_in',
|
|
|
- e69placeHolder) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e69placeHolder,
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E69_Death') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e69placeHolder,
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"Morte di ' + row['AUTN'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if row['AUTL'] != '':
|
|
|
- line = triple(e67placeHolder,
|
|
|
- cidocCoords.prefix + 'P7_took_place_at',
|
|
|
- museoCoords.prefix + row['AUTL']) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + row['AUTL'],
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E53_Place') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + row['AUTL'],
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['AUTL'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if row['AUTD'] != '':
|
|
|
- tt = row['AUTD'].replace(' ', '')
|
|
|
- tim = tt.replace('/', '')
|
|
|
- time = tim.replace('.', '')
|
|
|
- line = triple(e67placeHolder,
|
|
|
- cidocCoords.prefix + 'P4_has_time-span',
|
|
|
- museoCoords.prefix + time) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + time,
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E52_Time_Span') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + time,
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['AUTD'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if row['AUTX'] != '':
|
|
|
- line = triple(e69placeHolder,
|
|
|
- cidocCoords.prefix + 'P7_took_place_at',
|
|
|
- museoCoords.prefix + row['AUTX']) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + row['AUTX'],
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E53_Place') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + row['AUTX'],
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['AUTX'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if row['AUTT'] != '':
|
|
|
- tt = row['AUTT'].replace(' ', '')
|
|
|
- tim = tt.replace('/', '')
|
|
|
- time = tim.replace('.', '')
|
|
|
- line = triple(e69placeHolder,
|
|
|
- cidocCoords.prefix + 'P4_has_time-span',
|
|
|
- museoCoords.prefix + time) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + time,
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E52_Time_Span') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + time,
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['AUTT'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
- output.write('\n')
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (ii > max_entries):
|
|
|
- break
|