Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Avy Faingezicht
    @avyfain
    Does anyone have code snippets/patterns to share on how to properly deal with reification in rdflib? I'm planning to use python + rdflib to create a graph from a few sources, and I am planning to use reification for provenance (learned fact X from source Y) as well as for temporality (X worked at Y since Z). I found it odd that there was nothing about that in the docs
    Iwan Aucamp
    @aucampia
    Presumably this is not RDF* reificiation?
    If it is not RDF* then there is no specific language support
    or library support
    Well there is no specific RDF* support either
    I will try make an example though on using RDF 1.1 recommendation for reification (i.e. rdf:Statement IIRC)
    CC: @avyfain
    Iwan Aucamp
    @aucampia
    will only look at it tonight though
    4 replies
    Avy Faingezicht
    @avyfain

    Thanks @aucampia! I am starting from scratch here, so if RDF* was available then I'd probably go with that since it's the next big standard, but just good old RDF 1.1 would be ok

    import rdflib
    from rdflib.namespace import RDF
    
    lit2019 = rdflib.Literal('2019-01-01', datatype=rdflib.XSD.date)
    lit2020 = rdflib.Literal('2020-01-01', datatype=rdflib.XSD.date)
    
    bob = rdflib.URIRef("http://example.org/people/Bob")
    google = rdflib.URIRef("http://example.org/companies/Google")
    workedAt = rdflib.URIRef("http://example.org/stuff/0.1/workedAt")
    startTime = rdflib.URIRef("http://example.org/stuff/0.1/startTime")
    endTime = rdflib.URIRef("http://example.org/stuff/0.1/endTime")
    
    g = rdflib.Graph()
    
    position = (bob, workedAt, google)
    reified_position = (position, RDF.type, RDF.Statement)
    
    g.add(position)
    g.add(reified_position)
    g.add((reified_position, startTime, lit2019))

    I tried running this but can't add that second triple, I guess I'd have to make it a BNode?

    hope that helps
    Iwan Aucamp
    @aucampia
    I updated it to schema.org instead
    will maybe share it on stackoverflow also
    though not sure it is extremely idomatic
    Iwan Aucamp
    @aucampia
    An example with http://www.ontotext.com/proton/protontop.html#Statement may be more idiomatic
    Avy Faingezicht
    @avyfain
    That's super helpful, yeah! Thanks a lot Iwan! I'm pretty new to the semantic web side of things, so still picking up on the right patterns/namespaces/etc. I'll play around with this some more and maybe after a bit I can share where I end up
    Iwan Aucamp
    @aucampia
    Ask if you need more help, will help when I can
    Always glad to have more people using it :)
    Another great place to ask for help in general is https://gitter.im/linkeddata/chat - but that is just general semantic web and not rdflib specific
    joylix
    @joylix
    Does rdflib support RDF-star and SPARQL-star now?
    Iwan Aucamp
    @aucampia
    @joylix not yet AFAIK see RDFLib/rdflib#955
    Avy Faingezicht
    @avyfain
    Is there a way to set up a default language for a graph, just like there's the default context?
    Iwan Aucamp
    @aucampia
    Like the default language for string literals?
    I don't think there is a built in way to do that
    Avy Faingezicht
    @avyfain
    Hmm bummer. Yeah, that's what I was thinking. Partly because if they are null they aren't unique when using the sqlalchemy backend.
    rpgoldman
    @rpgoldman
    Is there a way to add a prefix definition for : in RDFLib? g.bind("", ns) does not seem to work.
    When I normalize a URI with that binding, I get default1:foobar for :foobar
    Avy Faingezicht
    @avyfain
    Anyone here has experience working with large datasets in rdflib-sqlalchemy with psql as a backend? any advice on reducing latencies at read/write time?
    Iwan Aucamp
    @aucampia
    I have not used it, but I guess the best advice I can give is to try and isolate where the latency is coming from
    2 replies
    rpgoldman
    @rpgoldman
    Wanted to ask a question about rdflab.extras.infixowl : I don't see how to enter a datatype restriction (e.g., the numericalUnit only owl:real [>= 200 ] Anyone know if this is possible?
    2 replies
    Iwan Aucamp
    @aucampia
    Hope Nick knows we appreciate all the work he puts into this
    Can imagine it must feel a bit thankless
    But I think it is invaluable
    white_gecko
    @white_gecko:matrix.org
    [m]
    I have forwarded it to him.
    Iwan Aucamp
    @aucampia
    thanks :)
    white_gecko
    @white_gecko:matrix.org
    [m]
    Thank you, for giving room to such important things in live :-)
    Iwan Aucamp
    @aucampia
    If anyone has time for a review: RDFLib/rdflib#1452 - Migrate from nosetest to pytest
    Iwan Aucamp
    @aucampia
    Need more reviewers :/
    Robert Alexander
    @rjalexa
    Dear friends, medical doctor here trying to model human medicines. I generate a .ttl file which works well but I need to add the following line manually everytime: http://isagog.com/dataset/aifa rdf:type owl:Ontology ;
    owl:imports http://isagog.com/ontologies/pharma .
    Is there a way to use RDFLib in such a way that it will add that when serializing/writing the file? Thank you so much for this wonderful package.
    Robert Alexander
    @rjalexa
    Nevermind, I overcame my brain freeze and found the solution :) Thanks to you all
    Graham Higgins
    @gjhiggins
    2 replies
    greattang123
    @greattang123

    Dear rdflib manitainers,
    I am a user of rdflib. When I use rdflib.Graph to parse one .nt file, the terminal output is
    rdflib.exceptions.ParserError: Invalid line: http://dbpedia.org/resource/2015_African_Rugby_Under-19_Cup_Division_"A" .
    While I remove the double quotations of ”A", i.e., "A" -> A,the program is OK. I want to know if there are other ways to parsing the .nt file rather than remove the double quotations of ”A".
    Thanks a lot.
    Yours Sincerely.

    Appendix
    Data{ <a:> http://www.w3.org/2002/07/owl#sameAs http://dbpedia.org/resource/2015_African_Rugby_Under-19_Cup_Division_"A" .}
    Code{
    from rdflib import Graph
    g = Graph()
    g.parse("./data/example.nt")
    print(f"Graph g has {len(g)} statements.")
    print(g.serialize(format="turtle"))
    }

    Graham Higgins
    @gjhiggins
    Looks like a problematic URL for dbpedia. With, or without the double qutoes, that dbpedia URL returns a “301 See other” and the relocate is https://dbpedia.org/resource/2015_African_Rugby_Under-19_Cup_Division_%22A%22- which itself fails to resolve. OTOH, wikipedia returns a corresponding redirect https://en.wikipedia.org/wiki/2015_African_Rugby_Under-19_Cup_Division_%22A%22 which is found. The dbpedia page is essentially blank, it has none of the info for that entry on wikipedia.
    1 reply
    Iwan Aucamp
    @aucampia
    @greattang123 I once had similar issues, and then what I did was basically to run urllib.parse.quoteon the bad URL first
    1 reply
    @greattang123 https://gitlab.com/aucampia/incubator/-/blob/master/osdu-ld/tools.py/src/osdu/ld/util.py#L143 < nasty code, but that is one place where I used it
    Thomas Tanon
    @Tpt
    Hi! I would love to get feedback on: RDFLib/rdflib#1396
    I am moving forward with my Oxigraph project (https://github.com/oxigraph/oxigraph) and I would love to be able to provide a fast rdflib store based on it.
    The task description a bit convoluted. I can work to make it clearer if needed
    Graham Higgins
    @gjhiggins
    I'm working in that area atm, trying to progress the "identifier-as-context" issue that's been extant since 2010 or thereabouts and which has had a couple of implementations, the last one being oohlaf's PR of RDFLib/rdflib#958. It's looking reasonably good thus far but there's a coupla aspects I'm not sure about but may just be down to terminological inexactitude - f'rinstance https://github.com/RDFLib/rdflib/blob/9379a69d6ec6e18819aa0c5a0d54849e7abb8223/rdflib/graph.py#L1558 where ConjunctiveGraph binds a Graph to the instance variable self.default_context.
    Thomas Tanon
    @Tpt
    @gjhiggins Great! Thank you! The PR you link does not solves my problem but seems a good step into the right direction
    4 replies