This library helps you extracting graphs and data triples from a plain text pseudo Turtle format intended to be intuitive but powerful, and maybe eventually quite complete.
{ context : Dict String String
, triples : Triples
, subject : Maybe String
}
Holds a pseudo-Turtle document, containing context (for adressing vocabularies, currently not used), triples and an optional "current" subject.
Dict String (List ( String
, String )
}
Holds triple data: subjects as keys, and lists of predicate-object pairs for values.
empty : Document
Represents an empty pseudo-Turtle document.
fromString : String -> Document
Convert a text string in pseudo-Turtle format into a Document containing triples, a context (not used yet, but it is used for supporting multiple meanings for the same word, or precisely pinning which meaning is intended), and an optional subject (used during parsing as "the current subject").
toNodesEdgesLabels : Document -> { nodes : List String, edges : List ( Basics.Int, Basics.Int ), labels : Dict ( Basics.Int, Basics.Int ) String }
Convert a Document with triples into a list of nodes, a list of edges between nodes and labels for use with elm-community/graph.
{ nodes, edges, labels } =
source
|> Knowledge.Graph.PseudoTurtle.fromString
|> Knowledge.Graph.PseudoTurtle.toNodesEdgesLabels
graph =
Graph.fromNodeLabelsAndEdgePairs nodes edges