Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Jan 29, 2024
1 parent 98d0856 commit ba513e5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/sparqlunicorn_ontdoc/docgeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,19 +883,21 @@ def createHTMLTableValueEntry(self,subject,pred,object,ttlf,graph,baseurl,checkd
annobodies=mydata["annobodies"]
if inverse:
rdfares = " about=\"" + str(object) + "\" resource=\"" + str(subject) + "\""
microdatares=" itemref=\""+str(object)+"\" "
else:
rdfares = "resource=\"" + str(object) + "\""
microdatares=" "
if baseurl in str(object) or isinstance(object,BNode):
rellink = DocUtils.generateRelativeLinkFromGivenDepth(baseurl,checkdepth,str(object),True)
tablecontents += "<span><a property=\"" + str(pred) + "\" "+rdfares+" href=\"" + rellink + "\">"+ label + " <span style=\"color: #666;\">(" + self.namespaceshort + ":" + str(DocUtils.shortenURI(str(object))) + ")</span></a>"
tablecontents += "<span><a itemprop=\""+str(pred)+"\""+microdatares+"property=\"" + str(pred) + "\" "+rdfares+" href=\"" + rellink + "\">"+ label + " <span style=\"color: #666;\">(" + self.namespaceshort + ":" + str(DocUtils.shortenURI(str(object))) + ")</span></a>"
if bibtex!=None:
tablecontents+="<details><summary>[BIBTEX]</summary><pre>"+str(bibtex)+"</pre></details>"
else:
res = DocUtils.replaceNameSpacesInLabel(self.prefixes,str(object))
if res != None:
tablecontents += "<span><a property=\"" + str(pred) + "\" "+rdfares+" target=\"_blank\" href=\"" + str(object) + "\">" + label + " <span style=\"color: #666;\">(" + res["uri"] + ")</span></a>"
tablecontents += "<span><a itemprop=\""+str(pred)+"\""+microdatares+"property=\"" + str(pred) + "\" "+rdfares+" target=\"_blank\" href=\"" + str(object) + "\">" + label + " <span style=\"color: #666;\">(" + res["uri"] + ")</span></a>"
else:
tablecontents += "<span><a property=\"" + str(pred) + "\" "+rdfares+" target=\"_blank\" href=\"" + str(object) + "\">" + label + "</a>"
tablecontents += "<span><a itemprop=\""+str(pred)+"\""+microdatares+"property=\"" + str(pred) + "\" "+rdfares+" target=\"_blank\" href=\"" + str(object) + "\">" + label + "</a>"
if bibtex!=None:
tablecontents+="<details><summary>[BIBTEX]</summary><pre>"+str(bibtex)+"</pre></details>"
if self.generatePagesForNonNS:
Expand Down Expand Up @@ -923,19 +925,19 @@ def createHTMLTableValueEntry(self,subject,pred,object,ttlf,graph,baseurl,checkd
if str(object.datatype) in DocConfig.timeliteraltypes and dateprops!=None and DocUtils.shortenURI(str(pred),True) not in DocConfig.metadatanamespaces and str(pred) not in dateprops:
dateprops.append(str(pred))
if res != None:
tablecontents += "<span property=\"" + str(pred) + "\" content=\"" + str(
tablecontents += "<span itemprop=\""+str(pred)+"\" property=\"" + str(pred) + "\" content=\"" + str(
object).replace("<", "&lt").replace(">", "&gt;").replace("\"", "'") + "\" datatype=\"" + str(
object.datatype) + "\">" + self.truncateValue(objstring) + " <small>(<a style=\"color: #666;\" target=\"_blank\" href=\"" + str(
object.datatype) + "\">" + res["uri"]+ "</a>)</small></span>"
else:
tablecontents += "<span property=\"" + str(pred) + "\" content=\"" + str(
tablecontents += "<span itemprop=\""+str(pred)+"\" property=\"" + str(pred) + "\" content=\"" + str(
object).replace("<", "&lt").replace(">", "&gt;").replace("\"", "'") + "\" datatype=\"" + str(
object.datatype) + "\">" + self.truncateValue(objstring) + " <small>(<a style=\"color: #666;\" target=\"_blank\" href=\"" + str(
object.datatype) + "\">" + DocUtils.shortenURI(str(object.datatype)) + "</a>)</small></span>"
geojsonrep=LiteralUtils.resolveGeoLiterals(URIRef(pred), object, graph, geojsonrep,nonns,subject)
else:
if object.language != None:
tablecontents += "<span property=\"" + str(pred) + "\" content=\"" + str(object).replace("<", "&lt").replace(">", "&gt;").replace("\"","'") + "\" datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString\" xml:lang=\"" + str(object.language) + "\">" + self.truncateValue(str(object).replace("<", "&lt").replace(">", "&gt;")) + " <small>(<a style=\"color: #666;\" target=\"_blank\" href=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString\">rdf:langString</a>) (<a href=\"http://www.lexvo.org/page/iso639-1/"+str(object.language)+"\" target=\"_blank\">iso6391:" + str(object.language) + "</a>)</small></span>"
tablecontents += "<span itemprop=\""+str(pred)+"\" property=\"" + str(pred) + "\" content=\"" + str(object).replace("<", "&lt").replace(">", "&gt;").replace("\"","'") + "\" datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString\" xml:lang=\"" + str(object.language) + "\">" + self.truncateValue(str(object).replace("<", "&lt").replace(">", "&gt;")) + " <small>(<a style=\"color: #666;\" target=\"_blank\" href=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString\">rdf:langString</a>) (<a href=\"http://www.lexvo.org/page/iso639-1/"+str(object.language)+"\" target=\"_blank\">iso6391:" + str(object.language) + "</a>)</small></span>"
else:
tablecontents += self.detectStringLiteralContent(pred,object)
return {"html":tablecontents,"geojson":geojsonrep,"foundmedia":foundmedia,"imageannos":imageannos,"textannos":textannos,"image3dannos":image3dannos,"annobodies":annobodies,"label":label,"timeobj":dateprops}
Expand All @@ -947,18 +949,18 @@ def truncateValue(self,value,limit=150):

def detectStringLiteralContent(self,pred,object):
if object.startswith("http://") or object.startswith("https://"):
return "<span><a property=\"" + str(pred) + "\" target=\"_blank\" href=\"" + str(
return "<span><a itemprop=\""+str(pred)+"\" property=\"" + str(pred) + "\" target=\"_blank\" href=\"" + str(
object)+ "\" datatype=\"http://www.w3.org/2001/XMLSchema#string\">" + str(object)+ "</a> <small>(<a style=\"color: #666;\" target=\"_blank\" href=\"http://www.w3.org/2001/XMLSchema#string\">xsd:string</a>)</small></span>"
elif object.startswith("www."):
return "<span><a property=\"" + str(pred) + "\" target=\"_blank\" href=\"http://" + str(
return "<span><a itemprop=\""+str(pred)+"\" property=\"" + str(pred) + "\" target=\"_blank\" href=\"http://" + str(
object) + "\" datatype=\"http://www.w3.org/2001/XMLSchema#string\">http://" + str(
object) + "</a> <small>(<a style=\"color: #666;\" target=\"_blank\" href=\"http://www.w3.org/2001/XMLSchema#string\">xsd:string</a>)</small></span>"
elif re.search(r'(10[.][0-9]{2,}(?:[.][0-9]+)*/(?:(?![%"#? ])\\S)+)',str(object)):
return "<span><a property=\"" + str(pred) + "\" href=\"https://www.doi.org/" + str(
return "<span><a itemprop=\""+str(pred)+"\" property=\"" + str(pred) + "\" href=\"https://www.doi.org/" + str(
object) + "\" datatype=\"http://www.w3.org/2001/XMLSchema#anyURI\">" + str(
object) + "</a> <small>(<a style=\"color: #666;\" target=\"_blank\" href=\"http://www.w3.org/2001/XMLSchema#anyURI\">xsd:anyURI</a>)</small></span>"
elif re.search(r'[\w.]+\@[\w.]+', object):
return "<span><a property=\"" + str(pred) + "\" href=\"mailto:" + str(
return "<span><a itemprop=\""+str(pred)+"\" property=\"" + str(pred) + "\" href=\"mailto:" + str(
object) + "\" datatype=\"http://www.w3.org/2001/XMLSchema#string\">mailto:" + str(
object) + "</a> <small>(<a style=\"color: #666;\" target=\"_blank\" href=\"http://www.w3.org/2001/XMLSchema#string\">xsd:string</a>)</small></span>"
return "<span property=\"" + str(pred) + "\" content=\"" + str(object).replace("<","&lt").replace(">","&gt;").replace("\"","'") + "\" datatype=\"http://www.w3.org/2001/XMLSchema#string\">" + str(object).replace("<","&lt").replace(">","&gt;") + " <small>(<a style=\"color: #666;\" target=\"_blank\" href=\"http://www.w3.org/2001/XMLSchema#string\">xsd:string</a>)</small></span>"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<html about="{{subject}}"><head><title>{{toptitle}}</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<html about="{{subject}}" itemscope itemid="{{subject}}" id="subject"><head><title>{{toptitle}}</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css" />
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
Expand Down
12 changes: 12 additions & 0 deletions src/sparqlunicorn_ontdoc/resources/prefixes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,27 @@
"nstolabel": {
"http://babelnet.org/2.0/": "Babelnet 2.0",
"http://babelnet.org/rdf/": "Babelnet RDF",
"http://purl.org/ontology/af/": "Audio Features Ontology",
"http://xmlns.com/foaf/0.1/": "Friend Of A Friend Ontology",
"http://purl.org/cerif/frapo/":"Funding, Research Administration and Projects Ontology",
"http://www.opengis.net/ont/geosparql#": "The GeoSPARQL Ontology",
"http://purl.org/dpn#":"Data Provider Node ontology",
"http://purl.org/foodontology#": "The FoodOntology Vocabulary for Food Products Description",
"http://purl.org/olia/olia.owl#": "Ontologies of Linguistic Annotation",
"http://viaf.org/ontology/1.1/": "Virtual International Authority File (VIAF) Ontology",
"http://www.w3.org/TR/owl-time#": "OWL Time Ontology",
"http://rdfs.org/scot/ns#": "SCOT (Social Semantic Cloud of Tags) Ontology",
"http://rdfs.co/juso/": "Juso Ontology",
"http://www.opengis.net/kml/2.2#": "Keyhole Markup Language (KML)",
"http://rdfs.co/bevon/": "BEVON: Beverage Ontology",
"http://www.w3.org/ns/lemon/lime#": "Linguistic Metadata Ontology",
"http://www.w3.org/ns/lemon/ontolex#": "Lexicon Model For Ontologies",
"http://www.w3.org/ns/lemon/vartrans#": "Ontolex Variation and Translation Module",
"http://www.w3.org/ns/sosa/":"Sensor, Observation, Sample, and Actuator (SOSA) Ontology",
"http://www.w3.org/2002/07/owl#": "Web Ontology Language 2 Vocabulary",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#": "The RDF Concepts Vocabulary (RDF)",
"http://www.w3.org/2000/01/rdf-schema#": "The RDF Schema vocabulary (RDFS)",
"http://www.w3.org/2003/01/geo/wgs84_pos#": "W3C Geo Vocabulary",
"http://www.wikidata.org/entity/": "Wikidata Entities",
"http://www.ontology-of-units-of-measure.org/resource/om-2/": "Ontology of Units of Measurement",
"http://pleiades.stoa.org/places/": "Pleiades Places",
Expand All @@ -20,6 +31,7 @@
"http://www.w3.org/ns/dcat#": "DCAT Vocabulary",
"http://www.w3.org/2003/12/exif/ns#": "EXIF data description vocabulary",
"http://rdfs.org/ns/void#": "Vocabulary of Interlinked Datasets (VoID)",
"http://rdfs.org/ns/void-ext#":"Extensions to the Vocabulary of Interlinked Datasets (VoID-EXT)"
"http://schema.org/": "Schema.org vocabulary",
"https://www.geonames.org/": "GeoNames Ontology",
"http://www.geonames.org/ontology#": "GeoNames Ontology",
Expand Down

0 comments on commit ba513e5

Please sign in to comment.