From b883b0dc443bd341eaa8685e5ab7f8d142b5ee5d Mon Sep 17 00:00:00 2001 From: weasdown <34220924+weasdown@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:40:21 +0100 Subject: [PATCH 01/19] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index aa53890..6a50c0c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +## This repository is a fork of anusii/rdflib:main to develop a solution to its [issue 34](https://github.com/anusii/rdflib/issues/34). + + # RDFLib [![Pub Package](https://img.shields.io/pub/v/rdflib)](https://pub.dev/packages/rdflib) From 1cd23b451c790df65ef59c80ed85251e1cf0ea98 Mon Sep 17 00:00:00 2001 From: weasdown <34220924+weasdown@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:41:01 +0100 Subject: [PATCH 02/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a50c0c..c1f403b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## This repository is a fork of anusii/rdflib:main to develop a solution to its [issue 34](https://github.com/anusii/rdflib/issues/34). +## This repository is a fork of [anusii/rdflib:main](https://github.com/anusii/rdflib) to develop a solution to its [issue 34](https://github.com/anusii/rdflib/issues/34) # RDFLib From 92971443e1f1d4249ed760c2c6d4c89a617e0721 Mon Sep 17 00:00:00 2001 From: weasdown <34220924+weasdown@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:41:20 +0100 Subject: [PATCH 03/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1f403b..c2ef885 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## This repository is a fork of [anusii/rdflib:main](https://github.com/anusii/rdflib) to develop a solution to its [issue 34](https://github.com/anusii/rdflib/issues/34) +## This repository is a fork of [anusii/rdflib:main]([https://github.com/anusii/rdflib](https://github.com/anusii/rdflib/tree/main)) to develop a solution to its [issue 34](https://github.com/anusii/rdflib/issues/34) # RDFLib From 4aa33cda54753c85611dbacfbf6e9532a1260cf0 Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:00:01 +0100 Subject: [PATCH 04/19] Added initial String/List branching --- lib/src/graph.dart | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 1893c4d..086636f 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -611,10 +611,27 @@ class Graph { // Use a set to store the triples. groups[sub]![pre] = Set(); List objectList = predicateObjectList[1]; - for (String obj in objectList) { - groups[sub]![pre]!.add(item(obj)); - triples.add(Triple(sub: sub, pre: pre, obj: item(obj))); + + for (var obj in objectList){ + + var objItem; + if (obj is String){ + objItem = item(obj); + } + if (obj is List){ + print('List found!'); + throw Error(); + } + + groups[sub]![pre]!.add(objItem); + triples.add(Triple(sub: sub, pre: pre, obj: item(obj))); } + + // // Original for loop - TODO remove + // for (String obj in objectList) { + // groups[sub]![pre]!.add(item(obj)); + // triples.add(Triple(sub: sub, pre: pre, obj: item(obj))); + // } } } From f4ddd3d911f44fb62faeead7b086d281a66561bb Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:26:52 +0100 Subject: [PATCH 05/19] Added itemFromList() to handle obj being a List --- lib/src/graph.dart | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 086636f..1b070e0 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -612,19 +612,22 @@ class Graph { groups[sub]![pre] = Set(); List objectList = predicateObjectList[1]; + // My new code: for (var obj in objectList){ + var objItem; + if (obj is String){ + objItem = item(obj); + } + else if (obj is List){ + objItem = itemFromList(obj); + } - var objItem; - if (obj is String){ - objItem = item(obj); - } - if (obj is List){ - print('List found!'); - throw Error(); - } + groups[sub]![pre]!.add(objItem); + print('Adding to groups, sub: $sub, pre: $pre, obj: $obj'); + triples.add(Triple(sub: sub, pre: pre, obj: objItem)); - groups[sub]![pre]!.add(objItem); - triples.add(Triple(sub: sub, pre: pre, obj: item(obj))); + var groups_sub_pre = groups[sub]![pre]!; + print('groups[sub]![pre]!: ${groups_sub_pre}'); } // // Original for loop - TODO remove @@ -730,6 +733,11 @@ class Graph { } } + itemFromList(List l){ + print('Pretending to process item from list ${l}'); + return l; + } + /// Serializes the graph to certain format and export to file. /// /// Note: From 7ed1300bbf18cb6f8fcd0f4848ac97204edc6483 Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Tue, 18 Jun 2024 13:28:45 +0100 Subject: [PATCH 06/19] Added first version of parser to itemFromList() --- lib/src/graph.dart | 56 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 1b070e0..2959e67 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -623,11 +623,12 @@ class Graph { } groups[sub]![pre]!.add(objItem); - print('Adding to groups, sub: $sub, pre: $pre, obj: $obj'); triples.add(Triple(sub: sub, pre: pre, obj: objItem)); - var groups_sub_pre = groups[sub]![pre]!; - print('groups[sub]![pre]!: ${groups_sub_pre}'); + // TODO remove + // print('Adding to groups, sub: $sub, pre: $pre, obj: $obj'); + // var groups_sub_pre = groups[sub]![pre]!; + // print('groups[sub]![pre]!: ${groups_sub_pre}'); } // // Original for loop - TODO remove @@ -733,9 +734,52 @@ class Graph { } } - itemFromList(List l){ - print('Pretending to process item from list ${l}'); - return l; + Map> itemFromList(List tripleList){ + print('Pretending to process item from list'); + if (tripleList[0] == '[') { + // trim leading and trailing 'entries' that are just [ or ] + tripleList = tripleList.sublist(1, tripleList.length - 1); + } + + List predicateObjectLists = tripleList[0]; + print('pOLs: $predicateObjectLists,\n\t- length: ${predicateObjectLists.length},\n\t- runtimeType: ${predicateObjectLists.runtimeType}'); + print('First in pOLs: ${predicateObjectLists[0]}'); + + // format is [subject, [ [pre1, obj1], [pre2, obj2], [pre3, obj3]... ] ] + + Map> objectGroups = Map(); + + for (List predicateObjectList in predicateObjectLists){ + print('predicateObjectList in pOL: $predicateObjectList, type: ${predicateObjectList.runtimeType}, length: ${predicateObjectList.length}'); + if (predicateObjectList[0] == '['){ + predicateObjectList = predicateObjectList.sublist(1, predicateObjectList.length-1); + } + var pre; + if (predicateObjectList[0] is List){ + pre = itemFromList(predicateObjectList[0]); + } + else { + pre = item(predicateObjectList[0]); // URIRef + } + + List objectList = predicateObjectList[1]; + + var objectItem; + for (var object in objectList){ + if (object is String){ + objectItem = item(object); + } + else if (object is List){ + objectItem = itemFromList(object); + } + else { + throw Exception('object could not be parsed. object'); + } + + objectGroups[pre] = {objectItem}; + } + } + return objectGroups; } /// Serializes the graph to certain format and export to file. From afac50d975284833bdfb6914e9fc320b269e7206 Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Tue, 18 Jun 2024 13:31:31 +0100 Subject: [PATCH 07/19] Improved handling of brackets --- lib/src/graph.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 2959e67..034a389 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -736,8 +736,8 @@ class Graph { Map> itemFromList(List tripleList){ print('Pretending to process item from list'); - if (tripleList[0] == '[') { - // trim leading and trailing 'entries' that are just [ or ] + if (tripleList[0] == '[' || tripleList[0] == '(') { + // trim leading and trailing 'entries' that are just brackets tripleList = tripleList.sublist(1, tripleList.length - 1); } @@ -748,7 +748,7 @@ class Graph { // format is [subject, [ [pre1, obj1], [pre2, obj2], [pre3, obj3]... ] ] Map> objectGroups = Map(); - + for (List predicateObjectList in predicateObjectLists){ print('predicateObjectList in pOL: $predicateObjectList, type: ${predicateObjectList.runtimeType}, length: ${predicateObjectList.length}'); if (predicateObjectList[0] == '['){ From 3662a119dee79013c4dd71f6a1e1b39988d90cfa Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:31:11 +0100 Subject: [PATCH 08/19] Fixed bracket handling --- lib/src/graph.dart | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 034a389..2bfe14d 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -735,19 +735,20 @@ class Graph { } Map> itemFromList(List tripleList){ - print('Pretending to process item from list'); - if (tripleList[0] == '[' || tripleList[0] == '(') { - // trim leading and trailing 'entries' that are just brackets - tripleList = tripleList.sublist(1, tripleList.length - 1); - } - - List predicateObjectLists = tripleList[0]; - print('pOLs: $predicateObjectLists,\n\t- length: ${predicateObjectLists.length},\n\t- runtimeType: ${predicateObjectLists.runtimeType}'); - print('First in pOLs: ${predicateObjectLists[0]}'); + List predicateObjectLists = []; + Map> objectGroups = Map(); - // format is [subject, [ [pre1, obj1], [pre2, obj2], [pre3, obj3]... ] ] + if (tripleList[0] == '('){ + if (tripleList[1][0] is List){ + tripleList = tripleList[1][0]; + } + } - Map> objectGroups = Map(); + if (tripleList[0] == '[') { + // trim leading and trailing 'entries' that are just [ or ] + tripleList = tripleList.sublist(1, tripleList.length - 1); + predicateObjectLists = tripleList[0]; + } for (List predicateObjectList in predicateObjectLists){ print('predicateObjectList in pOL: $predicateObjectList, type: ${predicateObjectList.runtimeType}, length: ${predicateObjectList.length}'); @@ -770,7 +771,18 @@ class Graph { objectItem = item(object); } else if (object is List){ - objectItem = itemFromList(object); + if (object[0]=='('){ + // Found a set of objects + object = object.sublist(1, object.length - 1); + + if (object[0][0] is List){ + object = object[0][0]; + objectItem = itemFromList(object); + } + else { + objectItem = object.toSet(); + } + } } else { throw Exception('object could not be parsed. object'); From 115960474daed781385bbde7f95cb5ba34a32dc1 Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:40:23 +0100 Subject: [PATCH 09/19] Removed print --- lib/src/graph.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 2bfe14d..97d9011 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -751,7 +751,6 @@ class Graph { } for (List predicateObjectList in predicateObjectLists){ - print('predicateObjectList in pOL: $predicateObjectList, type: ${predicateObjectList.runtimeType}, length: ${predicateObjectList.length}'); if (predicateObjectList[0] == '['){ predicateObjectList = predicateObjectList.sublist(1, predicateObjectList.length-1); } From ce32dc220104935690b1b37e74ca5f46b9cca0a6 Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Sun, 23 Jun 2024 09:00:54 +0100 Subject: [PATCH 10/19] Started adding parsing for multiple ConstrainedDatatype restrictions --- lib/src/graph.dart | 90 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 23 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 97d9011..947929f 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -613,12 +613,11 @@ class Graph { List objectList = predicateObjectList[1]; // My new code: - for (var obj in objectList){ + for (var obj in objectList) { var objItem; - if (obj is String){ + if (obj is String) { objItem = item(obj); - } - else if (obj is List){ + } else if (obj is List) { objItem = itemFromList(obj); } @@ -734,12 +733,51 @@ class Graph { } } - Map> itemFromList(List tripleList){ + List stripBrackets(List values) { + if (values[0] == '(' || values[0] == '[') { + values = values.sublist(1, values.length - 1); + } + return values; + } + + parseObjectValues(List objVals) { + /// Parses a Set or List of multiple object values + print('objVals: $objVals'); + objVals = stripBrackets(objVals)[0]; + print(''); + for (var objVal in objVals) { + objVal = stripBrackets(objVal)[0][0]; + String objName = objVal[0]; + + print('name: ${objVal[0]}, value: ${objVal[1]}'); + print(''); + } + } + + parseObjectValueFromNameStringAndValueList(List obj) { + /// Used for getting name and values for objects when obj is in the format: + /// ['Object name string', ['Value 1', 'Value 2 (optional)'...] ] + String objName = obj[0]; + List values = obj[1]; + String objValues = ''; + if (values.length == 1) { + objValues = values[1]; + } else { + // TODO + List singleValuesList = values[1]; + } + } + + parseObjectValue() { + /// Parses a single object value + } + + Map> itemFromList(List tripleList) { List predicateObjectLists = []; Map> objectGroups = Map(); - if (tripleList[0] == '('){ - if (tripleList[1][0] is List){ + if (tripleList[0] == '(') { + if (tripleList[1][0] is List) { tripleList = tripleList[1][0]; } } @@ -750,40 +788,46 @@ class Graph { predicateObjectLists = tripleList[0]; } - for (List predicateObjectList in predicateObjectLists){ - if (predicateObjectList[0] == '['){ - predicateObjectList = predicateObjectList.sublist(1, predicateObjectList.length-1); + for (List predicateObjectList in predicateObjectLists) { + if (predicateObjectList[0] == '[') { + predicateObjectList = + predicateObjectList.sublist(1, predicateObjectList.length - 1); } var pre; - if (predicateObjectList[0] is List){ - pre = itemFromList(predicateObjectList[0]); + pre = predicateObjectList[0]; + var objValues = predicateObjectList[1]; + if (objValues[0] is List && objValues[0].length > 1) { + // Multiple object values found (e.g. multiple restrictions on a ConstrainedDatatype) + print('Multiple values!'); + parseObjectValues(objValues[0]); } - else { + + if (predicateObjectList[0] is List) { + // detect list within predicateObjectList and iterate + pre = itemFromList(predicateObjectList[0]); + } else { pre = item(predicateObjectList[0]); // URIRef } List objectList = predicateObjectList[1]; var objectItem; - for (var object in objectList){ - if (object is String){ + for (var object in objectList) { + if (object is String) { objectItem = item(object); - } - else if (object is List){ - if (object[0]=='('){ + } else if (object is List) { + if (object[0] == '(') { // Found a set of objects object = object.sublist(1, object.length - 1); - if (object[0][0] is List){ + if (object[0][0] is List) { object = object[0][0]; objectItem = itemFromList(object); - } - else { + } else { objectItem = object.toSet(); } } - } - else { + } else { throw Exception('object could not be parsed. object'); } From fd195ffdffba90d0cac7bf86179602ccfd9166bd Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:52:04 +0100 Subject: [PATCH 11/19] Improved handling of pre and multi-value objects --- lib/src/graph.dart | 59 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 947929f..63c4295 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -740,32 +740,61 @@ class Graph { return values; } - parseObjectValues(List objVals) { + Set parseObjectValues(List objVals) { /// Parses a Set or List of multiple object values - print('objVals: $objVals'); + print('objVals: $objVals'); // TODO remove objVals = stripBrackets(objVals)[0]; - print(''); + + Set values = {}; for (var objVal in objVals) { - objVal = stripBrackets(objVal)[0][0]; - String objName = objVal[0]; + if (objVal is List) { + objVal = stripBrackets(objVal)[0][0]; + + String objName = objVal[0]; + List subValues = objVal[1]; - print('name: ${objVal[0]}, value: ${objVal[1]}'); - print(''); + // TODO try to parse to int/float etc + Map objMap = { + objName: subValues.length == 1 ? subValues[0] : subValues + }; + values.add(objMap); + } else { + // TODO + print(''); + values.add(objVal); + } } + return values; } - parseObjectValueFromNameStringAndValueList(List obj) { + List parseObjectValueFromNameStringAndValueList(List obj) { /// Used for getting name and values for objects when obj is in the format: /// ['Object name string', ['Value 1', 'Value 2 (optional)'...] ] + /// Returns in format: {'Object name string': {'Value 1', 'Value 2 (optional)'...} } + String objName = obj[0]; + List values = obj[1]; - String objValues = ''; + Set objValues = {}; + if (values.length == 1) { - objValues = values[1]; + objValues.add(values[0]); } else { - // TODO + // TODO parse multiple values List singleValuesList = values[1]; + for (final val in values) { + // check whether string or list + if (val is String) { + objValues.add(val); + } else { + // TODO + throw UnimplementedError( + 'Parsing of multiple values is not yet implemented in this method'); + } + } } + + return [objName, objValues]; } parseObjectValue() { @@ -794,14 +823,16 @@ class Graph { predicateObjectList.sublist(1, predicateObjectList.length - 1); } var pre; - pre = predicateObjectList[0]; + pre = item(predicateObjectList[0]); var objValues = predicateObjectList[1]; if (objValues[0] is List && objValues[0].length > 1) { // Multiple object values found (e.g. multiple restrictions on a ConstrainedDatatype) print('Multiple values!'); - parseObjectValues(objValues[0]); + Set values = parseObjectValues(objValues[0]); + objectGroups[pre] = values; } + // TODO still needed? else if rather than if? if (predicateObjectList[0] is List) { // detect list within predicateObjectList and iterate pre = itemFromList(predicateObjectList[0]); @@ -815,6 +846,7 @@ class Graph { for (var object in objectList) { if (object is String) { objectItem = item(object); + print(''); } else if (object is List) { if (object[0] == '(') { // Found a set of objects @@ -823,6 +855,7 @@ class Graph { if (object[0][0] is List) { object = object[0][0]; objectItem = itemFromList(object); + print(''); } else { objectItem = object.toSet(); } From 664a30c2e3727e37d414462d14adf86ea8c9cad2 Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Sun, 23 Jun 2024 17:30:53 +0100 Subject: [PATCH 12/19] Neatened parsing of multi-attribute objects --- lib/src/graph.dart | 69 +++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 63c4295..fbd3944 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -742,7 +742,6 @@ class Graph { Set parseObjectValues(List objVals) { /// Parses a Set or List of multiple object values - print('objVals: $objVals'); // TODO remove objVals = stripBrackets(objVals)[0]; Set values = {}; @@ -755,12 +754,12 @@ class Graph { // TODO try to parse to int/float etc Map objMap = { - objName: subValues.length == 1 ? subValues[0] : subValues + // TODO remove extra Set layer + objName: subValues.length == 1 ? {subValues[0]} : {subValues} }; values.add(objMap); } else { // TODO - print(''); values.add(objVal); } } @@ -781,7 +780,7 @@ class Graph { objValues.add(values[0]); } else { // TODO parse multiple values - List singleValuesList = values[1]; + // List singleValuesList = values[1]; for (final val in values) { // check whether string or list if (val is String) { @@ -825,12 +824,6 @@ class Graph { var pre; pre = item(predicateObjectList[0]); var objValues = predicateObjectList[1]; - if (objValues[0] is List && objValues[0].length > 1) { - // Multiple object values found (e.g. multiple restrictions on a ConstrainedDatatype) - print('Multiple values!'); - Set values = parseObjectValues(objValues[0]); - objectGroups[pre] = values; - } // TODO still needed? else if rather than if? if (predicateObjectList[0] is List) { @@ -840,32 +833,44 @@ class Graph { pre = item(predicateObjectList[0]); // URIRef } - List objectList = predicateObjectList[1]; + Set objItem = {}; - var objectItem; - for (var object in objectList) { - if (object is String) { - objectItem = item(object); - print(''); - } else if (object is List) { - if (object[0] == '(') { - // Found a set of objects - object = object.sublist(1, object.length - 1); - - if (object[0][0] is List) { - object = object[0][0]; - objectItem = itemFromList(object); - print(''); - } else { - objectItem = object.toSet(); - } - } + for (final obj in objValues) { + if (objValues[0] is List && objValues[0].length > 1) { + // Multiple object values found (e.g. multiple restrictions on a ConstrainedDatatype) + objItem.add(parseObjectValues(objValues[0])); } else { - throw Exception('object could not be parsed. object'); + objItem.add(item(obj)); } - - objectGroups[pre] = {objectItem}; } + + objectGroups[pre] = objItem; + // List objectList = predicateObjectList[1]; + + // var objectItem; + // for (var object in objectList) { + // if (object is String) { + // objectItem = item(object); + // print(''); + // } else if (object is List) { + // if (object[0] == '(') { + // // Found a set of objects + // object = object.sublist(1, object.length - 1); + // + // if (object[0][0] is List) { + // object = object[0][0]; + // objectItem = itemFromList(object); + // print(''); + // } else { + // objectItem = object.toSet(); + // } + // } + // } else { + // throw Exception('object could not be parsed. object'); + // } + // + // objectGroups[pre] = {objectItem}; + // } } return objectGroups; } From 94cd210229fde8c8e01e5288a5dc08c57432926c Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Sun, 23 Jun 2024 17:37:12 +0100 Subject: [PATCH 13/19] Removed commented code, fixed excess Set layer --- lib/src/graph.dart | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index fbd3944..e58889a 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -623,11 +623,6 @@ class Graph { groups[sub]![pre]!.add(objItem); triples.add(Triple(sub: sub, pre: pre, obj: objItem)); - - // TODO remove - // print('Adding to groups, sub: $sub, pre: $pre, obj: $obj'); - // var groups_sub_pre = groups[sub]![pre]!; - // print('groups[sub]![pre]!: ${groups_sub_pre}'); } // // Original for loop - TODO remove @@ -754,8 +749,7 @@ class Graph { // TODO try to parse to int/float etc Map objMap = { - // TODO remove extra Set layer - objName: subValues.length == 1 ? {subValues[0]} : {subValues} + objName: subValues.length == 1 ? subValues[0] : subValues }; values.add(objMap); } else { @@ -825,7 +819,6 @@ class Graph { pre = item(predicateObjectList[0]); var objValues = predicateObjectList[1]; - // TODO still needed? else if rather than if? if (predicateObjectList[0] is List) { // detect list within predicateObjectList and iterate pre = itemFromList(predicateObjectList[0]); @@ -845,32 +838,6 @@ class Graph { } objectGroups[pre] = objItem; - // List objectList = predicateObjectList[1]; - - // var objectItem; - // for (var object in objectList) { - // if (object is String) { - // objectItem = item(object); - // print(''); - // } else if (object is List) { - // if (object[0] == '(') { - // // Found a set of objects - // object = object.sublist(1, object.length - 1); - // - // if (object[0][0] is List) { - // object = object[0][0]; - // objectItem = itemFromList(object); - // print(''); - // } else { - // objectItem = object.toSet(); - // } - // } - // } else { - // throw Exception('object could not be parsed. object'); - // } - // - // objectGroups[pre] = {objectItem}; - // } } return objectGroups; } From 24bc15b94fe8f557cf495d75ceba773d2ffc7c71 Mon Sep 17 00:00:00 2001 From: zheyxu <79696631+zheyxu@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:09:00 +1000 Subject: [PATCH 14/19] Update graph.dart to make deep list work --- lib/src/graph.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 0fb0f83..0e71515 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -756,7 +756,9 @@ class Graph { // TODO try to parse to int/float etc Map objMap = { - objName: subValues.length == 1 ? subValues[0] : subValues + item(objName): subValues.length == 1 + ? item(subValues[0]) + : subValues.map((e) => item(e)).toSet() }; values.add(objMap); } else { From 4267fec281779c1fd7326c4ca3ce7778790f97f5 Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Sun, 21 Jul 2024 09:00:58 +0100 Subject: [PATCH 15/19] Add rdflib-proto --- lib/src/graph.dart | 6 +++--- lib/src/namespace.dart | 2 +- lib/src/term.dart | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 0e71515..c308e0e 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -1,10 +1,10 @@ import 'dart:convert'; import 'dart:io' show File; -import './namespace.dart'; +import 'namespace.dart'; import './term.dart'; -import './triple.dart'; -import './constants.dart'; +import 'triple.dart'; +import 'constants.dart'; import '../parser/grammar_parser.dart'; class Graph { diff --git a/lib/src/namespace.dart b/lib/src/namespace.dart index d9bc1e0..ae801f4 100644 --- a/lib/src/namespace.dart +++ b/lib/src/namespace.dart @@ -1,4 +1,4 @@ -import './term.dart'; +import 'term.dart'; import 'constants.dart'; class Namespace { diff --git a/lib/src/term.dart b/lib/src/term.dart index 61356a0..f92da84 100644 --- a/lib/src/term.dart +++ b/lib/src/term.dart @@ -1,5 +1,5 @@ import 'package:logging/logging.dart'; -import './namespace.dart'; +import 'namespace.dart'; Logger logger = Logger('term'); From d07fae6cf09fa06df0a0ac1518a76e096f727335 Mon Sep 17 00:00:00 2001 From: William Easdown Babb <34220924+weasdown@users.noreply.github.com> Date: Thu, 1 Aug 2024 20:07:04 +0100 Subject: [PATCH 16/19] Reset README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index c2ef885..aa53890 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ -## This repository is a fork of [anusii/rdflib:main]([https://github.com/anusii/rdflib](https://github.com/anusii/rdflib/tree/main)) to develop a solution to its [issue 34](https://github.com/anusii/rdflib/issues/34) - - # RDFLib [![Pub Package](https://img.shields.io/pub/v/rdflib)](https://pub.dev/packages/rdflib) From bc924a8f33d3487b584627d55c0199b2074d208b Mon Sep 17 00:00:00 2001 From: Tristan Tarrant Date: Tue, 25 Mar 2025 14:37:18 +0100 Subject: [PATCH 17/19] [#52] Fix parsing of semicolon at end of predicateObjectList --- lib/parser/grammar_parser.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/parser/grammar_parser.dart b/lib/parser/grammar_parser.dart index b4d3209..ea07db2 100644 --- a/lib/parser/grammar_parser.dart +++ b/lib/parser/grammar_parser.dart @@ -337,7 +337,9 @@ class EvaluatorDefinition extends ExpressionDefinition { rtnList.add(firstPreObj); final restPreObjs = values[2] as List; for (var i = 0; i < restPreObjs.length; i++) { - rtnList.add(restPreObjs[i][1][0]); + var o = restPreObjs[i][1] as List; + if (o.length > 0) + rtnList.add(o[0]); } return rtnList; }); From 2d250eaebd2ddc80022f1ee5e2bbd46d5a788b78 Mon Sep 17 00:00:00 2001 From: zheyxu <79696631+zheyxu@users.noreply.github.com> Date: Mon, 14 Apr 2025 12:30:18 +1000 Subject: [PATCH 18/19] dart format --- lib/parser/grammar_parser.dart | 5 ++--- lib/src/graph.dart | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/parser/grammar_parser.dart b/lib/parser/grammar_parser.dart index ea07db2..c32e5c3 100644 --- a/lib/parser/grammar_parser.dart +++ b/lib/parser/grammar_parser.dart @@ -257,7 +257,7 @@ class ExpressionDefinition extends GrammarDefinition { Parser turtleDoc() => ref0(statement).star(); } -/// This class focuses on interpreting and formatting the raw parsed data +/// This class focuses on interpreting and formatting the raw parsed data /// into a more structured and meaningful format. class EvaluatorDefinition extends ExpressionDefinition { @@ -338,8 +338,7 @@ class EvaluatorDefinition extends ExpressionDefinition { final restPreObjs = values[2] as List; for (var i = 0; i < restPreObjs.length; i++) { var o = restPreObjs[i][1] as List; - if (o.length > 0) - rtnList.add(o[0]); + if (o.length > 0) rtnList.add(o[0]); } return rtnList; }); diff --git a/lib/src/graph.dart b/lib/src/graph.dart index 7ef72be..b20ecff 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -804,7 +804,6 @@ class Graph { // (obj is List) ? item(_combineListItems(obj)) : item(obj); // groups[sub]![pre]!.add(parsedObj); // triples.add(Triple(sub: sub, pre: pre, obj: parsedObj)); - } // // Original for loop - TODO remove From 3a76079405b47e2eda62128734ccb1935adb5cd3 Mon Sep 17 00:00:00 2001 From: zheyxu <79696631+zheyxu@users.noreply.github.com> Date: Mon, 14 Apr 2025 12:41:08 +1000 Subject: [PATCH 19/19] update comments --- lib/src/graph.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/src/graph.dart b/lib/src/graph.dart index b20ecff..3f084db 100644 --- a/lib/src/graph.dart +++ b/lib/src/graph.dart @@ -799,13 +799,18 @@ class Graph { groups[sub]![pre]!.add(objItem); triples.add(Triple(sub: sub, pre: pre, obj: objItem)); -// for (var obj in objectList) { -// var parsedObj = -// (obj is List) ? item(_combineListItems(obj)) : item(obj); -// groups[sub]![pre]!.add(parsedObj); -// triples.add(Triple(sub: sub, pre: pre, obj: parsedObj)); + /// Keep it for future use. + + // for (var obj in objectList) { + // var parsedObj = + // (obj is List) ? item(_combineListItems(obj)) : item(obj); + // groups[sub]![pre]!.add(parsedObj); + // triples.add(Triple(sub: sub, pre: pre, obj: parsedObj)); + // } } + /// Keep it for future use. + // // Original for loop - TODO remove // for (String obj in objectList) { // groups[sub]![pre]!.add(item(obj));