Ejemplo n.º 1
0
#Importing Modules
import rdflib
from rdflib.graph import Graph, URIRef
import matplotlib.pyplot as plt
import gzip
#Loading and Serilizin Combined Dataset
from gastrodon import LocalEndpoint, one, QName
#g = rdflib.ConjunctiveGraph()
g = Graph()
#g.parse("C:/publish/RDF/OWL.ttl",format="ttl")
g.parse("C:/publish/RDF/WSP1WS8.ttl", format="ttl")
len(g)
e = LocalEndpoint(g)
#qUERY formulation
properties1 = e.select("""
SELECT ?o ?o1 ?o2
WHERE { 
?s <http://www.semanticweb.org/yawfrimpong/ontologies/untitled-ontology-13#FoundOn>  ?o .
?s <http://www.semanticweb.org/yawfrimpong/ontologies/untitled-ontology-13#HasLat> ?o1 .
?s <http://www.semanticweb.org/yawfrimpong/ontologies/untitled-ontology-13#HasLong> ?o2 . 
  }
    """)
properties1
#Saving and Printing Result
print(properties1)
Ejemplo n.º 2
0
import numpy as np

np.random.seed(5)
from nltk.corpus import wordnet
import rdflib
from rdflib.graph import *
from gastrodon import LocalEndpoint, one, QName

Ont = Graph()
Ont.parse("C:/publish/RDF/OWL.ttl", format="ttl")
OpenOnto = open("OntClasses.txt", "w")
len(Ont)
e = LocalEndpoint(Ont)

Classes = e.select("""
SELECT  ?s
WHERE
{
?s ?p ?o .
}
""")

print(Classes)

pit = "Desert"
p = "Mangrove", "adaptation", "Biome", "Desert", "Community", "Conservation", "habitat", "Species", "City", "Population", "Taxon", "Nomenclature", "Landscape", "Extinction", "Diversity", "Ecology", "Environment", "Watershed", "Seagrass", "Assemblage"


def WordsMeanng(c):
    for a in c:
        i = str(a)
Ejemplo n.º 3
0
import rdflib
from rdflib.graph import Graph, URIRef
import matplotlib.pyplot as plt
import gzip
import numpy as np
import pandas as pd
from gastrodon import LocalEndpoint, one, QName

#g = rdflib.ConjunctiveGraph()
g = Graph()

g.parse("C:/publish/RDF/OWL.ttl", format="ttl")
len(g)

e = LocalEndpoint(g)
properties1 = e.select("""

SELECT ?o ?o2
 {
        ?s <http://www.semanticweb.org/yawfrimpong/ontologies/\
        untitled-ontology-13#FeedOn> "GrassLand" . 
        ?s <http://www.semanticweb.org/yawfrimpong/ontologies/\
        untitled-ontology-13#HasLat> ?o . 
        ?s <http://www.semanticweb.org/yawfrimpong/ontologies/\
        untitled-ontology-13#FoundIn> "San Francisco" .
        ?s <http://www.semanticweb.org/yawfrimpong/ontologies/\
        untitled-ontology-13#HasName> "Owl" .
          }  """)
properties1
file = open("GrassLand.txt", "w")
data = properties1.values
Ejemplo n.º 4
0
import rdflib
from rdflib.graph import Graph, URIRef
import matplotlib.pyplot as plt
import gzip
NewText = open("M.txt", "w")
from gastrodon import LocalEndpoint,one,QName

#g = rdflib.ConjunctiveGraph()
g = Graph()

g.parse("C:/publish/Ontology.ttl",format="ttl")
len(g)

e=LocalEndpoint(g)


Q1=e.select("""

SELECT ?p
WHERE
{
?s ?p ?o .
}
""")

Q1
print(Q1)
a =str(Q1)
NewText.write(a)
Ejemplo n.º 5
0
np.random.seed(5)
from nltk.corpus import wordnet
g = Graph()


g.parse("Ont.owl", format="ttl")

#print(len(g))

m = open("Paul.txt", "w")

pd.DataFrame()
#for a, b, c, in g:
 #   m.write(a)

e=LocalEndpoint(g)

qres = e.select(
    """
    SELECT  ?s
       WHERE {
          ?s ?p ?o .
       }""")
