Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing documentation #33

Open
FlorianLudwig opened this issue Sep 5, 2020 · 4 comments
Open

missing documentation #33

FlorianLudwig opened this issue Sep 5, 2020 · 4 comments

Comments

@FlorianLudwig
Copy link

FlorianLudwig commented Sep 5, 2020

I am looking for documentation how to use this - I tried using it like other parsers:

import rdflib


rdfa_text = """
    <div vocab="http://schema.org/" typeof="Order">
      <div property="seller" typeof="Organization">
        <b property="name">ACME Supplies</b>
      </div>
      <div property="customer" typeof="Person">
        <b property="name">Jane Doe</b>
      </div>
      <div property="orderedItem" typeof="OrderItem">
        Item number: <span property="orderItemNumber">abc123</span>
        <span property="orderQuantity">1</span>
        <div property="orderedItem" typeof="Product">
          <span property="name">Widget</span>
        </div>
        <link property="orderItemStatus" href="http://schema.org/OrderDelivered" />Delivered
        <div property="orderDelivery" typeof="ParcelDelivery">
          <time property="expectedArrivalFrom">2015-03-10</time>
        </div>
      </div>
      <div property="orderedItem" typeof="OrderItem">
        Item number: <span property="orderItemNumber">def456</span>
        <span property="orderQuantity">4</span>
        <div property="orderedItem" typeof="Product">
          <span property="name">Widget accessories</span>
        </div>
        <link property="orderItemStatus" href="http://schema.org/OrderInTransit" />Shipped
        <div property="orderDelivery" typeof="ParcelDelivery">
          <time property="expectedArrivalFrom">2015-03-15</time>
          <time property="expectedArrivalUntil">2015-03-18</time>
        </div>
      </div>
    </div>
"""

g = rdflib.Graph()
g.parse(data=rdfa_text, format="rdfa")

But that won't work:

Traceback (most recent call last):
  File "rdfa.py", line 54, in <module>
    g.parse(data=rdfa_text, format="rdfa")
  File "/home/f.ludwig/projects/rdflib/rdflib/graph.py", line 1075, in parse
    parser.parse(source, self, **args)
  File "/home/f.ludwig/.local/share/virtualenvs/dbe-FuKuixvd/lib/python3.8/site-packages/pyRdfa/rdflibparsers.py", line 138, in parse
    self._process(graph, pgraph, baseURI, orig_source,
  File "/home/f.ludwig/.local/share/virtualenvs/dbe-FuKuixvd/lib/python3.8/site-packages/pyRdfa/rdflibparsers.py", line 180, in _process
    _check_error(processor_graph)
  File "/home/f.ludwig/.local/share/virtualenvs/dbe-FuKuixvd/lib/python3.8/site-packages/pyRdfa/rdflibparsers.py", line 60, in _check_error
    raise Exception("RDFa parsing Error! %s" % msg)
Exception: RDFa parsing Error! name 'file' is not defined
@iherman
Copy link
Contributor

iherman commented Sep 7, 2020

@FlorianLudwig, unfortunately, I have difficulties to help here. I have put the HTML fragment into a separate file and ran it through the RDFa processor as a standalone program, and it worked without problems. However, what you do is to run this from inside a Python program, relying on the RDFLib plugin architecture; the plugin approach has changed over the years, and I have not followed those changes (I have stopped working on this library about 5-6 years ago). At this moment, your program does not even get to the point as yours on my own machine, which shows that my local setup may not be up-to-date either. The error message seems to suggest that the bridge between the plugin mechanism and the parser itself seems to be erroneous: line 138 is the entry point into the pyRdfa environment...

I would hope @nicholascar can help in at least locating where the problem may be.

@nicholascar
Copy link
Member

Hi all. The code above still runs fine with RDFlib 4.2.2, just not with RDFlib 5.0.0. So yes, there is a change inside RDFlib 5.0.0's Graph that's doing something different with the results it gets from this plugin and throwing an error.

In the short term, just drop the RDFlib version you're using back to 4.2.2 to use this plugin. I'll try and see if I can find someone to look into the issue in detail.

Apologies for not testing compatibility with PyRdfa3 before releasing RDFlib 5.0.0! We'll be merging the JSON-LD plugin into RDFlib core for RDFlib 6.0.0 and perhaps this could be merged in then too, if not much is changing with RDFa.

@iherman
Copy link
Contributor

iherman commented Sep 9, 2020

Thanks @nicholascar. I have, b.t.w., a PR (#34) that takes care of some of the issues around Python3, but I am not sure whether merging this is wise with the versions of RDFLib changing. The changes are really only on the level of Python2 vs. Python3 (usage of print, that sort of things), and nothing else. And, as you know, I do not really plan to do any more work on this...

@nicholascar
Copy link
Member

rdflib-jsonld is now merged into rdflib, as of 6.0.0 and the PR #34 mentioned above is merged.

A PR to restore RDFa support in RDFlib is in progress here: RDFLib/rdflib#1503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants