Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    iwan.aucamp
    @iwan.aucamp:matrix.org
    [m]
    no I mean with OWL
    Nicholas Car
    @nicholascar

    Just in case people missed the mailing list post:

    My student Xugang Song (Song) has just demoed to me Turtle-star -> RDFLib Graph -> Turtle-star deserialisation, serialisation roundtrip, for all of the approved Turtle-star test cases [1]. His work is buried deep in the repo at [2].

    We are considering what he might do with his remaining student time (2 months) but, whatever else he does, he will contribute his final work as a neat PR to RDFLib.

    If you have a strong request for what he might do - perhaps other format conversions or benchmarking of RDFLib's implementation v. others - please le me know on this mailing list ASAP.

    Regards, Nick

    [1] https://w3c.github.io/rdf-tests/turtle/
    [2] https://github.com/RDFLib/rdflib-rdfstar/

    Iwan Aucamp
    @aucampia
    @nicholascar I will get back to you tomorrow
    Tory Clasen
    @tclasen
    Hello again RDFLib folk. Is there a way to specify a consistent skolemization formula to a graph such that every time I export it from rdflib I get the same names for blank nodes back?
    Now that I'm saying this out-loud, it sounds stupid. What would be a good way to handle blank nodes in a json-ld blob where I've split out each "@id" subject into its own document?
    Iwan Aucamp
    @aucampia
    @tclasen it is not stupid actually :D
    We have this
    "Uses an algorithm to compute unique hashes which takes bnodes into account."
    It is a bit buggy
    iwan.aucamp
    @iwan.aucamp:matrix.org
    [m]
    but it sometimes works
    most of the time
    For the blank node as a json blob, you would have to manually transform the graph, basically take each subject, get all triples with that subject, construct json-ld, etc
    rdflib.compare.to_canonical_graph
    I would say use that, and if it does not work make a PR to fix it
    or tell us why it is broken
    and we can try fix it
    Nicholas Car
    @nicholascar

    I don't like our chances of implementing deterministic BN hashes in the sort term: this is a hard problem.

    There is a W3C WG convening now (https://www.w3.org/groups/wg/rch) that aims to solver the larger problem that is predicated on solving this one:

    "There are a variety of use cases that depend on the ability to calculate a unique and deterministic hash value of RDF Datasets...These use cases require a standard way to process the underlying graphs contained in RDF Datasets that is independent of the serialization itself. "

    iwan.aucamp
    @iwan.aucamp:matrix.org
    [m]
    That is true, but to_canonical_graph is there and it works mostly. But likely the outputs of that working group will make it easier to provide this functionality correctly and robustly
    Iwan Aucamp
    @aucampia
    If anyone has time please consider checking out some of the open PRs tagged with review wanted - there are some quite simple/small ones
    1 reply
    iwan.aucamp
    @iwan.aucamp:matrix.org
    [m]
    thanks @gjhiggins
    matetrix
    @matetrix:matrix.org
    [m]
    Hi,
    I have a turtle file with id's (not URI's).
    When I parse it with rdflib, it adds a "file:///home/user/path/to/ttl_file/" prefix, which I don't want.
    I can change the prexfix with the publicID parameter, but I can't get rid of it.
    Is there a way to achive this behavior?
    1 reply
    matetrix
    @matetrix:matrix.org
    [m]

    Input file (with only ids):
    @prefix xsd: http://www.w3.org/2001/XMLSchema# .

    <D00002> <isOriginalData> true .

    <hsa:10> <isOriginalData> true ;
    <interaction> <D00002>,
    <D00448> .

    <hsa:111> <isOriginalData> true ;
    <interaction> <D00002> .

    #

    Serialised file AFTER parsing (with prefix added):
    @prefix ns1: file:///home/user/data_folder/ .
    @prefix xsd: http://www.w3.org/2001/XMLSchema# .

    <hsa:10> ns1:isOriginalData true ;
    ns1:interaction ns1:D00002,
    ns1:D00448 .

    <hsa:111> ns1:isOriginalData true ;
    ns1:interaction ns1:D00002 .

    ns1:D00002 ns1:isOriginalData true .

    Graham Higgins
    @gjhiggins-matrix:matrix.org
    [m]
    matetrix: looks like you need to bind an arbitrary ns to base - as illustrated in the W3 Turtle doc intro: https://www.w3.org/TR/turtle/#sec-intro
    matetrix
    @matetrix:matrix.org
    [m]
    So there is no way around a id prefix?
    Graham Higgins
    @gjhiggins-matrix:matrix.org
    [m]
    Um, looks like "no" as far as RDFLib's serialization of turtle goes - this may be an issue, I'll have to investigate further.
    matetrix
    @matetrix:matrix.org
    [m]
    That's unfortunate, I'll try adding a default namespace for everything and remove it in postprocessing, thanks for your help
    Graham Higgins
    @gjhiggins-matrix:matrix.org
    [m]
    Ok, it's not as bad as all that ...
    matetrix: see above (oh, and the namespace declaration in your turtle-as-posted is invalid, see data in attachment and hsa is missing a prefix declaration)
    matetrix
    @matetrix:matrix.org
    [m]
    It kind of works, the resulting serialization has the added @base prefix and only the ids in the triples.
    But i also need to query the knowledge graph, and this results into a id with prefix.
    "hsa:111" is unfortunately an id, "hsa:" is not a prefix.
    mikerah
    @mikerah:matrix.org
    [m]
    I have a question about RDFLib's internal graph representation
    I know that other python graph libraries like Networkx use an adjacency matrix to represent graphs
    However, I wasn't able to find such a representation in RDFLib
    Is there a way to get an RDF graph represented as an adjacency matrix through RDFLib?
    1 reply
    mikerah
    @mikerah:matrix.org
    [m]
    Thank you
    fatmeBK
    @fatmeBK
    hi I have a problem when I use the Arabic language inside the rule swrl( rule1 = Imp()
    rule1.set_as_rule("""Patient(?p), hasSymptom(?p,couch) -> hasDisease(?p,الربو)""")) in Python It gives me this error......(raise LexingError('Lexing error near "%s..."!' % self.s[self.idx : self.idx + 15], self.idx)
    owlready2.rply.LexingError: ('Lexing error near "الربو)..."!', 51)
    3 replies
    shafaat khan
    @shafaat10013_twitter
    Hi, is rdflib graph object same as rdfjs graph object?
    Or can some one please send an example of how rdflib graph object looks like?
    A stringified example of graph object if possible. Thanks
    Nicholas Car
    @nicholascar

    Hi, is rdflib graph object same as rdfjs graph object?

    No, how could it be? RDFLib - Python - is a Python dictionary-based object, the JS one uses JS data structures.

    Or can some one please send an example of how rdflib graph object looks like?
    A stringified example of graph object if possible. Thanks

    You can print a Python object's properties like this:

    from rdflib import Graph
    g = Graph()
    print(dir(g))

    But to really understand RDFLib's Graph object, I suggest you just read the documentation, perhaps here: https://rdflib.readthedocs.io/en/stable/utilities.html

    shafaat khan
    @shafaat10013_twitter
    Thanks
    Can i parse rdfjs graph to rdflib graph?
    I have rdfjs graph and want to use it in validation through pySHACL as SHACL's javascript library doesnot support SPARQL constraints
    shafaat khan
    @shafaat10013_twitter
    I am able to run python file through nodeJS
    Also its rdflibJS library's graph which i have currently.
    shafaat khan
    @shafaat10013_twitter
    Was able to pass string of nquads for shacl validation which i created through rdflib store.
    fatmeBK
    @fatmeBK
      graph = default_world.as_rdflib_graph()
      list( graph.query_owlready( """ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
               PREFIX owl: <http://www.w3.org/2002/07/owl#>
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
               PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
               PREFIX my: <http://www.semanticweb.org/allaithgroup/ontologies/2021/11/untitled-ontology-33#>
              SELECT ?x ?y ?z
              WHERE { ?x   my:hasDiagnosis ?y .
                      ?y  rdfs:comment  ?z }
    """)) How can I access the variable z only?