コード例 #1
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def testFOAFminprops(self):
   """Check we found at least 50 FOAF properties."""
   foaf_spec = Vocab('examples/foaf/','index-20081211.rdf')
   foaf_spec.index()
   foaf_spec.uri = str(FOAF)
   c = len(foaf_spec.properties)
   self.failUnless(c > 50 , "FOAF has more than 50 properties. count: "+str(c))
コード例 #2
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def testSIOCminprops(self):
   """Check we found at least 20 SIOC properties (which means matching OWL properties)"""
   sioc_spec = Vocab('examples/sioc/','sioc.rdf')
   sioc_spec.index()
   sioc_spec.uri = str(SIOC)
   c = len(sioc_spec.properties)
   self.failUnless(c > 20 , "SIOC has more than 20 properties. count was "+str(c))
コード例 #3
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def testCanUseNonStrURI(self):
   """If some fancy object used with a string-oriented setter, we just take the string."""
   doap_spec = Vocab('examples/doap/','doap-en.rdf')
   print "[1]"
   doap_spec.index()
   doap_spec.uri = Namespace('http://usefulinc.com/ns/doap#')  # likely a common mistake
   self.assertEqual(doap_spec.uri, 'http://usefulinc.com/ns/doap#')
コード例 #4
0
 def testSIOCminprops(self):
     """Check we found at least 20 SIOC properties (which means matching OWL properties)"""
     sioc_spec = Vocab('examples/sioc/', 'sioc.rdf')
     sioc_spec.index()
     sioc_spec.uri = str(SIOC)
     c = len(sioc_spec.properties)
     self.failUnless(
         c > 20, "SIOC has more than 20 properties. count was " + str(c))
コード例 #5
0
 def testCanUseNonStrURI(self):
     """If some fancy object used with a string-oriented setter, we just take the string."""
     doap_spec = Vocab('examples/doap/', 'doap-en.rdf')
     print("[1]")
     doap_spec.index()
     doap_spec.uri = Namespace(
         'http://usefulinc.com/ns/doap#')  # likely a common mistake
     self.assertEqual(doap_spec.uri, 'http://usefulinc.com/ns/doap#')
コード例 #6
0
 def testFOAFminprops(self):
     """Check we found at least 50 FOAF properties."""
     foaf_spec = Vocab('examples/foaf/', 'index-20081211.rdf')
     foaf_spec.index()
     foaf_spec.uri = str(FOAF)
     c = len(foaf_spec.properties)
     self.failUnless(c > 50,
                     "FOAF has more than 50 properties. count: " + str(c))
コード例 #7
0
 def testFOAFusingDCasExternal(self):
     """FOAF using external vocabs"""
     foaf_spec = Vocab(dir=FOAFSNAPSHOTDIR, f=FOAFSNAPSHOT)
     foaf_spec.index()
     foaf_spec.uri = str(FOAF)
     for t in foaf_spec.terms:
         # print "is term "+t+" external? ", t.is_external(foaf_spec)
         ''
コード例 #8
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def testFOAFusingDCasExternal(self):
   """FOAF using external vocabs"""
   foaf_spec = Vocab(dir=FOAFSNAPSHOTDIR, f=FOAFSNAPSHOT)
   foaf_spec.index()
   foaf_spec.uri = str(FOAF)
   for t in foaf_spec.terms:
     # print "is term "+t+" external? ", t.is_external(foaf_spec)
     ''
コード例 #9
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def testSIOCmaxprops(self):
   """sioc max props: not more than 500 properties in SIOC"""
   sioc_spec = Vocab(dir='examples/sioc/',f='sioc.rdf')
   sioc_spec.index()
   sioc_spec.uri = str(SIOC)
   c = len(sioc_spec.properties)
   #print "SIOC property count: ",c
   self.failUnless(c < 500 , "SIOC has less than 500 properties. count was "+str(c))