#print(qres)
df = pd.DataFrame(qres)
random.randrange(20)
#b = random.sample((list(df.iloc[:],20)))
c = df.iloc[:19,-1]
#a = df.iloc[np.random.choice((df.iloc[:],21)),-1]
fit = open("WordMeaning.txt","r+")
#for i in fit:
Ejemplo n.º 6
0
import rdflib
from rdflib.graph import Graph, URIRef
import matplotlib.pyplot as plt
import gzip
NewText = open("M.txt", "w")
from gastrodon import LocalEndpoint,one,QName

#g = rdflib.ConjunctiveGraph()
g = Graph()

g.parse("C:/publish/RDF/Birds.ttl",format="ttl")
len(g)

e=LocalEndpoint(g)


Q1=e.select("""

SELECT (Distinct ?o as ?Land_Information)
WHERE
{
?s ?p "San Francisco" .
?s <http://www.semanticweb.org/yawfrimpong/ontologies/untitled-ontology-13#FoundOn> ?o .
}
""")

Q1
print(Q1)
a =str(Q1)
NewText.write(a)
Ejemplo n.º 7
0
import rdflib
from rdflib.graph import Graph, URIRef
import matplotlib.pyplot as plt
import gzip

NewText = open("M.txt", "w")

from gastrodon import LocalEndpoint, one, QName

#g = rdflib.ConjunctiveGraph()
g = Graph()

g.parse("C:/publish/RDF/WSP1WS8.ttl", format="ttl")
len(g)

e = LocalEndpoint(g)

properties1 = e.select("""



select ?o as ?Land_Information 
WHERE {
      ?s ?p ?o .
      FILTER(STRSTARTS(STR(?p),"http://www.semanticweb.org/yawfrimpong/ontologies/untitled-ontology-13#FoundOn"))
   } """)

properties1

print(properties1)
f_dbp_onto = input_path + "DBpedia ontology 2016/" + "dbpedia_2016-10.nt"
f_dbp_people = input_path + "DBpedia_people/DBpedia_people_no-semantics/" + "goldStandard_dbp_cleaned.nt"
f_disease = input_path + "Diseases/no-semantics/" + "goldStandard_diseases.nt"

dbpedia_ontology = Graph()
dbpedia_ontology.parse(f_dbp_onto, format="nt")
dbpedia_People = Graph()
dbpedia_People.parse(f_dbp_people, format="nt")
disease_ICD = Graph()
disease_ICD.parse(f_disease, format="nt")

print(len(dbpedia_ontology))
print(len(dbpedia_People))
print(len(disease_ICD))

dbp_p = LocalEndpoint(dbpedia_People)
drug = LocalEndpoint(disease_ICD)
dbp_onto = LocalEndpoint(dbpedia_ontology)

subject = dbp_p.select("""
   SELECT ?s (COUNT(*) AS ?count) {
      ?s ?p ?o .
      
   } GROUP BY ?s ORDER BY DESC(?count)
""")

