anusii / rdflib

A pure Dart package for working with RDF (resource description framework).
https://pub.dev/packages/rdflib
GNU General Public License v3.0
13 stars 3 forks source link

RDF: read full example `ttl` data in anusii/pods with `RDFLib` package #3

Closed tian3rd closed 1 year ago

zheyxu commented 1 year ago

@tian3rd According to the use of the package, I raised some issues:

tian3rd commented 1 year ago

@Zheyuan-Robert-Xu Thanks for raising this issue, I'm discussing it with @Sergio For a temporary quick fix, I have updated the rdflib to the latest version where I just ignore lines starting with '@base` which should generate the outcome of parsing or serializing without errors.

tian3rd commented 1 year ago

See the change log of version 0.1.3 for detail.

tian3rd commented 1 year ago

The full example data I use: https://github.com/anusii/pods/blob/main/datasets/turtle-data/SOLID-Health-Ontology-Example%20-%20(data).ttl

Read this file --> store triples in graph --> serialize graph to a new ttl file, we get the file: https://github.com/anusii/rdflib/blob/main/example/ex_full_processed.ttl

zheyxu commented 1 year ago

Thanks, Phillip! And is it possible to separate the whole ttl file into patient id-specific files, like p12460.ttl file?

tian3rd commented 1 year ago

Thanks, Phillip! And is it possible to separate the whole ttl file into patient id-specific files, like p12460.ttl file?

It's possible, for example, you can check each triple in your graph, and extract those which meet your id criteria. And then export it to a different ttl file.

It much depends on your workflow of organizing patient data in the first place.

zheyxu commented 1 year ago

The value of Literal is limited to a String. The value also needs to cover float, int. Literal(this.value, {this.datatype, this.lang})

tian3rd commented 1 year ago

The value of Literal is limited to a String. The value also needs to cover float, int. Literal(this.value, {this.datatype, this.lang})

Hi @Zheyuan-Robert-Xu, you can check the Literal datatype first, if it's a xsd:float type, then you can convert the value back to a double type in dart.

zheyxu commented 1 year ago

But when the record was written in the turtle file, it adds double quotation marks to the value.
sh-onto:systolicBloodPressure "123"^^xsd:int .

tian3rd commented 1 year ago

Exactly, so that when you parse it into your graph, you can check the object (Literal in this case) datatype first, which should be URIRef(XSD.int), then you're guranteed that the Literal's value "123" can be converted to an integer.