コード例 #10
0
 def testSIOCmaxprops(self):
     """sioc max props: not more than 500 properties in SIOC"""
     sioc_spec = Vocab(dir='examples/sioc/', f='sioc.rdf')
     sioc_spec.index()
     sioc_spec.uri = str(SIOC)
     c = len(sioc_spec.properties)
     #print "SIOC property count: ",c
     self.failUnless(
         c < 500, "SIOC has less than 500 properties. count was " + str(c))
コード例 #11
0
 def testDOAPusingFOAFasExternal(self):
     """when DOAP mentions a FOAF class, the API should let us know it is external"""
     doap_spec = Vocab(dir='examples/doap/', f='doap.rdf')
     doap_spec.index()
     doap_spec.uri = str(DOAP)
     for t in doap_spec.classes:
         #      print "is class "+t+" external? "
         #      print t.is_external(doap_spec)
         ''
コード例 #12
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
  def testDOAPusingFOAFasExternal(self):
    """when DOAP mentions a FOAF class, the API should let us know it is external"""
    doap_spec = Vocab(dir='examples/doap/',f='doap.rdf')
    doap_spec.index()
    doap_spec.uri = str(DOAP)
    for t in doap_spec.classes:
#      print "is class "+t+" external? "
#      print t.is_external(doap_spec)
      ''
コード例 #13
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def test_getset_uri(self):
   """getting and setting a Vocab uri property"""
   foaf_spec = Vocab(FOAFSNAPSHOTDIR,FOAFSNAPSHOT,uri='http://xmlns.com/foaf/0.1/')
   foaf_spec.index()
   u = 'http://foaf.tv/example#'
   # print "a) foaf_spec.uri is: ", foaf_spec.uri 
   foaf_spec.uri = u
   # print "b) foaf_spec.uri is: ", foaf_spec.uri 
   # print
   self.failUnless( foaf_spec.uri == u, "Failed to change uri.")
コード例 #14
0
 def test_getset_uri(self):
     """getting and setting a Vocab uri property"""
     foaf_spec = Vocab(FOAFSNAPSHOTDIR,
                       FOAFSNAPSHOT,
                       uri='http://xmlns.com/foaf/0.1/')
     foaf_spec.index()
     u = 'http://foaf.tv/example#'
     # print "a) foaf_spec.uri is: ", foaf_spec.uri
     foaf_spec.uri = u
     # print "b) foaf_spec.uri is: ", foaf_spec.uri
     # print
     self.failUnless(foaf_spec.uri == u, "Failed to change uri.")
コード例 #15
0
ファイル: specgen5.py プロジェクト: foaf/foaftown
def makeSpec(indir, uri, shortName,outdir,outfile, template, templatedir,indexrdfdir):
  spec = Vocab( indexrdfdir, 'index.rdf')
  spec.uri = uri
  spec.addShortName(shortName)
  spec.index() # slurp info from sources

  out = VocabReport( spec, indir, template, templatedir ) 

  filename = os.path.join(outdir, outfile)
  print "Printing to ",filename

  f = open(filename,"w")
  result = out.generate()
  f.write(result)
コード例 #16
0
ファイル: specgen7.py プロジェクト: jasonzou/spengen7
def makeSpec(indir, uri, shortName, outdir, outfile, template, templatedir,
             indexrdfdir):
    spec = Vocab(indexrdfdir, 'index.rdf')
    spec.uri = uri
    spec.addShortName(shortName)
    spec.index()  # slurp info from sources

    out = VocabReport(spec, indir, template, templatedir)

    filename = os.path.join(outdir, outfile)
    print("Printing to ", filename)

    f = open(filename, "w")
    result = out.generate()
    f.write(result)
コード例 #17
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def testFOAFns(self):
   foaf_spec = Vocab(FOAFSNAPSHOTDIR,FOAFSNAPSHOT)
   foaf_spec.index()
   foaf_spec.uri = FOAF
   # print "FOAF should be "+FOAF
   self.assertEqual(str(foaf_spec.uri), 'http://xmlns.com/foaf/0.1/')
