RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.15k stars 555 forks source link

"Bag" in rdflib #1235

Closed RichardPinka closed 3 years ago

RichardPinka commented 3 years ago

hello, Do You have please clue, why "Bag" is not working in module rdflib as you may see ? image

white-gecko commented 3 years ago

Hello @RichardPinka , the containers were added in the current master branch but are not yet released. Probably you are using rdflib 5.0.0 which does not include containers. When you install from the current master branch you will need to import Bag from rdflib.container as the following example shows:

from rdflib import Graph, BNode, Literal
from rdflib.container import Bag

g = Graph()
b = Bag(g, BNode(), [Literal("one"), Literal("two"), Literal("three")])

print(g.serialize(format="turtle"))
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

[] a rdf:Bag ;
    rdf:_1 "one" ;
    rdf:_2 "two" ;
    rdf:_3 "three" .

A minor remark. Please directly paste your code and the relevant output into the issue. That makes it easier to reproduce your code.

RichardPinka commented 3 years ago

Hello and thank you. Now, I just need to find out how the "current master branch" could be installed :) (sorry i am civil engineer, i like simple stuf like setup.exe for installing the stuff :) )

white-gecko commented 3 years ago

You can try it with

pip install git+https://github.com/RDFLib/rdflib@master

but be aware, the code in the master branch is not yet released and might be unstable