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

Add method for adding new Seq objects #280

Closed
gromgull opened this issue May 9, 2013 · 7 comments · Fixed by #997
Closed

Add method for adding new Seq objects #280

gromgull opened this issue May 9, 2013 · 7 comments · Fixed by #997
Labels
cleanup help wanted Extra attention is needed
Milestone

Comments

@gromgull
Copy link
Member

gromgull commented May 9, 2013

For querying - we have the Seq class / Graph.seq method for RDF Seq's and the Graph.items for RDF collections

The collections.Collection class tries to help adding collections, although it's slightly broken (#223)

We have no easy way to add seqs...

@gromgull gromgull changed the title tidy up methods for (adding) collections/list Add method for adding new Seq objects Jan 29, 2017
@gromgull
Copy link
Member Author

A collection adding method was added.

Related is, why do we not have a Bag or Alt class?

@joernhees joernhees added the help wanted Extra attention is needed label Jan 29, 2017
@joernhees joernhees added this to the rdflib 5.0.0 milestone Jan 29, 2017
@kushagr08
Copy link
Contributor

I am interested in solving this issue. Is a separate class wanted for bag/alt, since the Collection class only handles Seq?

@ashleysommer
Copy link
Contributor

@kushagr08
It might be a good idea to refactor the Collection class such that it uses rdf:Bag, then add subclasses for rdf:Seq and rdf:Alt. This would be a breaking change, but is a logical change, and would be considered for the 6.0.0 release.

@kushagr08
Copy link
Contributor

@ashleysommer
The Collection class is being used in various other sections of code such as graph.py . So if I remodel it as a Bag class, would I need to do corresponding changes in other sections of the code which use this class? Or will it be a good idea to make a Bag class from scratch and let the Collection class remain as it is ? This is because a bag is structurally different from a Collection.

@hsolbrig
Copy link
Contributor

Don't know whether this is directly applicable, but something we've found handy in certain situations:

https://github.com/hsolbrig/CFGraph

@kushagr08
Copy link
Contributor

@ashleysommer @hsolbrig
The structure of a collection in RDF is fundamentally different from that of a container.
A collection node has rdf: first which has the value of the current node and rdf :rest which points to the rest of the list.
A container, on the other hand, has one blank node which points to all of it's items by predicates of the form of rdf:_1 ,rdf:_2 and so on.
Therefore, I propose to add a separate container class to close this issue (as collection class is already there). Whether the container will be seq, alt or bag is for the user to decide since all of seq, alt and bag are containers, structurally same and semantically different. (https://stackoverflow.com/questions/29001433/how-rdfbag-rdfseq-and-rdfalt-is-different-while-using-them)

@white-gecko white-gecko modified the milestones: rdflib 5.0.0, rdflib 5.1.0 Apr 6, 2020
@kushagr08
Copy link
Contributor

@ashleysommer @hsolbrig
I have made a pull request for this issue. I have added a Container class with its 3 subclasses corresponding to seq, alt and bag as proposed. I have added some test cases also using assert statements. I request you to review the same.

@white-gecko white-gecko modified the milestones: rdflib 5.1.0, rdflib 6.0.0 May 1, 2020
nicholascar added a commit that referenced this issue May 25, 2020
Fix #280: Added container.py for adding container class and seq, alt and bag as it's subclasses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup help wanted Extra attention is needed
Projects
None yet
6 participants