Creating a new tuple with rdflib

Hi all,

I am working in a project to develop a decentralized chat and I have found a problem when using rdflib and how to store my data in turtle format.

What I do now is as follows:

store.add(sender, text, "my friend", doc);

I am trying this with just 1 POD as to try to get the correct functioning with turtle before jumping into having two users or more but thats for a further discussion.

Right now my problem is that whenever the first I try add a message all works fine, and the tuple is created as expected in my .ttl file.

@prefix : <#>.
@prefix c: </profile/card#>.
c:me "Testing message" "my friend".

But the second time I try to add another message it just adds it to the first tuple, over creating a second tuple with the second message.

I am not sure if it has to do with my knowledge about turtle which is pretty basic, or the way I am working with rdflib and handling the updates on the POD.

Thanks in advance

Hi Alvasan,

if you are meaning by the second time you get something like:

@prefix : <#>.
@prefix c: </profile/card#>.
c:me “Testing message” “my friend”;
“Second message” “my friend”.

then it is all right. The missing of the subject (c:me) ist just a short hand from turtle, the second line is a full tuple actually.

Be also aware that the second component in the tuple should be a predicate from some ontology or vocabulary. You should look for an appropriated vocabulary for representing messages. Then the message text would be probably the third component in the tuple, the object or value.


1 Like

Thanks for the information, I will have a look into the correct way of representing messages.

Still, the second time I get a different thing from what you pointed out:

@prefix : <#>.
@prefix c: </profile/card#>.
 c:me "Test" "my friend", "my friend".

Rather than adding a second tuple it is adding a comma and then the subject again. All I change is the text on the call to the store.add.

Comma indicates that subject and predicate are the same