properties = dbp_p.select("""
   SELECT ?p (COUNT(*) AS ?count) {
      ?s ?p ?o .
      
   } GROUP BY ?p ORDER BY DESC(?count)
Ejemplo n.º 9
0
import rdflib
from rdflib.graph import Graph, URIRef
import matplotlib.pyplot as plt
import gzip

NewText = open("M.txt", "w")

from gastrodon import LocalEndpoint, one, QName

#g = rdflib.ConjunctiveGraph()
g = Graph()

g.parse("C:/publish/RDF/WSP1WS8.ttl", format="ttl")
len(g)

e = LocalEndpoint(g)

properties1 = e.select("""
select DISTINCT ?o 
WHERE {

      ?s "<http://www.semanticweb.org/yawfrimpong/ontologies/untitled-ontology-13#FoundIn>" ?o .
     
   } """)

properties1

print(properties1)

#print(g.serialize(destination='D:/git/silk/data/staat.rdf',format="application/rdf+xml"))
'''
Ejemplo n.º 10
0
# in the next step.
g = Graph()

# Walks through output path from the netowlCurl function and parses all RDF/XML Documents
for root, dir, files in os.walk(rdfOutDir):
    for file in files:
        if file.endswith(rdfOutExt):
            filePath = os.path.join(root, file)
            print("Parsing " + file + "...")
            try:
                g.parse(filePath, format='xml')
            except Exception as ex:
                print(ex)

# Create Local SPARQL Endpoint on graph created in previous step
e = LocalEndpoint(g)

#Queries the SPARQL endpoint for the various addresses located in the documents
address=e.select("""
   SELECT ?s ?o ?label{
      ?s netowl:Entity.Address.Mail..name ?o .
      ?s rdfs:label ?label .
    }
""")
address.set_index("label")

#Geocodes the addresses and adds them to the map widget as a feature collection
locations = gis.content.import_data(address, {"Address" : "label"})

#Creates a hosted feature service from the feature
# collection created in the previous step
Ejemplo n.º 11
0
import rdflib
from rdflib.graph import Graph, URIRef
import matplotlib.pyplot as plt
import gzip

NewText = open("M.txt", "w")

from gastrodon import LocalEndpoint, one, QName

#g = rdflib.ConjunctiveGraph()
g = Graph()

g.parse("C:/publish/RDF/WSP1WS8.ttl", format="ttl")
len(g)

e = LocalEndpoint(g)

properties1 = e.select("""

SELECT ?o
 {
      ?s '<http://www.semanticweb.org/yawfrimpong/ontologies/untitled-ontology-13#FoundIn>' ?o .
   } 
    """)

properties1

print(properties1)

#print(g.serialize(destination='D:/git/silk/data/staat.rdf',format="application/rdf+xml"))
'''
Ejemplo n.º 12
0
import rdflib
from rdflib.graph import Graph, URIRef
import matplotlib.pyplot as plt
import gzip

NewText = open("M.txt", "w")

from gastrodon import LocalEndpoint, one, QName

#g = rdflib.ConjunctiveGraph()
g = Graph()

g.parse("C:/publish/RDF/WSP1WS8.ttl", format="ttl")
len(g)

e = LocalEndpoint(g)

Q1 = e.select("""

SELECT ?o (COUNT(?o) as ?oCount)
WHERE
{
  ?s <http://www.semanticweb.org/yawfrimpong/ontologies/untitled-ontology-13#FoundIn> ?o .
}
GROUP BY ?p
'ORDER BY DESC(?oCount)'
Limit 1
    """)

Q1
print(Q1)
	
	#Importing Modules
	import rdflib
	from rdflib.graph import Graph, URIRef
	import matplotlib.pyplot as plt
	import gzip
	#Loading the Combined Dataset
	from gastrodon import LocalEndpoint,one,QName
	#g = rdflib.ConjunctiveGraph()
	g = Graph()
	#g.parse("C:/publish/RDF/OWL.ttl",format="ttl")
	g.parse("C:/publish/RDF/WSP1WS8.ttl",format="ttl")
	len(g)
	e=LocalEndpoint(g)
	#Query formulation
	properties1=e.select("""
	SELECT ?o ?o1 ?o2
	WHERE { 
	?s <http://www.semanticweb.org/
	\yawfrimpong/ontologies/untitled-ontology-13#FoundOn>  ?o .
	?s <http://www.semanticweb.org/yawfrimpong/ontologies\
	/untitled-ontology-13#HasLat> ?o1 .
	?s <http://www.semanticweb.org/yawfrimpong/ontologies\
	/untitled-ontology-13#HasLong> ?o2 . 
	?s <http://www.semanticweb.org/yawfrimpong/ontologies\
	/untitled-ontology-13#HasLong> "San Francisco" . 
	?s <http://www.semanticweb.org/yawfrimpong/ontologies\
	/untitled-ontology-13FeedOn#> "Forest" . 
	 }
		""")
	properties1
Ejemplo n.º 14
0
import rdflib
from rdflib.graph import Graph, URIRef
import matplotlib.pyplot as plt
import gzip
from gastrodon import LocalEndpoint, one, QName

#g = rdflib.ConjunctiveGraph()
g = Graph()

g.parse("WSP1WS718295.ttl", format="n3")
len(g)
print(len(g))

e = LocalEndpoint(g)

properties1 = e.select("""
   SELECT *
      
""")
properties1
print(properties1)

print(e.namespaces())