Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

isomorphic graph with literal testing #656

Closed
satra opened this issue Oct 12, 2016 · 4 comments
Closed

isomorphic graph with literal testing #656

satra opened this issue Oct 12, 2016 · 4 comments
Labels
discussion enhancement New feature or request fix-in-progress parsing Related to a parsing. serialization Related to serialization.

Comments

@satra
Copy link
Contributor

satra commented Oct 12, 2016

if not g_rdf.isomorphic(g0_rdf):
    in_both, in_first, in_second = graph_diff(g_rdf, g0_rdf)
    print("FIRST")
    dump_nt_sorted(in_first) 
    print("SECOND")
    dump_nt_sorted(in_second) 

returns

FIRST
<http://example.org/a2> <http://www.w3.org/2000/01/rdf-schema#label> "activity2" .
<http://example.org/a2> <http://www.w3.org/2000/01/rdf-schema#label> "hello" .
SECOND
<http://example.org/a2> <http://www.w3.org/2000/01/rdf-schema#label> 
            "activity2"^^<http://www.w3.org/2001/XMLSchema#string> .
<http://example.org/a2> <http://www.w3.org/2000/01/rdf-schema#label> 
            "hello"^^<http://www.w3.org/2001/XMLSchema#string> .

would there be a way to say that the string "activity2" is equivalent to "activity2"^^<http://www.w3.org/2001/XMLSchema#string>

@joernhees joernhees added this to the rdflib 4.2.2 milestone Oct 13, 2016
@joernhees joernhees modified the milestones: rdflib 5.0.0, rdflib 4.2.2 Oct 13, 2016
@joernhees
Copy link
Member

hmm, i'm inclined to agree with your reasoning, but this probably has tons of intricate effects on RDFlib.
Additionally people might rely on Literal("foo").dataype is None, so this is definitely nothing we can change in a patch release.

For consistency reasons, accepting #657 should then also enforce datatype == XSD['langstring'] for strings with a language...

I think the reason for this can be seen (as many weird things) in rdflib trying to find the "pythonic" way in between syntactic and semantic equivalence.

  1. If you write Literal("foo").n3(), would you expect "foo" or "foo"^^xsd:string?
  2. If you now parse "foo"^^xsd:string, and afterwards serialize it again, what would you expect?

@joernhees joernhees added enhancement New feature or request fix-in-progress parsing Related to a parsing. serialization Related to serialization. discussion labels Oct 13, 2016
@satra
Copy link
Contributor Author

satra commented Oct 13, 2016

@joernhees - i wrote an extension to find_diff that helped me for my use case to isolate the differences that were actually affecting output. however, if you note the check that i'm doing is a literal check and that does return equivalence for things that don't return equivalent for a hash-based check.

https://github.com/satra/prov/blob/e480c62f2ed4dc1a4d1db4da8293afad163ba9e0/prov/tests/test_rdf.py#L22

this could be enabled through a flag or something.

i completely agree about the pythonic nature of things. this is exactly the issue noted here:

trungdong/prov#89

@cmaumet
Copy link

cmaumet commented Oct 13, 2016

@joernhees, @satra: agreed accepting #657 would have side effects, let's close it.

+1 for @satra's suggestion above.

@gromgull
Copy link
Member

this is sort of the same as #670

@ashleysommer ashleysommer removed this from the rdflib 5.0.0 milestone Apr 4, 2020
@ghost ghost locked and limited conversation to collaborators Dec 25, 2021
@ghost ghost converted this issue into discussion #1540 Dec 25, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
discussion enhancement New feature or request fix-in-progress parsing Related to a parsing. serialization Related to serialization.
Projects
None yet
Development

No branches or pull requests

5 participants