コード例 #18
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def testSIOCns(self):
   sioc_spec = Vocab('examples/sioc/','sioc.rdf')
   sioc_spec.index()
   sioc_spec.uri = str(SIOC)
   self.assertEqual(sioc_spec.uri, 'http://rdfs.org/sioc/ns#')
コード例 #19
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def testDOAPWrongns(self):
   doap_spec = Vocab('examples/doap/','doap-en.rdf')
   doap_spec.index()
   doap_spec.uri = str(DOAP)
   self.assertNotEqual(doap_spec.uri, 'http://example.com/DELIBERATE_MISTAKE_HERE')
コード例 #20
0
ファイル: run_tests.py プロジェクト: foaf/foaftown
 def testDOAPns(self):
   doap_spec = Vocab('examples/doap/','doap-en.rdf')
   doap_spec.index()
   doap_spec.uri = str(DOAP)
   self.assertEqual(doap_spec.uri, 'http://usefulinc.com/ns/doap#')
コード例 #21
0
 def testDOAPns(self):
     doap_spec = Vocab('examples/doap/', 'doap-en.rdf')
     doap_spec.index()
     doap_spec.uri = str(DOAP)
     self.assertEqual(doap_spec.uri, 'http://usefulinc.com/ns/doap#')
コード例 #22
0
ファイル: query_test.py プロジェクト: jasonzou/spengen7
from rdflib.Graph import Graph
from rdflib.Graph import ConjunctiveGraph
from rdflib.sparql.sparqlGraph import SPARQLGraph
from rdflib.sparql.graphPattern import GraphPattern
from rdflib.sparql.bison import Parse
from rdflib.sparql import Query

# Test a SPARQL query against RDF data input
#

fn = 'examples/sioc/sioc.rdf'
#fn = 'examples/foaf/index.rdf'
#fn = 'examples/doap/doap-en.rdf'

spec = Vocab(fn)
spec.uri = SIOC
# spec.raw()
spec.index()  # slurp info from sources
#print spec.report().encode('UTF-8')

g = spec.graph
q = 'SELECT ?x ?l ?c ?type WHERE { ?x rdfs:label ?l . ?x rdfs:comment ?c . ?x a ?type . FILTER (?type = owl:ObjectProperty || ?type = owl:DatatypeProperty || ?type = rdf:Property || ?type = owl:FunctionalProperty || ?type = owl:InverseFunctionalProperty) } '

q = 'SELECT distinct ?x ?l ?c WHERE { ?x rdfs:label ?l . ?x rdfs:comment ?c . ?x a ?type . FILTER (?type = <http://www.w3.org/2002/07/owl#ObjectProperty> || ?type = <http://www.w3.org/2002/07/owl#DatatypeProperty> || ?type = <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> || ?type = <http://www.w3.org/2002/07/owl#FunctionalProperty> || ?type = <http://www.w3.org/2002/07/owl#InverseFunctionalProperty>) } '

# Got type: http://www.w3.org/2002/07/owl#ObjectProperty
# property: has_usergrouplabel: has_usergroup comment: Points to a Usergroup that has certain access to this Space.

query = Parse(q)
relations = g.query(query, initNs=bindings)
for (term, label, comment) in relations:
コード例 #23
0
ファイル: doap_test.py プロジェクト: foaf/foaftown
from libvocab import Class
from libvocab import Property

from libvocab import DOAP

# Test DOAP spec

fn = 'examples/doap/doap-en.rdf'

# fn = 'examples/doap/doap.rdf'

spec = Vocab(fn)

# Note: I separated out a doap-en since libvocab makes assumptions of 'en'
# this avoids combinatorial explosion of spanish/french/eng labels vs comments
# TODO: don't assume the main index.rdf is monolingual (whether 'en' or other)

# spec = Vocab( DOAP )

spec.uri = DOAP
spec.raw()
spec.index()  # slurp info from sources
# print spec.report()

