Skip to content

Commit

Permalink
second geosparql 1.1 upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ghobona committed Dec 6, 2023
1 parent 4d652e9 commit b44e975
Show file tree
Hide file tree
Showing 30 changed files with 37,333 additions and 0 deletions.
6,284 changes: 6,284 additions & 0 deletions incubation/geosparql/20231206_delete_geosparqlfiles.nt

Large diffs are not rendered by default.

7,678 changes: 7,678 additions & 0 deletions incubation/geosparql/20231206_insert_geosparqlfiles.nt

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions incubation/geosparql/second_attempt/merge_def_ttl_files_to_add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import os, re
import rdflib
from rdflib.namespace import DC, DCTERMS, DOAP, FOAF, SKOS, OWL, RDF, RDFS, VOID, XMLNS, XSD


path = "/Users/ogckm/Documents/GitHub/NamingAuthority/incubation/geosparql/second_attempt/triples_to_add"

g = rdflib.Graph()

for dirpath, subdirs, files in os.walk(path):
for name in files:
if name.endswith(".ttl"):
print(os.path.join(dirpath, name))
g.parse(os.path.join(dirpath, name))


g.serialize(destination="/Users/ogckm/Documents/GitHub/NamingAuthority/incubation/geosparql/20231206_insert_geosparqlfiles.nt",format="nt")

'''
The code below is not used because it is incomplete.
g1 = rdflib.Graph()
g1.parse("file:///Users/ogckm/Documents/GitHub/NamingAuthority/incubation/geosparql/20231206_insert_geosparqlfiles.nt")
knows_query = """
SELECT DISTINCT ?subject {
?subject ?predicate ?object
FILTER (isURI(?subject) && STRSTARTS(str(?subject), str('http://www.opengis.net/def/') ) )
}"""
all_def_uris = []
qres = g1.query(knows_query)
for row in qres:
all_def_uris.append(f"{row.subject}")
fout2 = open('/Users/ogckm/Documents/GitHub/NamingAuthority/incubation/geosparql/20231206_insert_geosparqlfiles_step2_not_uploaded.nt','w')
for subject in all_def_uris:
is_concept = False
triple_to_check = "<"+subject+"> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept>."
qres = g1.query("ASK {"+triple_to_check+"}")
for row in qres:
if str(row) == 'False':
print(subject + " NOT Concept" + str(row))
else:
is_concept = True
if is_concept == False:
triple_to_check = "<"+subject+"> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#ConceptScheme>."
qres = g1.query("ASK {"+triple_to_check+"}")
for row in qres:
if str(row) == 'False':
if is_concept is False:
print(subject + " NOT ConceptScheme" + str(row))
fout2.write(triple_to_check+"\n")
fout2.close()
'''

'''
legacy instructions - no longer necessary
FIRST START FUSEKI
/Users/ogckm/Tools/apache-jena-fuseki-4.5.0/fuseki-server --file "/Users/ogckm/Downloads/20231206_insert_geosparqlfiles.nt" /geosparql
THEN EXPORT ALL definition triples to all_defs_queryResults.ttl with this:
CONSTRUCT {?subject ?predicate ?object} WHERE {
?subject ?predicate ?object
FILTER (isURI(?subject) && STRSTARTS(str(?subject), str('http://www.opengis.net/def/') ) )
}
Then export distinct def URIs to distinct_def_uris.csv with this:
SELECT DISTINCT ?subject {
?subject ?predicate ?object
FILTER (isURI(?subject) && STRSTARTS(str(?subject), str('http://www.opengis.net/def/') ) )
}
'''

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os, re
import rdflib
from rdflib.namespace import DC, DCTERMS, DOAP, FOAF, SKOS, OWL, RDF, RDFS, VOID, XMLNS, XSD


folderpath = "/Users/gobehobona/Documents/GitHub/NamingAuthority/incubation/geosparql/second_attempt/triples_to_clear"

g = rdflib.Graph()

for root, dirs, files in os.walk(folderpath):
print (root, "consumes")
for name in files:
print(name)
print(folderpath+"/"+name)
g.parse(folderpath+"/"+name)
print(len(g))

g.serialize(destination="/Users/gobehobona/Documents/GitHub/NamingAuthority/incubation/geosparql/geosparqlfiles2.nt",format="nt")



fin = open("/Users/gobehobona/Documents/GitHub/NamingAuthority/incubation/geosparql/geosparqlfiles2.nt",'r')
lines = fin.readlines()

fout = open("/Users/gobehobona/Documents/GitHub/NamingAuthority/incubation/geosparql/20231206_delete_geosparqlfiles.nt",'w')


for line in lines:
if "_:" in line:
print("do nothing")
else:
fout.write(line);

fout.close()

'''
FIRST START FUSEKI
/Users/ogckm/Tools/apache-jena-fuseki-4.5.0/fuseki-server --file "/Users/ogckm/Downloads/geosparqlfiles.ttl" /geosparql
THEN EXPORT ALL definition triples to all_defs_queryResults.ttl with this:
CONSTRUCT {?subject ?predicate ?object} WHERE {
?subject ?predicate ?object
FILTER (isURI(?subject) && STRSTARTS(str(?subject), str('http://www.opengis.net/def/') ) )
}
Then export distinct def URIs to distinct_def_uris.csv with this:
SELECT DISTINCT ?subject {
?subject ?predicate ?object
FILTER (isURI(?subject) && STRSTARTS(str(?subject), str('http://www.opengis.net/def/') ) )
}
'''

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@techreport{perry2012ogc,
type = {{OGC} {Implementation} {Standard}},
title = {{OGC} {GeoSPARQL} - {A} {Geographic} {Query} {Language} for {RDF} {Data}},
url = {http://www.opengis.net/doc/IS/geosparql/1.0},
number = {OGC 11-052r4},
institution = {Open Geospatial Consortium},
author = {{Matthew Perry} and {John Herring}},
month = sep,
year = {2012},
version = {1.0},
}
Loading

0 comments on commit b44e975

Please sign in to comment.