Skip to content

Instantly share code, notes, and snippets.

@cmackenzie1
Created December 13, 2016 02:12
Show Gist options
  • Save cmackenzie1/65766eb749ed50c8e2e31f5f054d94ee to your computer and use it in GitHub Desktop.
Save cmackenzie1/65766eb749ed50c8e2e31f5f054d94ee to your computer and use it in GitHub Desktop.
cmput391-a3 output
cdmacken@ohaton:~/cmput391-a3>cat test.txt
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX schema: <http://schema.org/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?city WHERE {
?aaa ?bbb ?city .
filter (regex(?city, "Canada")).
}
cdmacken@ohaton:~/cmput391-a3>python3 q9.py dbname.db test.txt
SELECT t0.subject, t0.object FROM triples t0 WHERE t0.predicate = t0.predicate AND t0.object = t0.object AND t0.subject = t0.subject AND t0.object LIKE '%Canada%'
Result: http://dbpedia.org/resource/Edmonton with object value of: http://dbpedia.org/resource/List_of_House_members_of_the_42nd_Parliament_of_Canada
Result: http://dbpedia.org/resource/Edmonton with object value of: Canada's Festival City, City of Champions, The Oil Capital of Canada (more...)@en
Result: http://dbpedia.org/resource/Edmonton with object value of: http://dbpedia.org/resource/List_of_T_postal_codes_of_Canada
Result: http://dbpedia.org/resource/Edmonton with object value of: http://dbpedia.org/resource/Canada
Result: http://dbpedia.org/resource/Edmonton with object value of: Canada's Festival City, City of Champions, The Oil Capital of Canada (more...)@en
Result: http://dbpedia.org/resource/Edmonton with object value of: http://dbpedia.org/resource/Canada
cdmacken@ohaton:~/cmput391-a3>cat test2.txt
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX schema: <http://schema.org/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?city WHERE {
?aaa ?bbb ?city .
filter (?city > 10253).
}
cdmacken@ohaton:~/cmput391-a3>python3 q9.py dbname.db test2.txt
SELECT t0.subject, t0.object FROM triples t0 WHERE t0.predicate = t0.predicate AND t0.object = t0.object AND t0.subject = t0.subject AND CAST(t0.object AS REAL) > 10253 AND t0.float = 1 OR t0.integer = 1
Result: http://dbpedia.org/resource/Edmonton with object value of: 95405
Result: http://dbpedia.org/resource/Edmonton with object value of: 707172541
Result: http://dbpedia.org/resource/Edmonton with object value of: 780587
Result: http://dbpedia.org/resource/Edmonton with object value of: 645
Result: http://dbpedia.org/resource/Edmonton with object value of: 123
Result: http://dbpedia.org/resource/Edmonton with object value of: 1159869
Result: http://dbpedia.org/resource/Edmonton with object value of: 812201
Result: http://dbpedia.org/resource/Edmonton with object value of: 960015
Result: http://dbpedia.org/resource/Edmonton with object value of: 11
Result: http://dbpedia.org/resource/Edmonton with object value of: 9426730000.0
Result: http://dbpedia.org/resource/Edmonton with object value of: 684370000.0
Result: http://dbpedia.org/resource/Edmonton with object value of: 1159869
Result: http://dbpedia.org/resource/Edmonton with object value of: 812201
Result: http://dbpedia.org/resource/Edmonton with object value of: 960015
cdmacken@ohaton:~/cmput391-a3>cat test_a3.txt
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX schema: <http://schema.org/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT * WHERE {
?city rdf:type schema:City .
?city dbo:country dbr:Canada .
}
cdmacken@ohaton:~/cmput391-a3>python3 q9.py dbname.db test_a3.txt
SELECT t0.subject, t0.object FROM triples t0 , triples t1 WHERE t0.predicate = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' AND t0.object = 'http://schema.org/City' AND t1.predicate = 'http://dbpedia.org/ontology/country' AND t1.object = 'http://dbpedia.org/resource/Canada' AND t0.subject = t0.subject AND t1.subject = t0.subject
Result: http://dbpedia.org/resource/Edmonton with object value of: http://schema.org/City
cdmacken@ohaton:~/cmput391-a3>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment