Closed joeltg closed 4 years ago
A few more notes:
normalized: []string
variable to a .lines: []string
field in NormalizationAlgorithm struct so that it can be accessed by the sort interface methods. If you have a name you'd prefer for the field instead of lines
please change it!Normalize(dataset *RDFDataset)
method, please change it! Normalize seemed like the most intuitive choice, but it could be confusing since there are other methods named Normalize in the library (e.g. on api).@joeltg thank you for submitting this PR! The proposed changes make sense. I'm not overly concerned about naming, because of the reasons I outlined in #26.
Regarding the way to run normalisation tests, the official test suite for normalisation runs as a part of _ld/processortest.go. If you execute:
make test
the whole test suite will run.
Thanks again! Will merge the PR now. I will add your name into the list of contributors with the next minor release.
This PR implements the proposal outlined in #26, with the goal of exposing a
Quads(): []*Quad
method onNormalisationAlgorithm
that lets users access a sorted, normalized slice of quads. This would be very useful to projects using json-gold's Quad and Dataset structs as a general RDF library.To recap, there are three changes:
Quads() []*Quad
method to theNormalisationAlgorithm
struct that just returns its internal.quads
field..quads
slice is sorted in addition to the slice of string n-quads lines.Main(dataset *RDFDataset, options *JsonLdOptions) (interface {}, error)
into a separate methodNormalize(dataset *RDFDatset)
that performs normalization and sorting, but doesn't construct the concatenated result or return anything.Main(...)
has the exact same interface and functionality, it just callsNormalize(dataset)
and then constructs the return value based on the options, but now users who just want to useQuads()
directly can just callNormalize()
.I couldn't figure out how to run proper tests (like from the ld/testdata/normalization folder?), but testing informally with all the datasets I have lying produced correct results.
Thanks so much for maintaining this library; it's fantastic to have high-quality tooling for RDF start to become more common!