removing unused files

This commit is contained in:
Marie-Angélique Laporte 2021-12-13 14:10:59 +01:00
parent cf5f17ff0f
commit 0feba6829a
2 changed files with 0 additions and 50385 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,233 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "solid-grove",
"metadata": {},
"outputs": [],
"source": [
"from rdflib import Graph\n",
"from rdflib.namespace import OWL, DC, DCTERMS, RDF, RDFS, SKOS, XSD\n",
"from rdflib import URIRef, BNode, Literal\n",
"import json\n",
"import os\n",
"import pandas as pd\n",
"import pylode"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "spiritual-geography",
"metadata": {},
"outputs": [],
"source": [
"g = Graph()\n",
"\n",
"##namespace\n",
"NS = \"http://idss.org/terms/\"\n",
"## create ontology\n",
"iseal = URIRef(NS)\n",
"g.add((iseal, RDF.type, OWL.Ontology)) "
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "competitive-turkish",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_excel('/Users/marie-angeliquelaporte/Documents/jupyter/ISEAL/idss_schema_fields.xlsx')\n",
"df.dropna(how='all', axis=1)\n",
"df.fillna('', inplace=True)\n",
"\n",
"\n",
"for index, row in df.iterrows() :\n",
" element_name = row['element name']\n",
" element_description = row['element description']\n",
" comment = row['element guidance']\n",
" example = row['element link for more information']\n",
" cardinality = row['element options']\n",
" prop_type = row['element type']\n",
" controlled_vocab = row['element controlled values or terms']\n",
" module = row['idss module']\n",
" module_cat = row['idss module category']\n",
" \n",
" ##module\n",
" moduleUri = URIRef(NS+module)\n",
" if not (None, SKOS.prefLabel, Literal(module)) in g:\n",
" ##create module as skos concept\n",
" g.add((moduleUri, RDF.type, OWL.Class)) ## SKOS.Concept\n",
" g.add((moduleUri, SKOS.prefLabel, Literal(module)))\n",
" ##element\n",
" if '-' in element_name:\n",
" concept = element_name.split(' - ')[0]\n",
" element = element_name.split(' - ')[1]\n",
" \n",
" conceptUri = URIRef(NS+concept.replace(\" \", \"_\"))\n",
" if not (None, SKOS.prefLabel, Literal(concept)) in g:\n",
" ##create concept as skos concept\n",
" g.add((conceptUri, RDF.type, OWL.Class)) ## SKOS.Concept\n",
" g.add((conceptUri, SKOS.prefLabel, Literal(concept)))\n",
" g.add((conceptUri, RDFS.subClassOf, moduleUri))\n",
" \n",
" ## create properties\n",
" elementURI = URIRef(NS+element.replace(\" \", \"_\"))\n",
" if prop_type == 'CONTROLLED VALUE': ## object property\n",
" g.add((elementURI, SKOS.prefLabel, Literal(element)))\n",
" g.add((elementURI, RDF.type, OWL.ObjectProperty))\n",
" g.add((elementURI, RDFS.domain, conceptUri))\n",
" \n",
" ## create controlled vocab\n",
" cvURI = URIRef(NS+\"VOCAB_\"+element.replace(\" \", \"_\"))\n",
" g.add((cvURI, RDF.type, OWL.Class)) ## SKOS.Concept ## SKOS.Collection??\n",
" g.add((cvURI, SKOS.prefLabel, Literal(\"VOCAB \"+element)))\n",
" for term in controlled_vocab.split(\"||\"):\n",
" termURI = URIRef(NS+term.replace(\" \", \"_\").replace(\"|\", \"\"))\n",
" g.add((termURI, RDF.type, OWL.Class)) ## SKOS.Concept\n",
" g.add((termURI, SKOS.prefLabel, Literal(term)))\n",
" g.add((termURI, RDFS.subClassOf, cvURI)) ## SKOS.member???\n",
" g.add((elementURI, OWL.range, cvURI))\n",
" \n",
" ## cardinality\n",
" if cardinality == 'MULTI SELECT FROM CONTROL LIST':\n",
" br = BNode()\n",
" g.add((br, RDF.type, OWL.Restriction))\n",
" g.add((br, OWL.onProperty, elementURI))\n",
" g.add((br, OWL.someValuesFrom, cvURI))\n",
" g.add((conceptUri, RDFS.subClassOf, br))\n",
" else:\n",
" br = BNode()\n",
" g.add((br, RDF.type, OWL.Restriction))\n",
" g.add((br, OWL.onProperty, elementURI))\n",
" g.add((br, OWL.maxQualifiedCardinality, Literal(1)))\n",
" g.add((br, OWL.onClass, cvURI))\n",
" g.add((conceptUri, RDFS.subClassOf, br))\n",
" \n",
" #elif prop_type == 'URL': ## object property\n",
" # g.add((elementURI, RDF.type, OWL.ObjectProperty))\n",
" # g.add((elementURI, OWL.domain, conceptUri))\n",
" # g.add((elementURI, OWL.range, URIRef(\"\") ))\n",
" # g.add((elementURI, SKOS.prefLabel, Literal(element)))\n",
" else: ## datatype properties\n",
" g.add((elementURI, SKOS.prefLabel, Literal(element)))\n",
" g.add((elementURI, RDF.type, OWL.DatatypeProperty))\n",
" g.add((elementURI, RDFS.domain, conceptUri))\n",
" range = None\n",
" if prop_type == 'DATE':\n",
" g.add((elementURI, RDFS.range, XSD.date ))\n",
" range = XSD.date\n",
" elif prop_type == 'NUMERIC VALUE':\n",
" g.add((elementURI, RDFS.range, XSD.float))\n",
" range = XSD.float\n",
" else:\n",
" g.add((elementURI, RDFS.range, XSD.string))\n",
" range = XSD.string\n",
" ##cardinality\n",
" if cardinality == 'REPEAT VALUES':\n",
" br = BNode()\n",
" g.add((br, RDF.type, OWL.Restriction))\n",
" g.add((br, OWL.onProperty, elementURI))\n",
" g.add((br, OWL.someValuesFrom, range))\n",
" g.add((conceptUri, RDFS.subClassOf, br))\n",
" else:\n",
" br = BNode()\n",
" g.add((br, RDF.type, OWL.Restriction))\n",
" g.add((br, OWL.onProperty, elementURI))\n",
" g.add((br, OWL.maxQualifiedCardinality, Literal(1)))\n",
" g.add((br, OWL.onDataRange, range))\n",
" g.add((conceptUri, RDFS.subClassOf, br))\n",
" \n",
" \n",
" if comment:\n",
" g.add((elementURI, SKOS.scopeNote, Literal(comment)))\n",
" if example:\n",
" g.add((elementURI, RDFS.comment, Literal(example)))\n",
" if element_description:\n",
" g.add((elementURI, SKOS.definition, Literal(element_description)))\n",
" else:\n",
" print(element_name)\n",
" \n",
" \n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "subject-asian",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 5,
"id": "sudden-elite",
"metadata": {},
"outputs": [],
"source": [
"## save graph\n",
"g.serialize(destination='idds.ttl', format='turtle')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "subsequent-zealand",
"metadata": {},
"outputs": [],
"source": [
"html = pylode.MakeDocco(\n",
" input_data_file=\"idds.ttl\",\n",
" outputformat=\"html\",\n",
" profile=\"ontdoc\"\n",
").document()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "occupied-caribbean",
"metadata": {},
"outputs": [],
"source": [
"f = open('documentation.html', 'w' )\n",
"f.write( html )\n",
"f.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "abstract-consortium",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}