for p in spec.properties:
    print "Got a property: " + p
    print p.simple_report().encode('UTF-8')
for c in spec.classes:
    print "Got a class: " + c
    print c.simple_report().encode('UTF-8')
コード例 #24
0
 def testSIOCns(self):
     sioc_spec = Vocab('examples/sioc/', 'sioc.rdf')
     sioc_spec.index()
     sioc_spec.uri = str(SIOC)
     self.assertEqual(sioc_spec.uri, 'http://rdfs.org/sioc/ns#')
コード例 #25
0
 def testFOAFns(self):
     foaf_spec = Vocab(FOAFSNAPSHOTDIR, FOAFSNAPSHOT)
     foaf_spec.index()
     foaf_spec.uri = FOAF
     # print "FOAF should be "+FOAF
     self.assertEqual(str(foaf_spec.uri), 'http://xmlns.com/foaf/0.1/')
コード例 #26
0
ファイル: doap_test.py プロジェクト: foaf/foaftown
from libvocab import Class
from libvocab import Property

from libvocab import DOAP

# Test DOAP spec

fn = 'examples/doap/doap-en.rdf' 

# fn = 'examples/doap/doap.rdf' 

spec = Vocab( fn )

# Note: I separated out a doap-en since libvocab makes assumptions of 'en'
# this avoids combinatorial explosion of spanish/french/eng labels vs comments
# TODO: don't assume the main index.rdf is monolingual (whether 'en' or other)

# spec = Vocab( DOAP )

spec.uri = DOAP
spec.raw()
spec.index() # slurp info from sources
# print spec.report()

for p in spec.properties:
  print "Got a property: " + p
  print p.simple_report().encode('UTF-8')
for c in spec.classes:
  print "Got a class: " + c
  print c.simple_report().encode('UTF-8')
コード例 #27
0
 def testDOAPWrongns(self):
     doap_spec = Vocab('examples/doap/', 'doap-en.rdf')
     doap_spec.index()
     doap_spec.uri = str(DOAP)
     self.assertNotEqual(doap_spec.uri,
                         'http://example.com/DELIBERATE_MISTAKE_HERE')
コード例 #28
0
ファイル: query_test.py プロジェクト: jasonzou/spengen7
from rdflib.Graph import Graph
from rdflib.Graph import ConjunctiveGraph
from rdflib.sparql.sparqlGraph  import SPARQLGraph
from rdflib.sparql.graphPattern import GraphPattern
from rdflib.sparql.bison import Parse 
from rdflib.sparql import Query 

# Test a SPARQL query against RDF data input
#

fn = 'examples/sioc/sioc.rdf'
#fn = 'examples/foaf/index.rdf'
#fn = 'examples/doap/doap-en.rdf'

spec = Vocab( fn )
spec.uri = SIOC
# spec.raw()
spec.index() # slurp info from sources
#print spec.report().encode('UTF-8')

g = spec.graph 
q= 'SELECT ?x ?l ?c ?type WHERE { ?x rdfs:label ?l . ?x rdfs:comment ?c . ?x a ?type . FILTER (?type = owl:ObjectProperty || ?type = owl:DatatypeProperty || ?type = rdf:Property || ?type = owl:FunctionalProperty || ?type = owl:InverseFunctionalProperty) } '

q= 'SELECT distinct ?x ?l ?c WHERE { ?x rdfs:label ?l . ?x rdfs:comment ?c . ?x a ?type . FILTER (?type = <http://www.w3.org/2002/07/owl#ObjectProperty> || ?type = <http://www.w3.org/2002/07/owl#DatatypeProperty> || ?type = <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> || ?type = <http://www.w3.org/2002/07/owl#FunctionalProperty> || ?type = <http://www.w3.org/2002/07/owl#InverseFunctionalProperty>) } '


# Got type: http://www.w3.org/2002/07/owl#ObjectProperty
# property: has_usergrouplabel: has_usergroup comment: Points to a Usergroup that has certain access to this Space.


query = Parse(q)