You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Martynas Jusevičius <ma...@atomgraph.com> on 2018/01/03 01:05:27 UTC
[3.0.1] Models (not) isomorphic
Hi,
I am writing a unit test for an RDF parser:
https://github.com/AtomGraph/Core/blob/master/src/test/java/com/atomgraph/core/riot/lang/RDFPostReaderTest.java
I have constructed two Models which only differ in blank nodes,
yet wanted.isIsomorphicWith(got) returns false.
Here are the wanted.toString() and got.toString() output:
<ModelCom {http://subject2 @http://predicate3 "literal1"; http://subject3
@http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
http://subject1 @http://predicate2 http://object3; http://subject1 @
http://predicate2 http://object2; http://subject1 @http://predicate1
http://object1; http://subject1 @http://dc.org/#title "title"@da;
http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
http://predicate5 "literal3"^^http://type} | [http://subject2,
http://predicate3, "literal1"] [http://subject3, http://predicate4,
"literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil] [b1,
http://rdf.org/#first, http://something/] [http://subject1,
http://predicate2, http://object3] [http://subject1, http://predicate2,
http://object2] [http://subject1, http://predicate1, http://object1] [
http://subject1, http://dc.org/#title, "title"@da] [http://subject4,
http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
"literal3"^^http://type]>
<ModelCom {http://subject2 @http://predicate3 "literal1"; http://subject3
@http://predicate4 "literal2"@da; http://subject1 @http://predicate2
http://object3; http://subject1 @http://predicate2 http://object2;
http://subject1 @http://predicate1 http://object1; http://subject1 @
http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2 @
http://rdf.org/#rest http://rdf.org/#nil; 9ee64f4ba50df2bb8b28a1a473990da2 @
http://rdf.org/#first http://something/; http://subject4 @
http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2; http://subject4 @
http://predicate5 "literal3"^^http://type} | [http://subject2,
http://predicate3, "literal1"] [http://subject3, http://predicate4,
"literal2"@da] [http://subject1, http://predicate2, http://object3] [
http://subject1, http://predicate2, http://object2] [http://subject1,
http://predicate1, http://object1] [http://subject1, http://dc.org/#title,
"title"@da] [9ee64f4ba50df2bb8b28a1a473990da2, http://rdf.org/#rest,
http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
http://rdf.org/#first, http://something/] [http://subject4,
http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [http://subject4,
http://predicate5, "literal3"^^http://type]>
When I sort the triples by the subject, they seem identical to me, sans
bnode labels:
[http://subject1, http://predicate2, http://object3]
[http://subject1, http://predicate2, http://object2]
[http://subject1, http://predicate1, http://object1]
[http://subject1, http://dc.org/#title, "title"@da]
[http://subject2, http://predicate3, "literal1"]
[http://subject3, http://predicate4, "literal2"@da]
[http://subject4, http://dct.org/#hasPart, b1]
[http://subject4, http://predicate5, "literal3"^^http://type]
[b1, http://rdf.org/#rest, http://rdf.org/#nil]
[b1, http://rdf.org/#first, http://something/]
[http://subject1, http://predicate2, http://object3]
[http://subject1, http://predicate2, http://object2]
[http://subject1, http://predicate1, http://object1]
[http://subject1, http://dc.org/#title, "title"@da]
[http://subject2, http://predicate3, "literal1"]
[http://subject3, http://predicate4, "literal2"@da]
[http://subject4, http://dct.org/#hasPart, 30b98db4d09af8c4a56f907aec5a5348]
[http://subject4, http://predicate5, "literal3"^^http://type]
[30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest, http://rdf.org/#nil
]
[30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first, http://something/]
What am I missing here?
Re: [3.0.1] Models (not) isomorphic
Posted by Andy Seaborne <an...@apache.org>.
On 04/01/18 16:50, Martynas Jusevičius wrote:
> Sorry once again, I was getting confused.
>
> I changed the original test method to construct Model with
>
> RDFDatatype datatype = TypeMapper.getInstance().getSafeTypeByName("
> http://type");
>
> and now it passes.
Yes - you must register.
NodeFactory.getType or TypeMapper#getSafeTypeByName
>
> Thanks!
>
> On Thu, Jan 4, 2018 at 5:46 PM, Martynas Jusevičius <ma...@atomgraph.com>
> wrote:
>
>> Sorry, my bad - the test actually creates 2 BaseDatatype instances. But if
>> I change it the following way, and it passes, I guess the parser is OK?
>>
>> RDFDatatype datatype = new BaseDatatype("http://type");
>> Model a = ModelFactory.createDefaultModel();
>> a.add(a.createResource(), a.createProperty("http://predicate"),
>> a.createTypedLiteral("literal", datatype));
>> Model b = ModelFactory.createDefaultModel();
>> b.add(b.createResource(), b.createProperty("http://predicate"),
>> b.createTypedLiteral("literal", datatype));
>> assertIsomorphic(a, b);
>>
>> On Thu, Jan 4, 2018 at 2:53 PM, Andy Seaborne <an...@apache.org> wrote:
>>
>>> Then trace through and see where the datatype is created.
>>>
>>> Works fine on current Jena but then various things have been improved
>>> since 3.0.1.
>>>
>>> Andy
>>>
>>>
>>> On 04/01/18 13:19, Martynas Jusevičius wrote:
>>>
>>>> On a second thought, the isomorphism test was for the streaming version
>>>> which follows bellow in the class and uses methods from ReaderRIOTBase.
>>>> The
>>>> datatypes parsing is here:
>>>> https://github.com/AtomGraph/Core/blob/master/src/main/java/
>>>> com/atomgraph/core/riot/lang/RDFPostReader.java#L695
>>>>
>>>> What is the fix here? Is it RDFPostReader handling the datatype wrong or
>>>> the ReaderRIOTBase?
>>>>
>>>> On Thu, Jan 4, 2018 at 2:14 PM, Martynas Jusevičius <
>>>> martynas@atomgraph.com>
>>>> wrote:
>>>>
>>>> Thanks, I will :)
>>>>>
>>>>> On Thu, Jan 4, 2018 at 2:12 PM, Andy Seaborne <an...@apache.org> wrote:
>>>>>
>>>>> Fix RDFPostReader? L201 an L218.
>>>>>>
>>>>>>
>>>>>> On 04/01/18 11:34, Martynas Jusevičius wrote:
>>>>>>
>>>>>> Right... I guess for the purposes of the test I'll just use a built-in
>>>>>>> datatype.
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> On Thu, Jan 4, 2018 at 11:42 AM, Andy Seaborne <an...@apache.org>
>>>>>>> wrote:
>>>>>>>
>>>>>>> Martynas,
>>>>>>>
>>>>>>>>
>>>>>>>> Datatypes need to be registered: The easy way (and the way RIOT
>>>>>>>> parsers
>>>>>>>> do
>>>>>>>> it) is to use getSafeTypeByName which registers and returns an
>>>>>>>> instance
>>>>>>>> of
>>>>>>>> BaseDatatype for unknown datatypes.
>>>>>>>>
>>>>>>>> RDFDatatype dt =
>>>>>>>> TypeMapper.getInstance().getSafeTypeByName("http://type");
>>>>>>>> ...
>>>>>>>> a.createTypedLiteral("literal", dt);
>>>>>>>> ...
>>>>>>>> b.createTypedLiteral("literal", dt)
>>>>>>>>
>>>>>>>> Multiple calls to getSafeTypeByName("http://type") will return the
>>>>>>>> same
>>>>>>>> object.
>>>>>>>>
>>>>>>>> Andy
>>>>>>>>
>>>>>>>> Node n1 = NodeFactory.createLiteral(
>>>>>>>> "literal", new BaseDatatype("http://type"));
>>>>>>>> Node n2 = NodeFactory.createLiteral(
>>>>>>>> "literal", new BaseDatatype("http://type"));
>>>>>>>> System.out.println(n1.equals(n2));
>>>>>>>> --> false
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On 04/01/18 00:33, Martynas Jusevičius wrote:
>>>>>>>>
>>>>>>>> Andy,
>>>>>>>>
>>>>>>>>>
>>>>>>>>> it looks like the new BaseDatetype instance is the culprit. I
>>>>>>>>> reproduced a
>>>>>>>>> minimal case - the first test fails, the second one succeeds:
>>>>>>>>>
>>>>>>>>> @Test
>>>>>>>>> public void testIdenticalFails()
>>>>>>>>> {
>>>>>>>>> Model a = ModelFactory.createDefaultModel();
>>>>>>>>> a.add(a.createResource(), a.createProperty("http://predi
>>>>>>>>> cate
>>>>>>>>> "),
>>>>>>>>> a.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>>>>>> Model b = ModelFactory.createDefaultModel();
>>>>>>>>> b.add(b.createResource(), b.createProperty("http://predi
>>>>>>>>> cate
>>>>>>>>> "),
>>>>>>>>> b.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>>>>>> assertIsomorphic(a, b);
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> @Test
>>>>>>>>> public void testIdenticalSucceeds()
>>>>>>>>> {
>>>>>>>>> Model a = ModelFactory.createDefaultModel();
>>>>>>>>> a.add(a.createResource(), a.createProperty("http://predi
>>>>>>>>> cate
>>>>>>>>> "),
>>>>>>>>> a.createTypedLiteral("literal", XSDfloat));
>>>>>>>>> Model b = ModelFactory.createDefaultModel();
>>>>>>>>> b.add(b.createResource(), b.createProperty("http://predi
>>>>>>>>> cate
>>>>>>>>> "),
>>>>>>>>> b.createTypedLiteral("literal", XSDfloat));
>>>>>>>>> assertIsomorphic(a, b);
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Can you confirm?
>>>>>>>>>
>>>>>>>>> On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Can't see anything.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> maybe try cutting down the example to the triple(s) that matter?
>>>>>>>>>> have you checked for upgrading from RDF 1.0?
>>>>>>>>>>
>>>>>>>>>> Andy
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 03/01/18 17:01, Martynas Jusevičius wrote:
>>>>>>>>>>
>>>>>>>>>> System.out.println("-- Expected --");
>>>>>>>>>>
>>>>>>>>>> expected.write(System.out, Lang.TURTLE.getName());
>>>>>>>>>>> System.out.println("-- Parsed --");
>>>>>>>>>>> parsed.write(System.out, Lang.TURTLE.getName());
>>>>>>>>>>>
>>>>>>>>>>> assertIsomorphic(parsed, parsed);
>>>>>>>>>>> assertIsomorphic(expected, expected);
>>>>>>>>>>> assertIsomorphic(expected, parsed);
>>>>>>>>>>>
>>>>>>>>>>> Two first assertions pass, the third one fails. The output:
>>>>>>>>>>>
>>>>>>>>>>> -- Expected --
>>>>>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>>>>>
>>>>>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>>>>>
>>>>>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>>>>>> "title"@da ;
>>>>>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>>>>>> http://object2> .
>>>>>>>>>>>
>>>>>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>>>>>> [ <http://rdf.org/#first> <http://something/>
>>>>>>>>>>> ;
>>>>>>>>>>> <http://rdf.org/#rest> <
>>>>>>>>>>> http://rdf.org/#nil>
>>>>>>>>>>> ] ;
>>>>>>>>>>> <http://predicate5> "literal3"^^<http://type>
>>>>>>>>>>> .
>>>>>>>>>>> -- Parsed --
>>>>>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>>>>>
>>>>>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>>>>>
>>>>>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>>>>>> "title"@da ;
>>>>>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>>>>>> http://object2> .
>>>>>>>>>>>
>>>>>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>>>>>> [ <http://rdf.org/#first> <http://something/>
>>>>>>>>>>> ;
>>>>>>>>>>> <http://rdf.org/#rest> <
>>>>>>>>>>> http://rdf.org/#nil>
>>>>>>>>>>> ] ;
>>>>>>>>>>> <http://predicate5> "literal3"^^<http://type>
>>>>>>>>>>> .
>>>>>>>>>>>
>>>>>>>>>>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Martynas,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Do you have anything readable?
>>>>>>>>>>>>
>>>>>>>>>>>> If you write-and-read-back each model do that test isomorphic to
>>>>>>>>>>>> themselves? To each other after read-write?
>>>>>>>>>>>>
>>>>>>>>>>>> Andy
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi,
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> I am writing a unit test for an RDF parser:
>>>>>>>>>>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>>>>>>>>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>>>>>>>>>>
>>>>>>>>>>>>> I have constructed two Models which only differ in blank nodes,
>>>>>>>>>>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Here are the wanted.toString() and got.toString() output:
>>>>>>>>>>>>>
>>>>>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>>>>>> http://subject3
>>>>>>>>>>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>>>>>>>>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first
>>>>>>>>>>>>> http://something/;
>>>>>>>>>>>>> http://subject1 @http://predicate2 http://object3;
>>>>>>>>>>>>> http://subject1
>>>>>>>>>>>>> @
>>>>>>>>>>>>> http://predicate2 http://object2; http://subject1 @
>>>>>>>>>>>>> http://predicate1
>>>>>>>>>>>>> http://object1; http://subject1 @http://dc.org/#title
>>>>>>>>>>>>> "title"@da;
>>>>>>>>>>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>>>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>>>>>> http://predicate3, "literal1"] [http://subject3,
>>>>>>>>>>>>> http://predicate4
>>>>>>>>>>>>> ,
>>>>>>>>>>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>>>>>> [b1,
>>>>>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>>>>>>>>>>> http://predicate2, http://object3] [http://subject1,
>>>>>>>>>>>>> http://predicate2,
>>>>>>>>>>>>> http://object2] [http://subject1, http://predicate1,
>>>>>>>>>>>>> http://object1]
>>>>>>>>>>>>> [
>>>>>>>>>>>>> http://subject1, http://dc.org/#title, "title"@da] [
>>>>>>>>>>>>> http://subject4,
>>>>>>>>>>>>> http://dct.org/#hasPart, b1] [http://subject4,
>>>>>>>>>>>>> http://predicate5,
>>>>>>>>>>>>> "literal3"^^http://type]>
>>>>>>>>>>>>>
>>>>>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>>>>>> http://subject3
>>>>>>>>>>>>> @http://predicate4 "literal2"@da; http://subject1 @
>>>>>>>>>>>>> http://predicate2
>>>>>>>>>>>>> http://object3; http://subject1 @http://predicate2
>>>>>>>>>>>>> http://object2;
>>>>>>>>>>>>> http://subject1 @http://predicate1 http://object1;
>>>>>>>>>>>>> http://subject1
>>>>>>>>>>>>> @
>>>>>>>>>>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990d
>>>>>>>>>>>>> a2
>>>>>>>>>>>>> @
>>>>>>>>>>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>>>>>>>>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>>>>>>>>> @
>>>>>>>>>>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>>>>>>>>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>>>>>>>>>>> http://subject4
>>>>>>>>>>>>> @
>>>>>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>>>>>> http://predicate3, "literal1"] [http://subject3,
>>>>>>>>>>>>> http://predicate4
>>>>>>>>>>>>> ,
>>>>>>>>>>>>> "literal2"@da] [http://subject1, http://predicate2,
>>>>>>>>>>>>> http://object3]
>>>>>>>>>>>>> [
>>>>>>>>>>>>> http://subject1, http://predicate2, http://object2] [
>>>>>>>>>>>>> http://subject1,
>>>>>>>>>>>>> http://predicate1, http://object1] [http://subject1,
>>>>>>>>>>>>> http://dc.org/#title
>>>>>>>>>>>>> ,
>>>>>>>>>>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>>>>>> http://rdf.org/#rest,
>>>>>>>>>>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>>>>>>>>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>>>>>>>>>>> http://subject4,
>>>>>>>>>>>>> http://predicate5, "literal3"^^http://type]>
>>>>>>>>>>>>>
>>>>>>>>>>>>> When I sort the triples by the subject, they seem identical to
>>>>>>>>>>>>> me,
>>>>>>>>>>>>> sans
>>>>>>>>>>>>> bnode labels:
>>>>>>>>>>>>>
>>>>>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>>>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>>>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>>>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>>>>>> [b1, http://rdf.org/#first, http://something/]
>>>>>>>>>>>>>
>>>>>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>>>>>> [http://subject4, http://dct.org/#hasPart,
>>>>>>>>>>>>> 30b98db4d09af8c4a56f907aec5a53
>>>>>>>>>>>>> 48]
>>>>>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>>>>>>>>>>> http://rdf.org/#nil
>>>>>>>>>>>>> ]
>>>>>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>>>>>>>>>>> http://something/]
>>>>>>>>>>>>>
>>>>>>>>>>>>> What am I missing here?
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>
>>>>
>>
>
Re: [3.0.1] Models (not) isomorphic
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Sorry once again, I was getting confused.
I changed the original test method to construct Model with
RDFDatatype datatype = TypeMapper.getInstance().getSafeTypeByName("
http://type");
and now it passes.
Thanks!
On Thu, Jan 4, 2018 at 5:46 PM, Martynas Jusevičius <ma...@atomgraph.com>
wrote:
> Sorry, my bad - the test actually creates 2 BaseDatatype instances. But if
> I change it the following way, and it passes, I guess the parser is OK?
>
> RDFDatatype datatype = new BaseDatatype("http://type");
> Model a = ModelFactory.createDefaultModel();
> a.add(a.createResource(), a.createProperty("http://predicate"),
> a.createTypedLiteral("literal", datatype));
> Model b = ModelFactory.createDefaultModel();
> b.add(b.createResource(), b.createProperty("http://predicate"),
> b.createTypedLiteral("literal", datatype));
> assertIsomorphic(a, b);
>
> On Thu, Jan 4, 2018 at 2:53 PM, Andy Seaborne <an...@apache.org> wrote:
>
>> Then trace through and see where the datatype is created.
>>
>> Works fine on current Jena but then various things have been improved
>> since 3.0.1.
>>
>> Andy
>>
>>
>> On 04/01/18 13:19, Martynas Jusevičius wrote:
>>
>>> On a second thought, the isomorphism test was for the streaming version
>>> which follows bellow in the class and uses methods from ReaderRIOTBase.
>>> The
>>> datatypes parsing is here:
>>> https://github.com/AtomGraph/Core/blob/master/src/main/java/
>>> com/atomgraph/core/riot/lang/RDFPostReader.java#L695
>>>
>>> What is the fix here? Is it RDFPostReader handling the datatype wrong or
>>> the ReaderRIOTBase?
>>>
>>> On Thu, Jan 4, 2018 at 2:14 PM, Martynas Jusevičius <
>>> martynas@atomgraph.com>
>>> wrote:
>>>
>>> Thanks, I will :)
>>>>
>>>> On Thu, Jan 4, 2018 at 2:12 PM, Andy Seaborne <an...@apache.org> wrote:
>>>>
>>>> Fix RDFPostReader? L201 an L218.
>>>>>
>>>>>
>>>>> On 04/01/18 11:34, Martynas Jusevičius wrote:
>>>>>
>>>>> Right... I guess for the purposes of the test I'll just use a built-in
>>>>>> datatype.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Thu, Jan 4, 2018 at 11:42 AM, Andy Seaborne <an...@apache.org>
>>>>>> wrote:
>>>>>>
>>>>>> Martynas,
>>>>>>
>>>>>>>
>>>>>>> Datatypes need to be registered: The easy way (and the way RIOT
>>>>>>> parsers
>>>>>>> do
>>>>>>> it) is to use getSafeTypeByName which registers and returns an
>>>>>>> instance
>>>>>>> of
>>>>>>> BaseDatatype for unknown datatypes.
>>>>>>>
>>>>>>> RDFDatatype dt =
>>>>>>> TypeMapper.getInstance().getSafeTypeByName("http://type");
>>>>>>> ...
>>>>>>> a.createTypedLiteral("literal", dt);
>>>>>>> ...
>>>>>>> b.createTypedLiteral("literal", dt)
>>>>>>>
>>>>>>> Multiple calls to getSafeTypeByName("http://type") will return the
>>>>>>> same
>>>>>>> object.
>>>>>>>
>>>>>>> Andy
>>>>>>>
>>>>>>> Node n1 = NodeFactory.createLiteral(
>>>>>>> "literal", new BaseDatatype("http://type"));
>>>>>>> Node n2 = NodeFactory.createLiteral(
>>>>>>> "literal", new BaseDatatype("http://type"));
>>>>>>> System.out.println(n1.equals(n2));
>>>>>>> --> false
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 04/01/18 00:33, Martynas Jusevičius wrote:
>>>>>>>
>>>>>>> Andy,
>>>>>>>
>>>>>>>>
>>>>>>>> it looks like the new BaseDatetype instance is the culprit. I
>>>>>>>> reproduced a
>>>>>>>> minimal case - the first test fails, the second one succeeds:
>>>>>>>>
>>>>>>>> @Test
>>>>>>>> public void testIdenticalFails()
>>>>>>>> {
>>>>>>>> Model a = ModelFactory.createDefaultModel();
>>>>>>>> a.add(a.createResource(), a.createProperty("http://predi
>>>>>>>> cate
>>>>>>>> "),
>>>>>>>> a.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>>>>> Model b = ModelFactory.createDefaultModel();
>>>>>>>> b.add(b.createResource(), b.createProperty("http://predi
>>>>>>>> cate
>>>>>>>> "),
>>>>>>>> b.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>>>>> assertIsomorphic(a, b);
>>>>>>>> }
>>>>>>>>
>>>>>>>> @Test
>>>>>>>> public void testIdenticalSucceeds()
>>>>>>>> {
>>>>>>>> Model a = ModelFactory.createDefaultModel();
>>>>>>>> a.add(a.createResource(), a.createProperty("http://predi
>>>>>>>> cate
>>>>>>>> "),
>>>>>>>> a.createTypedLiteral("literal", XSDfloat));
>>>>>>>> Model b = ModelFactory.createDefaultModel();
>>>>>>>> b.add(b.createResource(), b.createProperty("http://predi
>>>>>>>> cate
>>>>>>>> "),
>>>>>>>> b.createTypedLiteral("literal", XSDfloat));
>>>>>>>> assertIsomorphic(a, b);
>>>>>>>> }
>>>>>>>>
>>>>>>>> Can you confirm?
>>>>>>>>
>>>>>>>> On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Can't see anything.
>>>>>>>>
>>>>>>>>
>>>>>>>>> maybe try cutting down the example to the triple(s) that matter?
>>>>>>>>> have you checked for upgrading from RDF 1.0?
>>>>>>>>>
>>>>>>>>> Andy
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 03/01/18 17:01, Martynas Jusevičius wrote:
>>>>>>>>>
>>>>>>>>> System.out.println("-- Expected --");
>>>>>>>>>
>>>>>>>>> expected.write(System.out, Lang.TURTLE.getName());
>>>>>>>>>> System.out.println("-- Parsed --");
>>>>>>>>>> parsed.write(System.out, Lang.TURTLE.getName());
>>>>>>>>>>
>>>>>>>>>> assertIsomorphic(parsed, parsed);
>>>>>>>>>> assertIsomorphic(expected, expected);
>>>>>>>>>> assertIsomorphic(expected, parsed);
>>>>>>>>>>
>>>>>>>>>> Two first assertions pass, the third one fails. The output:
>>>>>>>>>>
>>>>>>>>>> -- Expected --
>>>>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>>>>
>>>>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>>>>
>>>>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>>>>> "title"@da ;
>>>>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>>>>> http://object2> .
>>>>>>>>>>
>>>>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>>>>> [ <http://rdf.org/#first> <http://something/>
>>>>>>>>>> ;
>>>>>>>>>> <http://rdf.org/#rest> <
>>>>>>>>>> http://rdf.org/#nil>
>>>>>>>>>> ] ;
>>>>>>>>>> <http://predicate5> "literal3"^^<http://type>
>>>>>>>>>> .
>>>>>>>>>> -- Parsed --
>>>>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>>>>
>>>>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>>>>
>>>>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>>>>> "title"@da ;
>>>>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>>>>> http://object2> .
>>>>>>>>>>
>>>>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>>>>> [ <http://rdf.org/#first> <http://something/>
>>>>>>>>>> ;
>>>>>>>>>> <http://rdf.org/#rest> <
>>>>>>>>>> http://rdf.org/#nil>
>>>>>>>>>> ] ;
>>>>>>>>>> <http://predicate5> "literal3"^^<http://type>
>>>>>>>>>> .
>>>>>>>>>>
>>>>>>>>>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Martynas,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Do you have anything readable?
>>>>>>>>>>>
>>>>>>>>>>> If you write-and-read-back each model do that test isomorphic to
>>>>>>>>>>> themselves? To each other after read-write?
>>>>>>>>>>>
>>>>>>>>>>> Andy
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> I am writing a unit test for an RDF parser:
>>>>>>>>>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>>>>>>>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>>>>>>>>>
>>>>>>>>>>>> I have constructed two Models which only differ in blank nodes,
>>>>>>>>>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>>>>>>>>>
>>>>>>>>>>>> Here are the wanted.toString() and got.toString() output:
>>>>>>>>>>>>
>>>>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>>>>> http://subject3
>>>>>>>>>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>>>>>>>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first
>>>>>>>>>>>> http://something/;
>>>>>>>>>>>> http://subject1 @http://predicate2 http://object3;
>>>>>>>>>>>> http://subject1
>>>>>>>>>>>> @
>>>>>>>>>>>> http://predicate2 http://object2; http://subject1 @
>>>>>>>>>>>> http://predicate1
>>>>>>>>>>>> http://object1; http://subject1 @http://dc.org/#title
>>>>>>>>>>>> "title"@da;
>>>>>>>>>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>>>>> http://predicate3, "literal1"] [http://subject3,
>>>>>>>>>>>> http://predicate4
>>>>>>>>>>>> ,
>>>>>>>>>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>>>>> [b1,
>>>>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>>>>>>>>>> http://predicate2, http://object3] [http://subject1,
>>>>>>>>>>>> http://predicate2,
>>>>>>>>>>>> http://object2] [http://subject1, http://predicate1,
>>>>>>>>>>>> http://object1]
>>>>>>>>>>>> [
>>>>>>>>>>>> http://subject1, http://dc.org/#title, "title"@da] [
>>>>>>>>>>>> http://subject4,
>>>>>>>>>>>> http://dct.org/#hasPart, b1] [http://subject4,
>>>>>>>>>>>> http://predicate5,
>>>>>>>>>>>> "literal3"^^http://type]>
>>>>>>>>>>>>
>>>>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>>>>> http://subject3
>>>>>>>>>>>> @http://predicate4 "literal2"@da; http://subject1 @
>>>>>>>>>>>> http://predicate2
>>>>>>>>>>>> http://object3; http://subject1 @http://predicate2
>>>>>>>>>>>> http://object2;
>>>>>>>>>>>> http://subject1 @http://predicate1 http://object1;
>>>>>>>>>>>> http://subject1
>>>>>>>>>>>> @
>>>>>>>>>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990d
>>>>>>>>>>>> a2
>>>>>>>>>>>> @
>>>>>>>>>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>>>>>>>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>>>>>>>> @
>>>>>>>>>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>>>>>>>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>>>>>>>>>> http://subject4
>>>>>>>>>>>> @
>>>>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>>>>> http://predicate3, "literal1"] [http://subject3,
>>>>>>>>>>>> http://predicate4
>>>>>>>>>>>> ,
>>>>>>>>>>>> "literal2"@da] [http://subject1, http://predicate2,
>>>>>>>>>>>> http://object3]
>>>>>>>>>>>> [
>>>>>>>>>>>> http://subject1, http://predicate2, http://object2] [
>>>>>>>>>>>> http://subject1,
>>>>>>>>>>>> http://predicate1, http://object1] [http://subject1,
>>>>>>>>>>>> http://dc.org/#title
>>>>>>>>>>>> ,
>>>>>>>>>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>>>>> http://rdf.org/#rest,
>>>>>>>>>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>>>>>>>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>>>>>>>>>> http://subject4,
>>>>>>>>>>>> http://predicate5, "literal3"^^http://type]>
>>>>>>>>>>>>
>>>>>>>>>>>> When I sort the triples by the subject, they seem identical to
>>>>>>>>>>>> me,
>>>>>>>>>>>> sans
>>>>>>>>>>>> bnode labels:
>>>>>>>>>>>>
>>>>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>>>>> [b1, http://rdf.org/#first, http://something/]
>>>>>>>>>>>>
>>>>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>>>>> [http://subject4, http://dct.org/#hasPart,
>>>>>>>>>>>> 30b98db4d09af8c4a56f907aec5a53
>>>>>>>>>>>> 48]
>>>>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>>>>>>>>>> http://rdf.org/#nil
>>>>>>>>>>>> ]
>>>>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>>>>>>>>>> http://something/]
>>>>>>>>>>>>
>>>>>>>>>>>> What am I missing here?
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>>
>
Re: [3.0.1] Models (not) isomorphic
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Sorry, my bad - the test actually creates 2 BaseDatatype instances. But if
I change it the following way, and it passes, I guess the parser is OK?
RDFDatatype datatype = new BaseDatatype("http://type");
Model a = ModelFactory.createDefaultModel();
a.add(a.createResource(), a.createProperty("http://predicate"),
a.createTypedLiteral("literal", datatype));
Model b = ModelFactory.createDefaultModel();
b.add(b.createResource(), b.createProperty("http://predicate"),
b.createTypedLiteral("literal", datatype));
assertIsomorphic(a, b);
On Thu, Jan 4, 2018 at 2:53 PM, Andy Seaborne <an...@apache.org> wrote:
> Then trace through and see where the datatype is created.
>
> Works fine on current Jena but then various things have been improved
> since 3.0.1.
>
> Andy
>
>
> On 04/01/18 13:19, Martynas Jusevičius wrote:
>
>> On a second thought, the isomorphism test was for the streaming version
>> which follows bellow in the class and uses methods from ReaderRIOTBase.
>> The
>> datatypes parsing is here:
>> https://github.com/AtomGraph/Core/blob/master/src/main/java/
>> com/atomgraph/core/riot/lang/RDFPostReader.java#L695
>>
>> What is the fix here? Is it RDFPostReader handling the datatype wrong or
>> the ReaderRIOTBase?
>>
>> On Thu, Jan 4, 2018 at 2:14 PM, Martynas Jusevičius <
>> martynas@atomgraph.com>
>> wrote:
>>
>> Thanks, I will :)
>>>
>>> On Thu, Jan 4, 2018 at 2:12 PM, Andy Seaborne <an...@apache.org> wrote:
>>>
>>> Fix RDFPostReader? L201 an L218.
>>>>
>>>>
>>>> On 04/01/18 11:34, Martynas Jusevičius wrote:
>>>>
>>>> Right... I guess for the purposes of the test I'll just use a built-in
>>>>> datatype.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Thu, Jan 4, 2018 at 11:42 AM, Andy Seaborne <an...@apache.org>
>>>>> wrote:
>>>>>
>>>>> Martynas,
>>>>>
>>>>>>
>>>>>> Datatypes need to be registered: The easy way (and the way RIOT
>>>>>> parsers
>>>>>> do
>>>>>> it) is to use getSafeTypeByName which registers and returns an
>>>>>> instance
>>>>>> of
>>>>>> BaseDatatype for unknown datatypes.
>>>>>>
>>>>>> RDFDatatype dt =
>>>>>> TypeMapper.getInstance().getSafeTypeByName("http://type");
>>>>>> ...
>>>>>> a.createTypedLiteral("literal", dt);
>>>>>> ...
>>>>>> b.createTypedLiteral("literal", dt)
>>>>>>
>>>>>> Multiple calls to getSafeTypeByName("http://type") will return the
>>>>>> same
>>>>>> object.
>>>>>>
>>>>>> Andy
>>>>>>
>>>>>> Node n1 = NodeFactory.createLiteral(
>>>>>> "literal", new BaseDatatype("http://type"));
>>>>>> Node n2 = NodeFactory.createLiteral(
>>>>>> "literal", new BaseDatatype("http://type"));
>>>>>> System.out.println(n1.equals(n2));
>>>>>> --> false
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 04/01/18 00:33, Martynas Jusevičius wrote:
>>>>>>
>>>>>> Andy,
>>>>>>
>>>>>>>
>>>>>>> it looks like the new BaseDatetype instance is the culprit. I
>>>>>>> reproduced a
>>>>>>> minimal case - the first test fails, the second one succeeds:
>>>>>>>
>>>>>>> @Test
>>>>>>> public void testIdenticalFails()
>>>>>>> {
>>>>>>> Model a = ModelFactory.createDefaultModel();
>>>>>>> a.add(a.createResource(), a.createProperty("http://predi
>>>>>>> cate
>>>>>>> "),
>>>>>>> a.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>>>> Model b = ModelFactory.createDefaultModel();
>>>>>>> b.add(b.createResource(), b.createProperty("http://predi
>>>>>>> cate
>>>>>>> "),
>>>>>>> b.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>>>> assertIsomorphic(a, b);
>>>>>>> }
>>>>>>>
>>>>>>> @Test
>>>>>>> public void testIdenticalSucceeds()
>>>>>>> {
>>>>>>> Model a = ModelFactory.createDefaultModel();
>>>>>>> a.add(a.createResource(), a.createProperty("http://predi
>>>>>>> cate
>>>>>>> "),
>>>>>>> a.createTypedLiteral("literal", XSDfloat));
>>>>>>> Model b = ModelFactory.createDefaultModel();
>>>>>>> b.add(b.createResource(), b.createProperty("http://predi
>>>>>>> cate
>>>>>>> "),
>>>>>>> b.createTypedLiteral("literal", XSDfloat));
>>>>>>> assertIsomorphic(a, b);
>>>>>>> }
>>>>>>>
>>>>>>> Can you confirm?
>>>>>>>
>>>>>>> On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org>
>>>>>>> wrote:
>>>>>>>
>>>>>>> Can't see anything.
>>>>>>>
>>>>>>>
>>>>>>>> maybe try cutting down the example to the triple(s) that matter?
>>>>>>>> have you checked for upgrading from RDF 1.0?
>>>>>>>>
>>>>>>>> Andy
>>>>>>>>
>>>>>>>>
>>>>>>>> On 03/01/18 17:01, Martynas Jusevičius wrote:
>>>>>>>>
>>>>>>>> System.out.println("-- Expected --");
>>>>>>>>
>>>>>>>> expected.write(System.out, Lang.TURTLE.getName());
>>>>>>>>> System.out.println("-- Parsed --");
>>>>>>>>> parsed.write(System.out, Lang.TURTLE.getName());
>>>>>>>>>
>>>>>>>>> assertIsomorphic(parsed, parsed);
>>>>>>>>> assertIsomorphic(expected, expected);
>>>>>>>>> assertIsomorphic(expected, parsed);
>>>>>>>>>
>>>>>>>>> Two first assertions pass, the third one fails. The output:
>>>>>>>>>
>>>>>>>>> -- Expected --
>>>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>>>
>>>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>>>
>>>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>>>> "title"@da ;
>>>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>>>> http://object2> .
>>>>>>>>>
>>>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>>>> [ <http://rdf.org/#first> <http://something/>
>>>>>>>>> ;
>>>>>>>>> <http://rdf.org/#rest> <
>>>>>>>>> http://rdf.org/#nil>
>>>>>>>>> ] ;
>>>>>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>>>>>> -- Parsed --
>>>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>>>
>>>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>>>
>>>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>>>> "title"@da ;
>>>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>>>> http://object2> .
>>>>>>>>>
>>>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>>>> [ <http://rdf.org/#first> <http://something/>
>>>>>>>>> ;
>>>>>>>>> <http://rdf.org/#rest> <
>>>>>>>>> http://rdf.org/#nil>
>>>>>>>>> ] ;
>>>>>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>>>>>>
>>>>>>>>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Martynas,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Do you have anything readable?
>>>>>>>>>>
>>>>>>>>>> If you write-and-read-back each model do that test isomorphic to
>>>>>>>>>> themselves? To each other after read-write?
>>>>>>>>>>
>>>>>>>>>> Andy
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I am writing a unit test for an RDF parser:
>>>>>>>>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>>>>>>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>>>>>>>>
>>>>>>>>>>> I have constructed two Models which only differ in blank nodes,
>>>>>>>>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>>>>>>>>
>>>>>>>>>>> Here are the wanted.toString() and got.toString() output:
>>>>>>>>>>>
>>>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>>>> http://subject3
>>>>>>>>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>>>>>>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/
>>>>>>>>>>> ;
>>>>>>>>>>> http://subject1 @http://predicate2 http://object3;
>>>>>>>>>>> http://subject1
>>>>>>>>>>> @
>>>>>>>>>>> http://predicate2 http://object2; http://subject1 @
>>>>>>>>>>> http://predicate1
>>>>>>>>>>> http://object1; http://subject1 @http://dc.org/#title
>>>>>>>>>>> "title"@da;
>>>>>>>>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>>>> http://predicate3, "literal1"] [http://subject3,
>>>>>>>>>>> http://predicate4
>>>>>>>>>>> ,
>>>>>>>>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>>>> [b1,
>>>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>>>>>>>>> http://predicate2, http://object3] [http://subject1,
>>>>>>>>>>> http://predicate2,
>>>>>>>>>>> http://object2] [http://subject1, http://predicate1,
>>>>>>>>>>> http://object1]
>>>>>>>>>>> [
>>>>>>>>>>> http://subject1, http://dc.org/#title, "title"@da] [
>>>>>>>>>>> http://subject4,
>>>>>>>>>>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5
>>>>>>>>>>> ,
>>>>>>>>>>> "literal3"^^http://type]>
>>>>>>>>>>>
>>>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>>>> http://subject3
>>>>>>>>>>> @http://predicate4 "literal2"@da; http://subject1 @
>>>>>>>>>>> http://predicate2
>>>>>>>>>>> http://object3; http://subject1 @http://predicate2
>>>>>>>>>>> http://object2;
>>>>>>>>>>> http://subject1 @http://predicate1 http://object1;
>>>>>>>>>>> http://subject1
>>>>>>>>>>> @
>>>>>>>>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990d
>>>>>>>>>>> a2
>>>>>>>>>>> @
>>>>>>>>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>>>>>>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>>>>>>> @
>>>>>>>>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>>>>>>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>>>>>>>>> http://subject4
>>>>>>>>>>> @
>>>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>>>> http://predicate3, "literal1"] [http://subject3,
>>>>>>>>>>> http://predicate4
>>>>>>>>>>> ,
>>>>>>>>>>> "literal2"@da] [http://subject1, http://predicate2,
>>>>>>>>>>> http://object3]
>>>>>>>>>>> [
>>>>>>>>>>> http://subject1, http://predicate2, http://object2] [
>>>>>>>>>>> http://subject1,
>>>>>>>>>>> http://predicate1, http://object1] [http://subject1,
>>>>>>>>>>> http://dc.org/#title
>>>>>>>>>>> ,
>>>>>>>>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>>>> http://rdf.org/#rest,
>>>>>>>>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>>>>>>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>>>>>>>>> http://subject4,
>>>>>>>>>>> http://predicate5, "literal3"^^http://type]>
>>>>>>>>>>>
>>>>>>>>>>> When I sort the triples by the subject, they seem identical to
>>>>>>>>>>> me,
>>>>>>>>>>> sans
>>>>>>>>>>> bnode labels:
>>>>>>>>>>>
>>>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>>>> [b1, http://rdf.org/#first, http://something/]
>>>>>>>>>>>
>>>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>>>> [http://subject4, http://dct.org/#hasPart,
>>>>>>>>>>> 30b98db4d09af8c4a56f907aec5a53
>>>>>>>>>>> 48]
>>>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>>>>>>>>> http://rdf.org/#nil
>>>>>>>>>>> ]
>>>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>>>>>>>>> http://something/]
>>>>>>>>>>>
>>>>>>>>>>> What am I missing here?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>
>>>
>>
Re: [3.0.1] Models (not) isomorphic
Posted by Andy Seaborne <an...@apache.org>.
Then trace through and see where the datatype is created.
Works fine on current Jena but then various things have been improved
since 3.0.1.
Andy
On 04/01/18 13:19, Martynas Jusevičius wrote:
> On a second thought, the isomorphism test was for the streaming version
> which follows bellow in the class and uses methods from ReaderRIOTBase. The
> datatypes parsing is here:
> https://github.com/AtomGraph/Core/blob/master/src/main/java/com/atomgraph/core/riot/lang/RDFPostReader.java#L695
>
> What is the fix here? Is it RDFPostReader handling the datatype wrong or
> the ReaderRIOTBase?
>
> On Thu, Jan 4, 2018 at 2:14 PM, Martynas Jusevičius <ma...@atomgraph.com>
> wrote:
>
>> Thanks, I will :)
>>
>> On Thu, Jan 4, 2018 at 2:12 PM, Andy Seaborne <an...@apache.org> wrote:
>>
>>> Fix RDFPostReader? L201 an L218.
>>>
>>>
>>> On 04/01/18 11:34, Martynas Jusevičius wrote:
>>>
>>>> Right... I guess for the purposes of the test I'll just use a built-in
>>>> datatype.
>>>>
>>>> Thanks.
>>>>
>>>> On Thu, Jan 4, 2018 at 11:42 AM, Andy Seaborne <an...@apache.org> wrote:
>>>>
>>>> Martynas,
>>>>>
>>>>> Datatypes need to be registered: The easy way (and the way RIOT parsers
>>>>> do
>>>>> it) is to use getSafeTypeByName which registers and returns an instance
>>>>> of
>>>>> BaseDatatype for unknown datatypes.
>>>>>
>>>>> RDFDatatype dt =
>>>>> TypeMapper.getInstance().getSafeTypeByName("http://type");
>>>>> ...
>>>>> a.createTypedLiteral("literal", dt);
>>>>> ...
>>>>> b.createTypedLiteral("literal", dt)
>>>>>
>>>>> Multiple calls to getSafeTypeByName("http://type") will return the same
>>>>> object.
>>>>>
>>>>> Andy
>>>>>
>>>>> Node n1 = NodeFactory.createLiteral(
>>>>> "literal", new BaseDatatype("http://type"));
>>>>> Node n2 = NodeFactory.createLiteral(
>>>>> "literal", new BaseDatatype("http://type"));
>>>>> System.out.println(n1.equals(n2));
>>>>> --> false
>>>>>
>>>>>
>>>>>
>>>>> On 04/01/18 00:33, Martynas Jusevičius wrote:
>>>>>
>>>>> Andy,
>>>>>>
>>>>>> it looks like the new BaseDatetype instance is the culprit. I
>>>>>> reproduced a
>>>>>> minimal case - the first test fails, the second one succeeds:
>>>>>>
>>>>>> @Test
>>>>>> public void testIdenticalFails()
>>>>>> {
>>>>>> Model a = ModelFactory.createDefaultModel();
>>>>>> a.add(a.createResource(), a.createProperty("http://predicate
>>>>>> "),
>>>>>> a.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>>> Model b = ModelFactory.createDefaultModel();
>>>>>> b.add(b.createResource(), b.createProperty("http://predicate
>>>>>> "),
>>>>>> b.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>>> assertIsomorphic(a, b);
>>>>>> }
>>>>>>
>>>>>> @Test
>>>>>> public void testIdenticalSucceeds()
>>>>>> {
>>>>>> Model a = ModelFactory.createDefaultModel();
>>>>>> a.add(a.createResource(), a.createProperty("http://predicate
>>>>>> "),
>>>>>> a.createTypedLiteral("literal", XSDfloat));
>>>>>> Model b = ModelFactory.createDefaultModel();
>>>>>> b.add(b.createResource(), b.createProperty("http://predicate
>>>>>> "),
>>>>>> b.createTypedLiteral("literal", XSDfloat));
>>>>>> assertIsomorphic(a, b);
>>>>>> }
>>>>>>
>>>>>> Can you confirm?
>>>>>>
>>>>>> On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org> wrote:
>>>>>>
>>>>>> Can't see anything.
>>>>>>
>>>>>>>
>>>>>>> maybe try cutting down the example to the triple(s) that matter?
>>>>>>> have you checked for upgrading from RDF 1.0?
>>>>>>>
>>>>>>> Andy
>>>>>>>
>>>>>>>
>>>>>>> On 03/01/18 17:01, Martynas Jusevičius wrote:
>>>>>>>
>>>>>>> System.out.println("-- Expected --");
>>>>>>>
>>>>>>>> expected.write(System.out, Lang.TURTLE.getName());
>>>>>>>> System.out.println("-- Parsed --");
>>>>>>>> parsed.write(System.out, Lang.TURTLE.getName());
>>>>>>>>
>>>>>>>> assertIsomorphic(parsed, parsed);
>>>>>>>> assertIsomorphic(expected, expected);
>>>>>>>> assertIsomorphic(expected, parsed);
>>>>>>>>
>>>>>>>> Two first assertions pass, the third one fails. The output:
>>>>>>>>
>>>>>>>> -- Expected --
>>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>>
>>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>>
>>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>>> "title"@da ;
>>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>>> http://object2> .
>>>>>>>>
>>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>>>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>>>>>> ] ;
>>>>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>>>>> -- Parsed --
>>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>>
>>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>>
>>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>>> "title"@da ;
>>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>>> http://object2> .
>>>>>>>>
>>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>>>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>>>>>> ] ;
>>>>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>>>>>
>>>>>>>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Martynas,
>>>>>>>>
>>>>>>>>
>>>>>>>>> Do you have anything readable?
>>>>>>>>>
>>>>>>>>> If you write-and-read-back each model do that test isomorphic to
>>>>>>>>> themselves? To each other after read-write?
>>>>>>>>>
>>>>>>>>> Andy
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> I am writing a unit test for an RDF parser:
>>>>>>>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>>>>>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>>>>>>>
>>>>>>>>>> I have constructed two Models which only differ in blank nodes,
>>>>>>>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>>>>>>>
>>>>>>>>>> Here are the wanted.toString() and got.toString() output:
>>>>>>>>>>
>>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>>> http://subject3
>>>>>>>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>>>>>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
>>>>>>>>>> http://subject1 @http://predicate2 http://object3; http://subject1
>>>>>>>>>> @
>>>>>>>>>> http://predicate2 http://object2; http://subject1 @
>>>>>>>>>> http://predicate1
>>>>>>>>>> http://object1; http://subject1 @http://dc.org/#title "title"@da;
>>>>>>>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4
>>>>>>>>>> ,
>>>>>>>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>>> [b1,
>>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>>>>>>>> http://predicate2, http://object3] [http://subject1,
>>>>>>>>>> http://predicate2,
>>>>>>>>>> http://object2] [http://subject1, http://predicate1,
>>>>>>>>>> http://object1]
>>>>>>>>>> [
>>>>>>>>>> http://subject1, http://dc.org/#title, "title"@da] [
>>>>>>>>>> http://subject4,
>>>>>>>>>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
>>>>>>>>>> "literal3"^^http://type]>
>>>>>>>>>>
>>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>>> http://subject3
>>>>>>>>>> @http://predicate4 "literal2"@da; http://subject1 @
>>>>>>>>>> http://predicate2
>>>>>>>>>> http://object3; http://subject1 @http://predicate2 http://object2;
>>>>>>>>>> http://subject1 @http://predicate1 http://object1; http://subject1
>>>>>>>>>> @
>>>>>>>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>>>>>> @
>>>>>>>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>>>>>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>>>>>> @
>>>>>>>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>>>>>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>>>>>>>> http://subject4
>>>>>>>>>> @
>>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4
>>>>>>>>>> ,
>>>>>>>>>> "literal2"@da] [http://subject1, http://predicate2, http://object3]
>>>>>>>>>> [
>>>>>>>>>> http://subject1, http://predicate2, http://object2] [
>>>>>>>>>> http://subject1,
>>>>>>>>>> http://predicate1, http://object1] [http://subject1,
>>>>>>>>>> http://dc.org/#title
>>>>>>>>>> ,
>>>>>>>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>>> http://rdf.org/#rest,
>>>>>>>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>>>>>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>>>>>>>> http://subject4,
>>>>>>>>>> http://predicate5, "literal3"^^http://type]>
>>>>>>>>>>
>>>>>>>>>> When I sort the triples by the subject, they seem identical to me,
>>>>>>>>>> sans
>>>>>>>>>> bnode labels:
>>>>>>>>>>
>>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>>> [b1, http://rdf.org/#first, http://something/]
>>>>>>>>>>
>>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>>> [http://subject4, http://dct.org/#hasPart,
>>>>>>>>>> 30b98db4d09af8c4a56f907aec5a53
>>>>>>>>>> 48]
>>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>>>>>>>> http://rdf.org/#nil
>>>>>>>>>> ]
>>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>>>>>>>> http://something/]
>>>>>>>>>>
>>>>>>>>>> What am I missing here?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
>
Re: [3.0.1] Models (not) isomorphic
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
On a second thought, the isomorphism test was for the streaming version
which follows bellow in the class and uses methods from ReaderRIOTBase. The
datatypes parsing is here:
https://github.com/AtomGraph/Core/blob/master/src/main/java/com/atomgraph/core/riot/lang/RDFPostReader.java#L695
What is the fix here? Is it RDFPostReader handling the datatype wrong or
the ReaderRIOTBase?
On Thu, Jan 4, 2018 at 2:14 PM, Martynas Jusevičius <ma...@atomgraph.com>
wrote:
> Thanks, I will :)
>
> On Thu, Jan 4, 2018 at 2:12 PM, Andy Seaborne <an...@apache.org> wrote:
>
>> Fix RDFPostReader? L201 an L218.
>>
>>
>> On 04/01/18 11:34, Martynas Jusevičius wrote:
>>
>>> Right... I guess for the purposes of the test I'll just use a built-in
>>> datatype.
>>>
>>> Thanks.
>>>
>>> On Thu, Jan 4, 2018 at 11:42 AM, Andy Seaborne <an...@apache.org> wrote:
>>>
>>> Martynas,
>>>>
>>>> Datatypes need to be registered: The easy way (and the way RIOT parsers
>>>> do
>>>> it) is to use getSafeTypeByName which registers and returns an instance
>>>> of
>>>> BaseDatatype for unknown datatypes.
>>>>
>>>> RDFDatatype dt =
>>>> TypeMapper.getInstance().getSafeTypeByName("http://type");
>>>> ...
>>>> a.createTypedLiteral("literal", dt);
>>>> ...
>>>> b.createTypedLiteral("literal", dt)
>>>>
>>>> Multiple calls to getSafeTypeByName("http://type") will return the same
>>>> object.
>>>>
>>>> Andy
>>>>
>>>> Node n1 = NodeFactory.createLiteral(
>>>> "literal", new BaseDatatype("http://type"));
>>>> Node n2 = NodeFactory.createLiteral(
>>>> "literal", new BaseDatatype("http://type"));
>>>> System.out.println(n1.equals(n2));
>>>> --> false
>>>>
>>>>
>>>>
>>>> On 04/01/18 00:33, Martynas Jusevičius wrote:
>>>>
>>>> Andy,
>>>>>
>>>>> it looks like the new BaseDatetype instance is the culprit. I
>>>>> reproduced a
>>>>> minimal case - the first test fails, the second one succeeds:
>>>>>
>>>>> @Test
>>>>> public void testIdenticalFails()
>>>>> {
>>>>> Model a = ModelFactory.createDefaultModel();
>>>>> a.add(a.createResource(), a.createProperty("http://predicate
>>>>> "),
>>>>> a.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>> Model b = ModelFactory.createDefaultModel();
>>>>> b.add(b.createResource(), b.createProperty("http://predicate
>>>>> "),
>>>>> b.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>>> assertIsomorphic(a, b);
>>>>> }
>>>>>
>>>>> @Test
>>>>> public void testIdenticalSucceeds()
>>>>> {
>>>>> Model a = ModelFactory.createDefaultModel();
>>>>> a.add(a.createResource(), a.createProperty("http://predicate
>>>>> "),
>>>>> a.createTypedLiteral("literal", XSDfloat));
>>>>> Model b = ModelFactory.createDefaultModel();
>>>>> b.add(b.createResource(), b.createProperty("http://predicate
>>>>> "),
>>>>> b.createTypedLiteral("literal", XSDfloat));
>>>>> assertIsomorphic(a, b);
>>>>> }
>>>>>
>>>>> Can you confirm?
>>>>>
>>>>> On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org> wrote:
>>>>>
>>>>> Can't see anything.
>>>>>
>>>>>>
>>>>>> maybe try cutting down the example to the triple(s) that matter?
>>>>>> have you checked for upgrading from RDF 1.0?
>>>>>>
>>>>>> Andy
>>>>>>
>>>>>>
>>>>>> On 03/01/18 17:01, Martynas Jusevičius wrote:
>>>>>>
>>>>>> System.out.println("-- Expected --");
>>>>>>
>>>>>>> expected.write(System.out, Lang.TURTLE.getName());
>>>>>>> System.out.println("-- Parsed --");
>>>>>>> parsed.write(System.out, Lang.TURTLE.getName());
>>>>>>>
>>>>>>> assertIsomorphic(parsed, parsed);
>>>>>>> assertIsomorphic(expected, expected);
>>>>>>> assertIsomorphic(expected, parsed);
>>>>>>>
>>>>>>> Two first assertions pass, the third one fails. The output:
>>>>>>>
>>>>>>> -- Expected --
>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>
>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>
>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>> "title"@da ;
>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>> http://object2> .
>>>>>>>
>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>>>>> ] ;
>>>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>>>> -- Parsed --
>>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>>
>>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>>
>>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>>> "title"@da ;
>>>>>>> <http://predicate1> <http://object1> ;
>>>>>>> <http://predicate2> <http://object3> , <
>>>>>>> http://object2> .
>>>>>>>
>>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>>>>> ] ;
>>>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>>>>
>>>>>>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org>
>>>>>>> wrote:
>>>>>>>
>>>>>>> Martynas,
>>>>>>>
>>>>>>>
>>>>>>>> Do you have anything readable?
>>>>>>>>
>>>>>>>> If you write-and-read-back each model do that test isomorphic to
>>>>>>>> themselves? To each other after read-write?
>>>>>>>>
>>>>>>>> Andy
>>>>>>>>
>>>>>>>>
>>>>>>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>>
>>>>>>>>> I am writing a unit test for an RDF parser:
>>>>>>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>>>>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>>>>>>
>>>>>>>>> I have constructed two Models which only differ in blank nodes,
>>>>>>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>>>>>>
>>>>>>>>> Here are the wanted.toString() and got.toString() output:
>>>>>>>>>
>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>> http://subject3
>>>>>>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>>>>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
>>>>>>>>> http://subject1 @http://predicate2 http://object3; http://subject1
>>>>>>>>> @
>>>>>>>>> http://predicate2 http://object2; http://subject1 @
>>>>>>>>> http://predicate1
>>>>>>>>> http://object1; http://subject1 @http://dc.org/#title "title"@da;
>>>>>>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4
>>>>>>>>> ,
>>>>>>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>> [b1,
>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>>>>>>> http://predicate2, http://object3] [http://subject1,
>>>>>>>>> http://predicate2,
>>>>>>>>> http://object2] [http://subject1, http://predicate1,
>>>>>>>>> http://object1]
>>>>>>>>> [
>>>>>>>>> http://subject1, http://dc.org/#title, "title"@da] [
>>>>>>>>> http://subject4,
>>>>>>>>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
>>>>>>>>> "literal3"^^http://type]>
>>>>>>>>>
>>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>>> http://subject3
>>>>>>>>> @http://predicate4 "literal2"@da; http://subject1 @
>>>>>>>>> http://predicate2
>>>>>>>>> http://object3; http://subject1 @http://predicate2 http://object2;
>>>>>>>>> http://subject1 @http://predicate1 http://object1; http://subject1
>>>>>>>>> @
>>>>>>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>>>>> @
>>>>>>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>>>>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>>>>> @
>>>>>>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>>>>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>>>>>>> http://subject4
>>>>>>>>> @
>>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4
>>>>>>>>> ,
>>>>>>>>> "literal2"@da] [http://subject1, http://predicate2, http://object3]
>>>>>>>>> [
>>>>>>>>> http://subject1, http://predicate2, http://object2] [
>>>>>>>>> http://subject1,
>>>>>>>>> http://predicate1, http://object1] [http://subject1,
>>>>>>>>> http://dc.org/#title
>>>>>>>>> ,
>>>>>>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>> http://rdf.org/#rest,
>>>>>>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>>>>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>>>>>>> http://subject4,
>>>>>>>>> http://predicate5, "literal3"^^http://type]>
>>>>>>>>>
>>>>>>>>> When I sort the triples by the subject, they seem identical to me,
>>>>>>>>> sans
>>>>>>>>> bnode labels:
>>>>>>>>>
>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>>> [b1, http://rdf.org/#first, http://something/]
>>>>>>>>>
>>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>>> [http://subject4, http://dct.org/#hasPart,
>>>>>>>>> 30b98db4d09af8c4a56f907aec5a53
>>>>>>>>> 48]
>>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>>>>>>> http://rdf.org/#nil
>>>>>>>>> ]
>>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>>>>>>> http://something/]
>>>>>>>>>
>>>>>>>>> What am I missing here?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>
>>>
>
Re: [3.0.1] Models (not) isomorphic
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Thanks, I will :)
On Thu, Jan 4, 2018 at 2:12 PM, Andy Seaborne <an...@apache.org> wrote:
> Fix RDFPostReader? L201 an L218.
>
>
> On 04/01/18 11:34, Martynas Jusevičius wrote:
>
>> Right... I guess for the purposes of the test I'll just use a built-in
>> datatype.
>>
>> Thanks.
>>
>> On Thu, Jan 4, 2018 at 11:42 AM, Andy Seaborne <an...@apache.org> wrote:
>>
>> Martynas,
>>>
>>> Datatypes need to be registered: The easy way (and the way RIOT parsers
>>> do
>>> it) is to use getSafeTypeByName which registers and returns an instance
>>> of
>>> BaseDatatype for unknown datatypes.
>>>
>>> RDFDatatype dt =
>>> TypeMapper.getInstance().getSafeTypeByName("http://type");
>>> ...
>>> a.createTypedLiteral("literal", dt);
>>> ...
>>> b.createTypedLiteral("literal", dt)
>>>
>>> Multiple calls to getSafeTypeByName("http://type") will return the same
>>> object.
>>>
>>> Andy
>>>
>>> Node n1 = NodeFactory.createLiteral(
>>> "literal", new BaseDatatype("http://type"));
>>> Node n2 = NodeFactory.createLiteral(
>>> "literal", new BaseDatatype("http://type"));
>>> System.out.println(n1.equals(n2));
>>> --> false
>>>
>>>
>>>
>>> On 04/01/18 00:33, Martynas Jusevičius wrote:
>>>
>>> Andy,
>>>>
>>>> it looks like the new BaseDatetype instance is the culprit. I
>>>> reproduced a
>>>> minimal case - the first test fails, the second one succeeds:
>>>>
>>>> @Test
>>>> public void testIdenticalFails()
>>>> {
>>>> Model a = ModelFactory.createDefaultModel();
>>>> a.add(a.createResource(), a.createProperty("http://predicate
>>>> "),
>>>> a.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>> Model b = ModelFactory.createDefaultModel();
>>>> b.add(b.createResource(), b.createProperty("http://predicate
>>>> "),
>>>> b.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>>> assertIsomorphic(a, b);
>>>> }
>>>>
>>>> @Test
>>>> public void testIdenticalSucceeds()
>>>> {
>>>> Model a = ModelFactory.createDefaultModel();
>>>> a.add(a.createResource(), a.createProperty("http://predicate
>>>> "),
>>>> a.createTypedLiteral("literal", XSDfloat));
>>>> Model b = ModelFactory.createDefaultModel();
>>>> b.add(b.createResource(), b.createProperty("http://predicate
>>>> "),
>>>> b.createTypedLiteral("literal", XSDfloat));
>>>> assertIsomorphic(a, b);
>>>> }
>>>>
>>>> Can you confirm?
>>>>
>>>> On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org> wrote:
>>>>
>>>> Can't see anything.
>>>>
>>>>>
>>>>> maybe try cutting down the example to the triple(s) that matter?
>>>>> have you checked for upgrading from RDF 1.0?
>>>>>
>>>>> Andy
>>>>>
>>>>>
>>>>> On 03/01/18 17:01, Martynas Jusevičius wrote:
>>>>>
>>>>> System.out.println("-- Expected --");
>>>>>
>>>>>> expected.write(System.out, Lang.TURTLE.getName());
>>>>>> System.out.println("-- Parsed --");
>>>>>> parsed.write(System.out, Lang.TURTLE.getName());
>>>>>>
>>>>>> assertIsomorphic(parsed, parsed);
>>>>>> assertIsomorphic(expected, expected);
>>>>>> assertIsomorphic(expected, parsed);
>>>>>>
>>>>>> Two first assertions pass, the third one fails. The output:
>>>>>>
>>>>>> -- Expected --
>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>
>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>
>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>> "title"@da ;
>>>>>> <http://predicate1> <http://object1> ;
>>>>>> <http://predicate2> <http://object3> , <http://object2>
>>>>>> .
>>>>>>
>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>>>> ] ;
>>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>>> -- Parsed --
>>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>>
>>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>>
>>>>>> <http://subject1> <http://dc.org/#title>
>>>>>> "title"@da ;
>>>>>> <http://predicate1> <http://object1> ;
>>>>>> <http://predicate2> <http://object3> , <http://object2>
>>>>>> .
>>>>>>
>>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>>>> ] ;
>>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>>>
>>>>>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org>
>>>>>> wrote:
>>>>>>
>>>>>> Martynas,
>>>>>>
>>>>>>
>>>>>>> Do you have anything readable?
>>>>>>>
>>>>>>> If you write-and-read-back each model do that test isomorphic to
>>>>>>> themselves? To each other after read-write?
>>>>>>>
>>>>>>> Andy
>>>>>>>
>>>>>>>
>>>>>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>>
>>>>>>>> I am writing a unit test for an RDF parser:
>>>>>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>>>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>>>>>
>>>>>>>> I have constructed two Models which only differ in blank nodes,
>>>>>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>>>>>
>>>>>>>> Here are the wanted.toString() and got.toString() output:
>>>>>>>>
>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>> http://subject3
>>>>>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>>>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
>>>>>>>> http://subject1 @http://predicate2 http://object3; http://subject1
>>>>>>>> @
>>>>>>>> http://predicate2 http://object2; http://subject1 @
>>>>>>>> http://predicate1
>>>>>>>> http://object1; http://subject1 @http://dc.org/#title "title"@da;
>>>>>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>>>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil] [b1,
>>>>>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>>>>>> http://predicate2, http://object3] [http://subject1,
>>>>>>>> http://predicate2,
>>>>>>>> http://object2] [http://subject1, http://predicate1, http://object1
>>>>>>>> ]
>>>>>>>> [
>>>>>>>> http://subject1, http://dc.org/#title, "title"@da] [http://subject4
>>>>>>>> ,
>>>>>>>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
>>>>>>>> "literal3"^^http://type]>
>>>>>>>>
>>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>>> http://subject3
>>>>>>>> @http://predicate4 "literal2"@da; http://subject1 @
>>>>>>>> http://predicate2
>>>>>>>> http://object3; http://subject1 @http://predicate2 http://object2;
>>>>>>>> http://subject1 @http://predicate1 http://object1; http://subject1
>>>>>>>> @
>>>>>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2 @
>>>>>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>>>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>>>> @
>>>>>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>>>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>>>>>> http://subject4
>>>>>>>> @
>>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>>>>>> "literal2"@da] [http://subject1, http://predicate2, http://object3]
>>>>>>>> [
>>>>>>>> http://subject1, http://predicate2, http://object2] [
>>>>>>>> http://subject1,
>>>>>>>> http://predicate1, http://object1] [http://subject1,
>>>>>>>> http://dc.org/#title
>>>>>>>> ,
>>>>>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2, http://rdf.org/#rest
>>>>>>>> ,
>>>>>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>>>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>>>>>> http://subject4,
>>>>>>>> http://predicate5, "literal3"^^http://type]>
>>>>>>>>
>>>>>>>> When I sort the triples by the subject, they seem identical to me,
>>>>>>>> sans
>>>>>>>> bnode labels:
>>>>>>>>
>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>>> [b1, http://rdf.org/#first, http://something/]
>>>>>>>>
>>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>>> [http://subject4, http://dct.org/#hasPart,
>>>>>>>> 30b98db4d09af8c4a56f907aec5a53
>>>>>>>> 48]
>>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>>>>>> http://rdf.org/#nil
>>>>>>>> ]
>>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>>>>>> http://something/]
>>>>>>>>
>>>>>>>> What am I missing here?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
Re: [3.0.1] Models (not) isomorphic
Posted by Andy Seaborne <an...@apache.org>.
Fix RDFPostReader? L201 an L218.
On 04/01/18 11:34, Martynas Jusevičius wrote:
> Right... I guess for the purposes of the test I'll just use a built-in
> datatype.
>
> Thanks.
>
> On Thu, Jan 4, 2018 at 11:42 AM, Andy Seaborne <an...@apache.org> wrote:
>
>> Martynas,
>>
>> Datatypes need to be registered: The easy way (and the way RIOT parsers do
>> it) is to use getSafeTypeByName which registers and returns an instance of
>> BaseDatatype for unknown datatypes.
>>
>> RDFDatatype dt =
>> TypeMapper.getInstance().getSafeTypeByName("http://type");
>> ...
>> a.createTypedLiteral("literal", dt);
>> ...
>> b.createTypedLiteral("literal", dt)
>>
>> Multiple calls to getSafeTypeByName("http://type") will return the same
>> object.
>>
>> Andy
>>
>> Node n1 = NodeFactory.createLiteral(
>> "literal", new BaseDatatype("http://type"));
>> Node n2 = NodeFactory.createLiteral(
>> "literal", new BaseDatatype("http://type"));
>> System.out.println(n1.equals(n2));
>> --> false
>>
>>
>>
>> On 04/01/18 00:33, Martynas Jusevičius wrote:
>>
>>> Andy,
>>>
>>> it looks like the new BaseDatetype instance is the culprit. I reproduced a
>>> minimal case - the first test fails, the second one succeeds:
>>>
>>> @Test
>>> public void testIdenticalFails()
>>> {
>>> Model a = ModelFactory.createDefaultModel();
>>> a.add(a.createResource(), a.createProperty("http://predicate"),
>>> a.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>> Model b = ModelFactory.createDefaultModel();
>>> b.add(b.createResource(), b.createProperty("http://predicate"),
>>> b.createTypedLiteral("literal", new BaseDatatype("http://type")));
>>> assertIsomorphic(a, b);
>>> }
>>>
>>> @Test
>>> public void testIdenticalSucceeds()
>>> {
>>> Model a = ModelFactory.createDefaultModel();
>>> a.add(a.createResource(), a.createProperty("http://predicate"),
>>> a.createTypedLiteral("literal", XSDfloat));
>>> Model b = ModelFactory.createDefaultModel();
>>> b.add(b.createResource(), b.createProperty("http://predicate"),
>>> b.createTypedLiteral("literal", XSDfloat));
>>> assertIsomorphic(a, b);
>>> }
>>>
>>> Can you confirm?
>>>
>>> On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org> wrote:
>>>
>>> Can't see anything.
>>>>
>>>> maybe try cutting down the example to the triple(s) that matter?
>>>> have you checked for upgrading from RDF 1.0?
>>>>
>>>> Andy
>>>>
>>>>
>>>> On 03/01/18 17:01, Martynas Jusevičius wrote:
>>>>
>>>> System.out.println("-- Expected --");
>>>>> expected.write(System.out, Lang.TURTLE.getName());
>>>>> System.out.println("-- Parsed --");
>>>>> parsed.write(System.out, Lang.TURTLE.getName());
>>>>>
>>>>> assertIsomorphic(parsed, parsed);
>>>>> assertIsomorphic(expected, expected);
>>>>> assertIsomorphic(expected, parsed);
>>>>>
>>>>> Two first assertions pass, the third one fails. The output:
>>>>>
>>>>> -- Expected --
>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>
>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>
>>>>> <http://subject1> <http://dc.org/#title>
>>>>> "title"@da ;
>>>>> <http://predicate1> <http://object1> ;
>>>>> <http://predicate2> <http://object3> , <http://object2> .
>>>>>
>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>>> ] ;
>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>> -- Parsed --
>>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>>
>>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>>
>>>>> <http://subject1> <http://dc.org/#title>
>>>>> "title"@da ;
>>>>> <http://predicate1> <http://object1> ;
>>>>> <http://predicate2> <http://object3> , <http://object2> .
>>>>>
>>>>> <http://subject4> <http://dct.org/#hasPart>
>>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>>> ] ;
>>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>>
>>>>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org> wrote:
>>>>>
>>>>> Martynas,
>>>>>
>>>>>>
>>>>>> Do you have anything readable?
>>>>>>
>>>>>> If you write-and-read-back each model do that test isomorphic to
>>>>>> themselves? To each other after read-write?
>>>>>>
>>>>>> Andy
>>>>>>
>>>>>>
>>>>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>>>
>>>>>>> I am writing a unit test for an RDF parser:
>>>>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>>>>
>>>>>>> I have constructed two Models which only differ in blank nodes,
>>>>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>>>>
>>>>>>> Here are the wanted.toString() and got.toString() output:
>>>>>>>
>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>> http://subject3
>>>>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
>>>>>>> http://subject1 @http://predicate2 http://object3; http://subject1 @
>>>>>>> http://predicate2 http://object2; http://subject1 @http://predicate1
>>>>>>> http://object1; http://subject1 @http://dc.org/#title "title"@da;
>>>>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil] [b1,
>>>>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>>>>> http://predicate2, http://object3] [http://subject1,
>>>>>>> http://predicate2,
>>>>>>> http://object2] [http://subject1, http://predicate1, http://object1]
>>>>>>> [
>>>>>>> http://subject1, http://dc.org/#title, "title"@da] [http://subject4,
>>>>>>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
>>>>>>> "literal3"^^http://type]>
>>>>>>>
>>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>>> http://subject3
>>>>>>> @http://predicate4 "literal2"@da; http://subject1 @http://predicate2
>>>>>>> http://object3; http://subject1 @http://predicate2 http://object2;
>>>>>>> http://subject1 @http://predicate1 http://object1; http://subject1 @
>>>>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2 @
>>>>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>>> @
>>>>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>>>>> http://subject4
>>>>>>> @
>>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>>>>> "literal2"@da] [http://subject1, http://predicate2, http://object3] [
>>>>>>> http://subject1, http://predicate2, http://object2] [http://subject1,
>>>>>>> http://predicate1, http://object1] [http://subject1,
>>>>>>> http://dc.org/#title
>>>>>>> ,
>>>>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2, http://rdf.org/#rest,
>>>>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>>>>> http://subject4,
>>>>>>> http://predicate5, "literal3"^^http://type]>
>>>>>>>
>>>>>>> When I sort the triples by the subject, they seem identical to me,
>>>>>>> sans
>>>>>>> bnode labels:
>>>>>>>
>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>>> [b1, http://rdf.org/#first, http://something/]
>>>>>>>
>>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>>> [http://subject4, http://dct.org/#hasPart,
>>>>>>> 30b98db4d09af8c4a56f907aec5a53
>>>>>>> 48]
>>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>>>>> http://rdf.org/#nil
>>>>>>> ]
>>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>>>>> http://something/]
>>>>>>>
>>>>>>> What am I missing here?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>
>
Re: [3.0.1] Models (not) isomorphic
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Right... I guess for the purposes of the test I'll just use a built-in
datatype.
Thanks.
On Thu, Jan 4, 2018 at 11:42 AM, Andy Seaborne <an...@apache.org> wrote:
> Martynas,
>
> Datatypes need to be registered: The easy way (and the way RIOT parsers do
> it) is to use getSafeTypeByName which registers and returns an instance of
> BaseDatatype for unknown datatypes.
>
> RDFDatatype dt =
> TypeMapper.getInstance().getSafeTypeByName("http://type");
> ...
> a.createTypedLiteral("literal", dt);
> ...
> b.createTypedLiteral("literal", dt)
>
> Multiple calls to getSafeTypeByName("http://type") will return the same
> object.
>
> Andy
>
> Node n1 = NodeFactory.createLiteral(
> "literal", new BaseDatatype("http://type"));
> Node n2 = NodeFactory.createLiteral(
> "literal", new BaseDatatype("http://type"));
> System.out.println(n1.equals(n2));
> --> false
>
>
>
> On 04/01/18 00:33, Martynas Jusevičius wrote:
>
>> Andy,
>>
>> it looks like the new BaseDatetype instance is the culprit. I reproduced a
>> minimal case - the first test fails, the second one succeeds:
>>
>> @Test
>> public void testIdenticalFails()
>> {
>> Model a = ModelFactory.createDefaultModel();
>> a.add(a.createResource(), a.createProperty("http://predicate"),
>> a.createTypedLiteral("literal", new BaseDatatype("http://type")));
>> Model b = ModelFactory.createDefaultModel();
>> b.add(b.createResource(), b.createProperty("http://predicate"),
>> b.createTypedLiteral("literal", new BaseDatatype("http://type")));
>> assertIsomorphic(a, b);
>> }
>>
>> @Test
>> public void testIdenticalSucceeds()
>> {
>> Model a = ModelFactory.createDefaultModel();
>> a.add(a.createResource(), a.createProperty("http://predicate"),
>> a.createTypedLiteral("literal", XSDfloat));
>> Model b = ModelFactory.createDefaultModel();
>> b.add(b.createResource(), b.createProperty("http://predicate"),
>> b.createTypedLiteral("literal", XSDfloat));
>> assertIsomorphic(a, b);
>> }
>>
>> Can you confirm?
>>
>> On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org> wrote:
>>
>> Can't see anything.
>>>
>>> maybe try cutting down the example to the triple(s) that matter?
>>> have you checked for upgrading from RDF 1.0?
>>>
>>> Andy
>>>
>>>
>>> On 03/01/18 17:01, Martynas Jusevičius wrote:
>>>
>>> System.out.println("-- Expected --");
>>>> expected.write(System.out, Lang.TURTLE.getName());
>>>> System.out.println("-- Parsed --");
>>>> parsed.write(System.out, Lang.TURTLE.getName());
>>>>
>>>> assertIsomorphic(parsed, parsed);
>>>> assertIsomorphic(expected, expected);
>>>> assertIsomorphic(expected, parsed);
>>>>
>>>> Two first assertions pass, the third one fails. The output:
>>>>
>>>> -- Expected --
>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>
>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>
>>>> <http://subject1> <http://dc.org/#title>
>>>> "title"@da ;
>>>> <http://predicate1> <http://object1> ;
>>>> <http://predicate2> <http://object3> , <http://object2> .
>>>>
>>>> <http://subject4> <http://dct.org/#hasPart>
>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>> ] ;
>>>> <http://predicate5> "literal3"^^<http://type> .
>>>> -- Parsed --
>>>> <http://subject2> <http://predicate3> "literal1" .
>>>>
>>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>>
>>>> <http://subject1> <http://dc.org/#title>
>>>> "title"@da ;
>>>> <http://predicate1> <http://object1> ;
>>>> <http://predicate2> <http://object3> , <http://object2> .
>>>>
>>>> <http://subject4> <http://dct.org/#hasPart>
>>>> [ <http://rdf.org/#first> <http://something/> ;
>>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>>> ] ;
>>>> <http://predicate5> "literal3"^^<http://type> .
>>>>
>>>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org> wrote:
>>>>
>>>> Martynas,
>>>>
>>>>>
>>>>> Do you have anything readable?
>>>>>
>>>>> If you write-and-read-back each model do that test isomorphic to
>>>>> themselves? To each other after read-write?
>>>>>
>>>>> Andy
>>>>>
>>>>>
>>>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>>>
>>>>>> I am writing a unit test for an RDF parser:
>>>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>>>
>>>>>> I have constructed two Models which only differ in blank nodes,
>>>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>>>
>>>>>> Here are the wanted.toString() and got.toString() output:
>>>>>>
>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>> http://subject3
>>>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
>>>>>> http://subject1 @http://predicate2 http://object3; http://subject1 @
>>>>>> http://predicate2 http://object2; http://subject1 @http://predicate1
>>>>>> http://object1; http://subject1 @http://dc.org/#title "title"@da;
>>>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil] [b1,
>>>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>>>> http://predicate2, http://object3] [http://subject1,
>>>>>> http://predicate2,
>>>>>> http://object2] [http://subject1, http://predicate1, http://object1]
>>>>>> [
>>>>>> http://subject1, http://dc.org/#title, "title"@da] [http://subject4,
>>>>>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
>>>>>> "literal3"^^http://type]>
>>>>>>
>>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>>> http://subject3
>>>>>> @http://predicate4 "literal2"@da; http://subject1 @http://predicate2
>>>>>> http://object3; http://subject1 @http://predicate2 http://object2;
>>>>>> http://subject1 @http://predicate1 http://object1; http://subject1 @
>>>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2 @
>>>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>>>> @
>>>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>>>> http://subject4
>>>>>> @
>>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>>>> "literal2"@da] [http://subject1, http://predicate2, http://object3] [
>>>>>> http://subject1, http://predicate2, http://object2] [http://subject1,
>>>>>> http://predicate1, http://object1] [http://subject1,
>>>>>> http://dc.org/#title
>>>>>> ,
>>>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2, http://rdf.org/#rest,
>>>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>>>> http://subject4,
>>>>>> http://predicate5, "literal3"^^http://type]>
>>>>>>
>>>>>> When I sort the triples by the subject, they seem identical to me,
>>>>>> sans
>>>>>> bnode labels:
>>>>>>
>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>>> [b1, http://rdf.org/#first, http://something/]
>>>>>>
>>>>>> [http://subject1, http://predicate2, http://object3]
>>>>>> [http://subject1, http://predicate2, http://object2]
>>>>>> [http://subject1, http://predicate1, http://object1]
>>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>>> [http://subject4, http://dct.org/#hasPart,
>>>>>> 30b98db4d09af8c4a56f907aec5a53
>>>>>> 48]
>>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>>>> http://rdf.org/#nil
>>>>>> ]
>>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>>>> http://something/]
>>>>>>
>>>>>> What am I missing here?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>
Re: [3.0.1] Models (not) isomorphic
Posted by Andy Seaborne <an...@apache.org>.
Martynas,
Datatypes need to be registered: The easy way (and the way RIOT parsers
do it) is to use getSafeTypeByName which registers and returns an
instance of BaseDatatype for unknown datatypes.
RDFDatatype dt =
TypeMapper.getInstance().getSafeTypeByName("http://type");
...
a.createTypedLiteral("literal", dt);
...
b.createTypedLiteral("literal", dt)
Multiple calls to getSafeTypeByName("http://type") will return the same
object.
Andy
Node n1 = NodeFactory.createLiteral(
"literal", new BaseDatatype("http://type"));
Node n2 = NodeFactory.createLiteral(
"literal", new BaseDatatype("http://type"));
System.out.println(n1.equals(n2));
--> false
On 04/01/18 00:33, Martynas Jusevičius wrote:
> Andy,
>
> it looks like the new BaseDatetype instance is the culprit. I reproduced a
> minimal case - the first test fails, the second one succeeds:
>
> @Test
> public void testIdenticalFails()
> {
> Model a = ModelFactory.createDefaultModel();
> a.add(a.createResource(), a.createProperty("http://predicate"),
> a.createTypedLiteral("literal", new BaseDatatype("http://type")));
> Model b = ModelFactory.createDefaultModel();
> b.add(b.createResource(), b.createProperty("http://predicate"),
> b.createTypedLiteral("literal", new BaseDatatype("http://type")));
> assertIsomorphic(a, b);
> }
>
> @Test
> public void testIdenticalSucceeds()
> {
> Model a = ModelFactory.createDefaultModel();
> a.add(a.createResource(), a.createProperty("http://predicate"),
> a.createTypedLiteral("literal", XSDfloat));
> Model b = ModelFactory.createDefaultModel();
> b.add(b.createResource(), b.createProperty("http://predicate"),
> b.createTypedLiteral("literal", XSDfloat));
> assertIsomorphic(a, b);
> }
>
> Can you confirm?
>
> On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org> wrote:
>
>> Can't see anything.
>>
>> maybe try cutting down the example to the triple(s) that matter?
>> have you checked for upgrading from RDF 1.0?
>>
>> Andy
>>
>>
>> On 03/01/18 17:01, Martynas Jusevičius wrote:
>>
>>> System.out.println("-- Expected --");
>>> expected.write(System.out, Lang.TURTLE.getName());
>>> System.out.println("-- Parsed --");
>>> parsed.write(System.out, Lang.TURTLE.getName());
>>>
>>> assertIsomorphic(parsed, parsed);
>>> assertIsomorphic(expected, expected);
>>> assertIsomorphic(expected, parsed);
>>>
>>> Two first assertions pass, the third one fails. The output:
>>>
>>> -- Expected --
>>> <http://subject2> <http://predicate3> "literal1" .
>>>
>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>
>>> <http://subject1> <http://dc.org/#title>
>>> "title"@da ;
>>> <http://predicate1> <http://object1> ;
>>> <http://predicate2> <http://object3> , <http://object2> .
>>>
>>> <http://subject4> <http://dct.org/#hasPart>
>>> [ <http://rdf.org/#first> <http://something/> ;
>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>> ] ;
>>> <http://predicate5> "literal3"^^<http://type> .
>>> -- Parsed --
>>> <http://subject2> <http://predicate3> "literal1" .
>>>
>>> <http://subject3> <http://predicate4> "literal2"@da .
>>>
>>> <http://subject1> <http://dc.org/#title>
>>> "title"@da ;
>>> <http://predicate1> <http://object1> ;
>>> <http://predicate2> <http://object3> , <http://object2> .
>>>
>>> <http://subject4> <http://dct.org/#hasPart>
>>> [ <http://rdf.org/#first> <http://something/> ;
>>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>>> ] ;
>>> <http://predicate5> "literal3"^^<http://type> .
>>>
>>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org> wrote:
>>>
>>> Martynas,
>>>>
>>>> Do you have anything readable?
>>>>
>>>> If you write-and-read-back each model do that test isomorphic to
>>>> themselves? To each other after read-write?
>>>>
>>>> Andy
>>>>
>>>>
>>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>>
>>>> Hi,
>>>>>
>>>>> I am writing a unit test for an RDF parser:
>>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>>
>>>>> I have constructed two Models which only differ in blank nodes,
>>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>>
>>>>> Here are the wanted.toString() and got.toString() output:
>>>>>
>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>> http://subject3
>>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
>>>>> http://subject1 @http://predicate2 http://object3; http://subject1 @
>>>>> http://predicate2 http://object2; http://subject1 @http://predicate1
>>>>> http://object1; http://subject1 @http://dc.org/#title "title"@da;
>>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil] [b1,
>>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>>> http://predicate2, http://object3] [http://subject1, http://predicate2,
>>>>> http://object2] [http://subject1, http://predicate1, http://object1] [
>>>>> http://subject1, http://dc.org/#title, "title"@da] [http://subject4,
>>>>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
>>>>> "literal3"^^http://type]>
>>>>>
>>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>>> http://subject3
>>>>> @http://predicate4 "literal2"@da; http://subject1 @http://predicate2
>>>>> http://object3; http://subject1 @http://predicate2 http://object2;
>>>>> http://subject1 @http://predicate1 http://object1; http://subject1 @
>>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2 @
>>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>>> @
>>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>>> http://subject4
>>>>> @
>>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>>> "literal2"@da] [http://subject1, http://predicate2, http://object3] [
>>>>> http://subject1, http://predicate2, http://object2] [http://subject1,
>>>>> http://predicate1, http://object1] [http://subject1,
>>>>> http://dc.org/#title
>>>>> ,
>>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2, http://rdf.org/#rest,
>>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>>> http://subject4,
>>>>> http://predicate5, "literal3"^^http://type]>
>>>>>
>>>>> When I sort the triples by the subject, they seem identical to me, sans
>>>>> bnode labels:
>>>>>
>>>>> [http://subject1, http://predicate2, http://object3]
>>>>> [http://subject1, http://predicate2, http://object2]
>>>>> [http://subject1, http://predicate1, http://object1]
>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>>> [b1, http://rdf.org/#first, http://something/]
>>>>>
>>>>> [http://subject1, http://predicate2, http://object3]
>>>>> [http://subject1, http://predicate2, http://object2]
>>>>> [http://subject1, http://predicate1, http://object1]
>>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>>> [http://subject2, http://predicate3, "literal1"]
>>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>>> [http://subject4, http://dct.org/#hasPart,
>>>>> 30b98db4d09af8c4a56f907aec5a53
>>>>> 48]
>>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>>> http://rdf.org/#nil
>>>>> ]
>>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>>> http://something/]
>>>>>
>>>>> What am I missing here?
>>>>>
>>>>>
>>>>>
>>>
>
Re: [3.0.1] Models (not) isomorphic
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Andy,
it looks like the new BaseDatetype instance is the culprit. I reproduced a
minimal case - the first test fails, the second one succeeds:
@Test
public void testIdenticalFails()
{
Model a = ModelFactory.createDefaultModel();
a.add(a.createResource(), a.createProperty("http://predicate"),
a.createTypedLiteral("literal", new BaseDatatype("http://type")));
Model b = ModelFactory.createDefaultModel();
b.add(b.createResource(), b.createProperty("http://predicate"),
b.createTypedLiteral("literal", new BaseDatatype("http://type")));
assertIsomorphic(a, b);
}
@Test
public void testIdenticalSucceeds()
{
Model a = ModelFactory.createDefaultModel();
a.add(a.createResource(), a.createProperty("http://predicate"),
a.createTypedLiteral("literal", XSDfloat));
Model b = ModelFactory.createDefaultModel();
b.add(b.createResource(), b.createProperty("http://predicate"),
b.createTypedLiteral("literal", XSDfloat));
assertIsomorphic(a, b);
}
Can you confirm?
On Wed, Jan 3, 2018 at 9:52 PM, Andy Seaborne <an...@apache.org> wrote:
> Can't see anything.
>
> maybe try cutting down the example to the triple(s) that matter?
> have you checked for upgrading from RDF 1.0?
>
> Andy
>
>
> On 03/01/18 17:01, Martynas Jusevičius wrote:
>
>> System.out.println("-- Expected --");
>> expected.write(System.out, Lang.TURTLE.getName());
>> System.out.println("-- Parsed --");
>> parsed.write(System.out, Lang.TURTLE.getName());
>>
>> assertIsomorphic(parsed, parsed);
>> assertIsomorphic(expected, expected);
>> assertIsomorphic(expected, parsed);
>>
>> Two first assertions pass, the third one fails. The output:
>>
>> -- Expected --
>> <http://subject2> <http://predicate3> "literal1" .
>>
>> <http://subject3> <http://predicate4> "literal2"@da .
>>
>> <http://subject1> <http://dc.org/#title>
>> "title"@da ;
>> <http://predicate1> <http://object1> ;
>> <http://predicate2> <http://object3> , <http://object2> .
>>
>> <http://subject4> <http://dct.org/#hasPart>
>> [ <http://rdf.org/#first> <http://something/> ;
>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>> ] ;
>> <http://predicate5> "literal3"^^<http://type> .
>> -- Parsed --
>> <http://subject2> <http://predicate3> "literal1" .
>>
>> <http://subject3> <http://predicate4> "literal2"@da .
>>
>> <http://subject1> <http://dc.org/#title>
>> "title"@da ;
>> <http://predicate1> <http://object1> ;
>> <http://predicate2> <http://object3> , <http://object2> .
>>
>> <http://subject4> <http://dct.org/#hasPart>
>> [ <http://rdf.org/#first> <http://something/> ;
>> <http://rdf.org/#rest> <http://rdf.org/#nil>
>> ] ;
>> <http://predicate5> "literal3"^^<http://type> .
>>
>> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org> wrote:
>>
>> Martynas,
>>>
>>> Do you have anything readable?
>>>
>>> If you write-and-read-back each model do that test isomorphic to
>>> themselves? To each other after read-write?
>>>
>>> Andy
>>>
>>>
>>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>>
>>> Hi,
>>>>
>>>> I am writing a unit test for an RDF parser:
>>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>>
>>>> I have constructed two Models which only differ in blank nodes,
>>>> yet wanted.isIsomorphicWith(got) returns false.
>>>>
>>>> Here are the wanted.toString() and got.toString() output:
>>>>
>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>> http://subject3
>>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
>>>> http://subject1 @http://predicate2 http://object3; http://subject1 @
>>>> http://predicate2 http://object2; http://subject1 @http://predicate1
>>>> http://object1; http://subject1 @http://dc.org/#title "title"@da;
>>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil] [b1,
>>>> http://rdf.org/#first, http://something/] [http://subject1,
>>>> http://predicate2, http://object3] [http://subject1, http://predicate2,
>>>> http://object2] [http://subject1, http://predicate1, http://object1] [
>>>> http://subject1, http://dc.org/#title, "title"@da] [http://subject4,
>>>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
>>>> "literal3"^^http://type]>
>>>>
>>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>>> http://subject3
>>>> @http://predicate4 "literal2"@da; http://subject1 @http://predicate2
>>>> http://object3; http://subject1 @http://predicate2 http://object2;
>>>> http://subject1 @http://predicate1 http://object1; http://subject1 @
>>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2 @
>>>> http://rdf.org/#rest http://rdf.org/#nil;
>>>> 9ee64f4ba50df2bb8b28a1a473990da2
>>>> @
>>>> http://rdf.org/#first http://something/; http://subject4 @
>>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2;
>>>> http://subject4
>>>> @
>>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>>> "literal2"@da] [http://subject1, http://predicate2, http://object3] [
>>>> http://subject1, http://predicate2, http://object2] [http://subject1,
>>>> http://predicate1, http://object1] [http://subject1,
>>>> http://dc.org/#title
>>>> ,
>>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2, http://rdf.org/#rest,
>>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>>> http://rdf.org/#first, http://something/] [http://subject4,
>>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>>> http://subject4,
>>>> http://predicate5, "literal3"^^http://type]>
>>>>
>>>> When I sort the triples by the subject, they seem identical to me, sans
>>>> bnode labels:
>>>>
>>>> [http://subject1, http://predicate2, http://object3]
>>>> [http://subject1, http://predicate2, http://object2]
>>>> [http://subject1, http://predicate1, http://object1]
>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>> [http://subject2, http://predicate3, "literal1"]
>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>> [http://subject4, http://dct.org/#hasPart, b1]
>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>>> [b1, http://rdf.org/#first, http://something/]
>>>>
>>>> [http://subject1, http://predicate2, http://object3]
>>>> [http://subject1, http://predicate2, http://object2]
>>>> [http://subject1, http://predicate1, http://object1]
>>>> [http://subject1, http://dc.org/#title, "title"@da]
>>>> [http://subject2, http://predicate3, "literal1"]
>>>> [http://subject3, http://predicate4, "literal2"@da]
>>>> [http://subject4, http://dct.org/#hasPart,
>>>> 30b98db4d09af8c4a56f907aec5a53
>>>> 48]
>>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>>> http://rdf.org/#nil
>>>> ]
>>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>>> http://something/]
>>>>
>>>> What am I missing here?
>>>>
>>>>
>>>>
>>
Re: [3.0.1] Models (not) isomorphic
Posted by Andy Seaborne <an...@apache.org>.
Can't see anything.
maybe try cutting down the example to the triple(s) that matter?
have you checked for upgrading from RDF 1.0?
Andy
On 03/01/18 17:01, Martynas Jusevičius wrote:
> System.out.println("-- Expected --");
> expected.write(System.out, Lang.TURTLE.getName());
> System.out.println("-- Parsed --");
> parsed.write(System.out, Lang.TURTLE.getName());
>
> assertIsomorphic(parsed, parsed);
> assertIsomorphic(expected, expected);
> assertIsomorphic(expected, parsed);
>
> Two first assertions pass, the third one fails. The output:
>
> -- Expected --
> <http://subject2> <http://predicate3> "literal1" .
>
> <http://subject3> <http://predicate4> "literal2"@da .
>
> <http://subject1> <http://dc.org/#title>
> "title"@da ;
> <http://predicate1> <http://object1> ;
> <http://predicate2> <http://object3> , <http://object2> .
>
> <http://subject4> <http://dct.org/#hasPart>
> [ <http://rdf.org/#first> <http://something/> ;
> <http://rdf.org/#rest> <http://rdf.org/#nil>
> ] ;
> <http://predicate5> "literal3"^^<http://type> .
> -- Parsed --
> <http://subject2> <http://predicate3> "literal1" .
>
> <http://subject3> <http://predicate4> "literal2"@da .
>
> <http://subject1> <http://dc.org/#title>
> "title"@da ;
> <http://predicate1> <http://object1> ;
> <http://predicate2> <http://object3> , <http://object2> .
>
> <http://subject4> <http://dct.org/#hasPart>
> [ <http://rdf.org/#first> <http://something/> ;
> <http://rdf.org/#rest> <http://rdf.org/#nil>
> ] ;
> <http://predicate5> "literal3"^^<http://type> .
>
> On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org> wrote:
>
>> Martynas,
>>
>> Do you have anything readable?
>>
>> If you write-and-read-back each model do that test isomorphic to
>> themselves? To each other after read-write?
>>
>> Andy
>>
>>
>> On 03/01/18 01:05, Martynas Jusevičius wrote:
>>
>>> Hi,
>>>
>>> I am writing a unit test for an RDF parser:
>>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>>
>>> I have constructed two Models which only differ in blank nodes,
>>> yet wanted.isIsomorphicWith(got) returns false.
>>>
>>> Here are the wanted.toString() and got.toString() output:
>>>
>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>> http://subject3
>>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
>>> http://subject1 @http://predicate2 http://object3; http://subject1 @
>>> http://predicate2 http://object2; http://subject1 @http://predicate1
>>> http://object1; http://subject1 @http://dc.org/#title "title"@da;
>>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil] [b1,
>>> http://rdf.org/#first, http://something/] [http://subject1,
>>> http://predicate2, http://object3] [http://subject1, http://predicate2,
>>> http://object2] [http://subject1, http://predicate1, http://object1] [
>>> http://subject1, http://dc.org/#title, "title"@da] [http://subject4,
>>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
>>> "literal3"^^http://type]>
>>>
>>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>>> http://subject3
>>> @http://predicate4 "literal2"@da; http://subject1 @http://predicate2
>>> http://object3; http://subject1 @http://predicate2 http://object2;
>>> http://subject1 @http://predicate1 http://object1; http://subject1 @
>>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2 @
>>> http://rdf.org/#rest http://rdf.org/#nil; 9ee64f4ba50df2bb8b28a1a473990da2
>>> @
>>> http://rdf.org/#first http://something/; http://subject4 @
>>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2; http://subject4
>>> @
>>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>>> "literal2"@da] [http://subject1, http://predicate2, http://object3] [
>>> http://subject1, http://predicate2, http://object2] [http://subject1,
>>> http://predicate1, http://object1] [http://subject1, http://dc.org/#title
>>> ,
>>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2, http://rdf.org/#rest,
>>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>>> http://rdf.org/#first, http://something/] [http://subject4,
>>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>>> http://subject4,
>>> http://predicate5, "literal3"^^http://type]>
>>>
>>> When I sort the triples by the subject, they seem identical to me, sans
>>> bnode labels:
>>>
>>> [http://subject1, http://predicate2, http://object3]
>>> [http://subject1, http://predicate2, http://object2]
>>> [http://subject1, http://predicate1, http://object1]
>>> [http://subject1, http://dc.org/#title, "title"@da]
>>> [http://subject2, http://predicate3, "literal1"]
>>> [http://subject3, http://predicate4, "literal2"@da]
>>> [http://subject4, http://dct.org/#hasPart, b1]
>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>>> [b1, http://rdf.org/#first, http://something/]
>>>
>>> [http://subject1, http://predicate2, http://object3]
>>> [http://subject1, http://predicate2, http://object2]
>>> [http://subject1, http://predicate1, http://object1]
>>> [http://subject1, http://dc.org/#title, "title"@da]
>>> [http://subject2, http://predicate3, "literal1"]
>>> [http://subject3, http://predicate4, "literal2"@da]
>>> [http://subject4, http://dct.org/#hasPart, 30b98db4d09af8c4a56f907aec5a53
>>> 48]
>>> [http://subject4, http://predicate5, "literal3"^^http://type]
>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>>> http://rdf.org/#nil
>>> ]
>>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>>> http://something/]
>>>
>>> What am I missing here?
>>>
>>>
>
Re: [3.0.1] Models (not) isomorphic
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
System.out.println("-- Expected --");
expected.write(System.out, Lang.TURTLE.getName());
System.out.println("-- Parsed --");
parsed.write(System.out, Lang.TURTLE.getName());
assertIsomorphic(parsed, parsed);
assertIsomorphic(expected, expected);
assertIsomorphic(expected, parsed);
Two first assertions pass, the third one fails. The output:
-- Expected --
<http://subject2> <http://predicate3> "literal1" .
<http://subject3> <http://predicate4> "literal2"@da .
<http://subject1> <http://dc.org/#title>
"title"@da ;
<http://predicate1> <http://object1> ;
<http://predicate2> <http://object3> , <http://object2> .
<http://subject4> <http://dct.org/#hasPart>
[ <http://rdf.org/#first> <http://something/> ;
<http://rdf.org/#rest> <http://rdf.org/#nil>
] ;
<http://predicate5> "literal3"^^<http://type> .
-- Parsed --
<http://subject2> <http://predicate3> "literal1" .
<http://subject3> <http://predicate4> "literal2"@da .
<http://subject1> <http://dc.org/#title>
"title"@da ;
<http://predicate1> <http://object1> ;
<http://predicate2> <http://object3> , <http://object2> .
<http://subject4> <http://dct.org/#hasPart>
[ <http://rdf.org/#first> <http://something/> ;
<http://rdf.org/#rest> <http://rdf.org/#nil>
] ;
<http://predicate5> "literal3"^^<http://type> .
On Wed, Jan 3, 2018 at 11:22 AM, Andy Seaborne <an...@apache.org> wrote:
> Martynas,
>
> Do you have anything readable?
>
> If you write-and-read-back each model do that test isomorphic to
> themselves? To each other after read-write?
>
> Andy
>
>
> On 03/01/18 01:05, Martynas Jusevičius wrote:
>
>> Hi,
>>
>> I am writing a unit test for an RDF parser:
>> https://github.com/AtomGraph/Core/blob/master/src/test/java/
>> com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>>
>> I have constructed two Models which only differ in blank nodes,
>> yet wanted.isIsomorphicWith(got) returns false.
>>
>> Here are the wanted.toString() and got.toString() output:
>>
>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>> http://subject3
>> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
>> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
>> http://subject1 @http://predicate2 http://object3; http://subject1 @
>> http://predicate2 http://object2; http://subject1 @http://predicate1
>> http://object1; http://subject1 @http://dc.org/#title "title"@da;
>> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil] [b1,
>> http://rdf.org/#first, http://something/] [http://subject1,
>> http://predicate2, http://object3] [http://subject1, http://predicate2,
>> http://object2] [http://subject1, http://predicate1, http://object1] [
>> http://subject1, http://dc.org/#title, "title"@da] [http://subject4,
>> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
>> "literal3"^^http://type]>
>>
>> <ModelCom {http://subject2 @http://predicate3 "literal1";
>> http://subject3
>> @http://predicate4 "literal2"@da; http://subject1 @http://predicate2
>> http://object3; http://subject1 @http://predicate2 http://object2;
>> http://subject1 @http://predicate1 http://object1; http://subject1 @
>> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2 @
>> http://rdf.org/#rest http://rdf.org/#nil; 9ee64f4ba50df2bb8b28a1a473990da2
>> @
>> http://rdf.org/#first http://something/; http://subject4 @
>> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2; http://subject4
>> @
>> http://predicate5 "literal3"^^http://type} | [http://subject2,
>> http://predicate3, "literal1"] [http://subject3, http://predicate4,
>> "literal2"@da] [http://subject1, http://predicate2, http://object3] [
>> http://subject1, http://predicate2, http://object2] [http://subject1,
>> http://predicate1, http://object1] [http://subject1, http://dc.org/#title
>> ,
>> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2, http://rdf.org/#rest,
>> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
>> http://rdf.org/#first, http://something/] [http://subject4,
>> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [
>> http://subject4,
>> http://predicate5, "literal3"^^http://type]>
>>
>> When I sort the triples by the subject, they seem identical to me, sans
>> bnode labels:
>>
>> [http://subject1, http://predicate2, http://object3]
>> [http://subject1, http://predicate2, http://object2]
>> [http://subject1, http://predicate1, http://object1]
>> [http://subject1, http://dc.org/#title, "title"@da]
>> [http://subject2, http://predicate3, "literal1"]
>> [http://subject3, http://predicate4, "literal2"@da]
>> [http://subject4, http://dct.org/#hasPart, b1]
>> [http://subject4, http://predicate5, "literal3"^^http://type]
>> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
>> [b1, http://rdf.org/#first, http://something/]
>>
>> [http://subject1, http://predicate2, http://object3]
>> [http://subject1, http://predicate2, http://object2]
>> [http://subject1, http://predicate1, http://object1]
>> [http://subject1, http://dc.org/#title, "title"@da]
>> [http://subject2, http://predicate3, "literal1"]
>> [http://subject3, http://predicate4, "literal2"@da]
>> [http://subject4, http://dct.org/#hasPart, 30b98db4d09af8c4a56f907aec5a53
>> 48]
>> [http://subject4, http://predicate5, "literal3"^^http://type]
>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest,
>> http://rdf.org/#nil
>> ]
>> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first,
>> http://something/]
>>
>> What am I missing here?
>>
>>
Re: [3.0.1] Models (not) isomorphic
Posted by Andy Seaborne <an...@apache.org>.
Martynas,
Do you have anything readable?
If you write-and-read-back each model do that test isomorphic to
themselves? To each other after read-write?
Andy
On 03/01/18 01:05, Martynas Jusevičius wrote:
> Hi,
>
> I am writing a unit test for an RDF parser:
> https://github.com/AtomGraph/Core/blob/master/src/test/java/com/atomgraph/core/riot/lang/RDFPostReaderTest.java
>
> I have constructed two Models which only differ in blank nodes,
> yet wanted.isIsomorphicWith(got) returns false.
>
> Here are the wanted.toString() and got.toString() output:
>
> <ModelCom {http://subject2 @http://predicate3 "literal1"; http://subject3
> @http://predicate4 "literal2"@da; b1 @http://rdf.org/#rest
> http://rdf.org/#nil; b1 @http://rdf.org/#first http://something/;
> http://subject1 @http://predicate2 http://object3; http://subject1 @
> http://predicate2 http://object2; http://subject1 @http://predicate1
> http://object1; http://subject1 @http://dc.org/#title "title"@da;
> http://subject4 @http://dct.org/#hasPart b1; http://subject4 @
> http://predicate5 "literal3"^^http://type} | [http://subject2,
> http://predicate3, "literal1"] [http://subject3, http://predicate4,
> "literal2"@da] [b1, http://rdf.org/#rest, http://rdf.org/#nil] [b1,
> http://rdf.org/#first, http://something/] [http://subject1,
> http://predicate2, http://object3] [http://subject1, http://predicate2,
> http://object2] [http://subject1, http://predicate1, http://object1] [
> http://subject1, http://dc.org/#title, "title"@da] [http://subject4,
> http://dct.org/#hasPart, b1] [http://subject4, http://predicate5,
> "literal3"^^http://type]>
>
> <ModelCom {http://subject2 @http://predicate3 "literal1"; http://subject3
> @http://predicate4 "literal2"@da; http://subject1 @http://predicate2
> http://object3; http://subject1 @http://predicate2 http://object2;
> http://subject1 @http://predicate1 http://object1; http://subject1 @
> http://dc.org/#title "title"@da; 9ee64f4ba50df2bb8b28a1a473990da2 @
> http://rdf.org/#rest http://rdf.org/#nil; 9ee64f4ba50df2bb8b28a1a473990da2 @
> http://rdf.org/#first http://something/; http://subject4 @
> http://dct.org/#hasPart 9ee64f4ba50df2bb8b28a1a473990da2; http://subject4 @
> http://predicate5 "literal3"^^http://type} | [http://subject2,
> http://predicate3, "literal1"] [http://subject3, http://predicate4,
> "literal2"@da] [http://subject1, http://predicate2, http://object3] [
> http://subject1, http://predicate2, http://object2] [http://subject1,
> http://predicate1, http://object1] [http://subject1, http://dc.org/#title,
> "title"@da] [9ee64f4ba50df2bb8b28a1a473990da2, http://rdf.org/#rest,
> http://rdf.org/#nil] [9ee64f4ba50df2bb8b28a1a473990da2,
> http://rdf.org/#first, http://something/] [http://subject4,
> http://dct.org/#hasPart, 9ee64f4ba50df2bb8b28a1a473990da2] [http://subject4,
> http://predicate5, "literal3"^^http://type]>
>
> When I sort the triples by the subject, they seem identical to me, sans
> bnode labels:
>
> [http://subject1, http://predicate2, http://object3]
> [http://subject1, http://predicate2, http://object2]
> [http://subject1, http://predicate1, http://object1]
> [http://subject1, http://dc.org/#title, "title"@da]
> [http://subject2, http://predicate3, "literal1"]
> [http://subject3, http://predicate4, "literal2"@da]
> [http://subject4, http://dct.org/#hasPart, b1]
> [http://subject4, http://predicate5, "literal3"^^http://type]
> [b1, http://rdf.org/#rest, http://rdf.org/#nil]
> [b1, http://rdf.org/#first, http://something/]
>
> [http://subject1, http://predicate2, http://object3]
> [http://subject1, http://predicate2, http://object2]
> [http://subject1, http://predicate1, http://object1]
> [http://subject1, http://dc.org/#title, "title"@da]
> [http://subject2, http://predicate3, "literal1"]
> [http://subject3, http://predicate4, "literal2"@da]
> [http://subject4, http://dct.org/#hasPart, 30b98db4d09af8c4a56f907aec5a5348]
> [http://subject4, http://predicate5, "literal3"^^http://type]
> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#rest, http://rdf.org/#nil
> ]
> [30b98db4d09af8c4a56f907aec5a5348, http://rdf.org/#first, http://something/]
>
> What am I missing here?
>