Posted By

magicrebirth on 07/13/10


Tagged

python RDF


Versions (?)

RDFLIB: playing with URIRef objects


 / Published in: Python
 

URL: http://www.rdflib.net/rdflib-2.4.0/html/index.html

  1. In [24]: from rdflib import RDF
  2.  
  3. In [25]: from rdflib import
  4. BNode IIdentifier Node StringInputSource _logger exceptions sparql
  5. ConjunctiveGraph Identifier QueryResult URIRef classImplements interfaces store
  6. FileInputSource Literal RDF URLInputSource compat logging syntax
  7. Graph Namespace RDFS Variable events plugin
  8.  
  9. In [25]: from rdflib import RDFS
  10.  
  11.  
  12. In [26]: RDFS.su
  13. RDFS.subClassOf RDFS.subPropertyOf
  14.  
  15. In [26]: for x in g.triples((None, rdftype, owlclass)):
  16. ....: f = x
  17. ....:
  18. ....:
  19.  
  20. In [27]: f
  21. Out[27]:
  22. (rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl#node'),
  23. rdflib.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
  24. rdflib.URIRef('http://www.w3.org/2002/07/owl#Class'))
  25.  
  26. In [28]: type(f)
  27. Out[28]: <type 'tuple'>
  28.  
  29.  
  30. In [29]: f[0]
  31. Out[29]: rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl#node')
  32.  
  33. In [30]: type(_)
  34. Out[30]: <class 'rdflib.URIRef.URIRef'>
  35.  
  36. In [31]: u = f[0]
  37.  
  38. In [32]: u.
  39. u.__add__ u.__gt__ u.__new__ u.abstract u.index u.ljust u.rsplit
  40. u.__class__ u.__hash__ u.__providedBy__ u.capitalize u.isalnum u.lower u.rstrip
  41. u.__contains__ u.__implemented__ u.__provides__ u.center u.isalpha u.lstrip u.split
  42. u.__delattr__ u.__init__ u.__reduce__ u.concrete u.isdecimal u.md5_term_hash u.splitlines
  43. u.__doc__ u.__le__ u.__reduce_ex__ u.count u.isdigit u.n3 u.startswith
  44. u.__eq__ u.__len__ u.__repr__ u.decode u.islower u.partition u.strip
  45. u.__ge__ u.__lt__ u.__rmod__ u.defrag u.isnumeric u.replace u.swapcase
  46. u.__getattribute__ u.__mod__ u.__rmul__ u.encode u.isspace u.rfind u.title
  47. u.__getitem__ u.__module__ u.__setattr__ u.endswith u.istitle u.rindex u.translate
  48. u.__getnewargs__ u.__mul__ u.__slots__ u.expandtabs u.isupper u.rjust u.upper
  49. u.__getslice__ u.__ne__ u.__str__ u.find u.join u.rpartition u.zfill
  50.  
  51. In [32]: u.abstract
  52. Out[32]: <bound method URIRef.abstract of rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl#node')>
  53.  
  54. In [33]: u.abstract()
  55. Out[33]: rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl#node')
  56.  
  57. In [35]: u.concrete()
  58. Out[35]: rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl/node')
  59.  
  60. In [36]: u.defrag()
  61. Out[36]: rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl')
  62.  
  63. In [37]: u.__str__()
  64. Out[37]: 'http://cohereweb.net/ontology/cohere.owl#node'
  65.  
  66. In [38]: u.n3()
  67. Out[38]: u'<http://cohereweb.net/ontology/cohere.owl#node>'

Report this snippet  

You need to login to post a comment.