-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtester.py
63 lines (42 loc) · 1.37 KB
/
tester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
__author__ = 'Pedro Sernadela sernadela@ua.pt'
import scaleus
s = scaleus.Scaleus('http://localhost/api/v1/')
## Datasets
print '\nDatasets:\n'
dataset = 'tester'
s.add_dataset(dataset)
print s.get_datasets()
s.remove_dataset(dataset)
print s.get_datasets()
## Triples
print '\nTriples:\n'
dataset = 'default'
sub = 'http://bioinformatics.ua.pt/'
pred = 'http://purl.org/dc/elements/1.1/title'
obj = 'Bioinformatics UA'
s.add_triple(dataset, sub, pred, obj)
s.remove_triple(dataset, sub, pred, obj)
## Namespaces
print '\nNamespaces:\n'
dataset = 'default'
prefix = 'bio'
namespace = 'http://bioinformatics.ua.pt/'
print s.get_namespaces(dataset)
s.add_namespace(dataset, prefix, namespace)
print s.get_namespaces(dataset)
s.remove_namespace(dataset, prefix)
print s.get_namespaces(dataset)
## SPARQL
print '\nSPARQL:\n'
dataset = 'default'
query = 'SELECT * { ?s ?p ?o } LIMIT 100'
inference = 'true'
rules = '[rule1: (?a ?p ?b), (?p rdfs:subPropertyOf ?q) -> (?a ?q ?b)]' + '[rule2: (?x rdfs:subClassOf ?y), (?a rdf:type ?x) -> (?a rdf:type ?y)]'
format = 'json'
print s.sparql(dataset, query, inference, rules, format)
## Data
print '\nData:\n'
dataset = 'default'
ttl_data = '@prefix bio: <http://bioinformatics.ua.pt/> . @prefix dc: <http://purl.org/dc/elements/1.1/> . bio:ieeta dc:title "Bioinformatics UA" .'
s.replace_data(dataset, ttl_data)
print s.get_data(dataset)