本文整理汇总了Python中libvocab.Vocab.uri方法的典型用法代码示例。如果您正苦于以下问题:Python Vocab.uri方法的具体用法?Python Vocab.uri怎么用?Python Vocab.uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libvocab.Vocab
的用法示例。
在下文中一共展示了Vocab.uri方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testFOAFminprops
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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: testSIOCminprops
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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: testCanUseNonStrURI
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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: testFOAFusingDCasExternal
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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)
''
示例5: testSIOCmaxprops
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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))
示例6: testDOAPusingFOAFasExternal
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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)
''
示例7: test_getset_uri
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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.")
示例8: makeSpec
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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)
示例9: Vocab
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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)
示例10: Vocab
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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')
示例11: testDOAPns
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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#')
示例12: testDOAPWrongns
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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')
示例13: testSIOCns
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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#')
示例14: testFOAFns
# 需要导入模块: from libvocab import Vocab [as 别名]
# 或者: from libvocab.Vocab import uri [as 别名]
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/')