GithubHelp home page GithubHelp logo

rdflib-microdata's Introduction

This is a rdflib plugin for parsing html5 microdata and modelling it as an rdf graph. The rdflib and html5lib libraries are required. Basically you'll be able to do something like:

>>> import rdflib
>>> import rdflib_microdata
>>> g = rdflib.Graph()
>>> g.parse("https://raw.github.com/edsu/microdata/master/test-data/example.html", format="microdata")
>>> print g.serialize()
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
   xmlns:ns1="http://schema.org/Person#"
   xmlns:ns2="http://schema.org/PostalAddress#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
  <rdf:Description rdf:about="http://www.xyz.edu/~jane">
    <ns1:name>Jane Doe</ns1:name>
    <ns1:email rdf:resource="mailto:[email protected]"/>
    <rdf:type rdf:resource="http://schema.org/Person"/>
    <ns1:url rdf:resource="http://www.janedoe.com"/>
    <ns1:colleagues rdf:resource="http://www.xyz.edu/students/alicejones.html"/>
    <ns1:colleagues rdf:resource="http://www.xyz.edu/students/bobsmith.html"/>
    <ns1:telephone>(425) 123-4567</ns1:telephone>
    <ns1:address rdf:nodeID="TggQqDwH2"/>
    <ns1:image rdf:resource="janedoe.jpg"/>
    <ns1:jobTitle>Professor</ns1:jobTitle>
  </rdf:Description>
  <rdf:Description rdf:nodeID="TggQqDwH2">
    <rdf:type rdf:resource="http://schema.org/PostalAddress"/>
    <ns2:addressRegion>WA</ns2:addressRegion>
    <ns2:postalCode>98052</ns2:postalCode>
    <ns2:streetAddress>
          20341 Whitworth Institute
          405 N. Whitworth
        </ns2:streetAddress>
    <ns2:addressLocality>Seattle</ns2:addressLocality>
  </rdf:Description>
</rdf:RDF>

Author: Ed Summers

License: Public Domain

rdflib-microdata's People

Contributors

edsu avatar

Watchers

JT5D avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.