package rdfwriter
import "github.com/spdx/gordf/rdfwriter"
Index ¶
- func DisjointSet(triples []*parser.Triple) map[*parser.Node]*parser.Node
- func FilterTriples(triples []*parser.Triple, subject, predicate, object *string) (result []*parser.Triple)
- func GetAdjacencyList(triples []*parser.Triple) (adjList map[*parser.Node][]*parser.Node)
- func GetNodeToTriples(triples []*parser.Triple) (recoveryDS map[string][]*parser.Triple)
- func GetRootNodes(triples []*parser.Triple) (rootNodes []*parser.Node)
- func TopologicalSortTriples(triples []*parser.Triple) (sortedTriples []*parser.Triple, err error)
- func TriplesToString(triples []*parser.Triple, schemaDefinition map[string]uri.URIRef, tab string) (outputString string, err error)
- func WriteToFile(w io.Writer, triples []*parser.Triple, schemaDefinition map[string]uri.URIRef, tab string) error
Functions ¶
func DisjointSet ¶
func FilterTriples ¶
func FilterTriples(triples []*parser.Triple, subject, predicate, object *string) (result []*parser.Triple)
returns the triples that matches the input subject, object and the predicate.
reason behind using string pointers is that it allows the user to pass a nil if the user is unsure about the other types. For example, if the user wants all the triples with subject rdf:about, the user can call FilterTriples(triples, &rdfAboutString, nil, nil) where, rdfAboutString := "rdf:about"
func GetAdjacencyList ¶
returns an adjacency list from a list of triples Params:
triples: might be unordered
Output:
adjList: adjacency list which maps subject to object for each triple
func GetNodeToTriples ¶
Params:
triples: might be unordered
Output:
recoveryDS: subject to triple mapping that will help retrieve the triples after sorting the Subject: Object pairs.
func GetRootNodes ¶
from a given adjacency list, return a list of root-nodes which will be used to generate string forms of the nodes to be written.
func TopologicalSortTriples ¶
Interface for user to provide a list of triples and get the sorted one as the output
func TriplesToString ¶
func TriplesToString(triples []*parser.Triple, schemaDefinition map[string]uri.URIRef, tab string) (outputString string, err error)
function provided to the user for converting triples to string. Arg Description:
triples: list of triples of a rdf graph schemaDefinition: maps the prefix given by xmlns to the URI tab: tab character to be used in the output. It can be four-spaces, two-spaces, single tab character, double tab character, etc depending upon the choice of the user.
func WriteToFile ¶
func WriteToFile(w io.Writer, triples []*parser.Triple, schemaDefinition map[string]uri.URIRef, tab string) error
converts the input triples to string and writes it to the file. Args Description:
w: writer in which the output data will be written. rest all params are same as that of the TriplesToString function.
Source Files ¶
- Version
- v0.0.0-20250128162952-000978ccd6fb (latest)
- Published
- Jan 28, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 2 weeks ago –
Tools for package owners.