ld

package
v0.0.0-...-26e7074 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RDFSyntaxNS string = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	RDFSchemaNS string = "http://www.w3.org/2000/01/rdf-schema#"
	XSDNS       string = "http://www.w3.org/2001/XMLSchema#"

	XSDAnyType string = XSDNS + "anyType"
	XSDBoolean string = XSDNS + "boolean"
	XSDDouble  string = XSDNS + "double"
	XSDInteger string = XSDNS + "integer"
	XSDFloat   string = XSDNS + "float"
	XSDDecimal string = XSDNS + "decimal"
	XSDAnyURI  string = XSDNS + "anyURI"
	XSDString  string = XSDNS + "string"

	RDFType         string = RDFSyntaxNS + "type"
	RDFFirst        string = RDFSyntaxNS + "first"
	RDFRest         string = RDFSyntaxNS + "rest"
	RDFNil          string = RDFSyntaxNS + "nil"
	RDFPlainLiteral string = RDFSyntaxNS + "PlainLiteral"
	RDFXMLLiteral   string = RDFSyntaxNS + "XMLLiteral"
	RDFObject       string = RDFSyntaxNS + "object"
	RDFLangString   string = RDFSyntaxNS + "langString"
	RDFList         string = RDFSyntaxNS + "List"
)

Variables

This section is empty.

Functions

func CloneDocument

func CloneDocument(value interface{}) interface{}

CloneDocument returns a cloned instance of the given document

func CompareShortestLeast

func CompareShortestLeast(a string, b string) bool

CompareShortestLeast compares two strings first based on length and then lexicographically.

func CompareValues

func CompareValues(v1 interface{}, v2 interface{}) bool

CompareValues compares two JSON-LD values for equality. Two JSON-LD values will be considered equal if:

1. They are both primitives of the same type and value. 2. They are both @values with the same @value, @type, and @language, OR 3. They both have @ids they are the same.

func DeepCompare

func DeepCompare(v1 interface{}, v2 interface{}, listOrderMatters bool) bool

DeepCompare returns true if v1 equals v2.

func DocumentFromReader

func DocumentFromReader(r io.Reader) (interface{}, error)

DocumentFromReader returns a document containing the contents of the JSON resource, streamed from the given Reader.

func FilterNode

func FilterNode(node map[string]interface{}, frame map[string]interface{}) (bool, error)

FilterNode returns true if the given node matches the given frame.

func FilterNodes

func FilterNodes(nodes map[string]interface{}, frame map[string]interface{}) (map[string]interface{}, error)

FilterNodes returns a map of all of the nodes that match a parsed frame.

func GetCanonicalDouble

func GetCanonicalDouble(v float64) string

GetCanonicalDouble returns a canonical string representation of a float64 number.

func GetFrameFlag

func GetFrameFlag(frame map[string]interface{}, name string, theDefault bool) bool

GetFrameFlag gets the frame flag value for the given flag name. If boolean value is not found, returns theDefault

func GetKeys

func GetKeys(m map[string]interface{}) []string

GetKeys returns all keys in the given object

func GetKeysString

func GetKeysString(m map[string]string) []string

GetKeysString returns all keys in the given map[string]string

func GetOrderedKeys

func GetOrderedKeys(m map[string]interface{}) []string

GetOrderedKeys returns all keys in the given object as a sorted list

func IsAbsoluteIri

func IsAbsoluteIri(value string) bool

IsAbsoluteIri returns true if the given value is an absolute IRI, false if not.

func IsBlankNode

func IsBlankNode(node Node) bool

IsBlankNode returns true if the given node is a blank node

func IsBlankNodeValue

func IsBlankNodeValue(v interface{}) bool

IsBlankNode returns true if the given value is a blank node.

func IsIRI

func IsIRI(node Node) bool

IsIRI returns true if the given node is an IRI node

func IsKeyword

func IsKeyword(key interface{}) bool

IsKeyword returns whether or not the given value is a keyword.

func IsLiteral

func IsLiteral(node Node) bool

IsLiteral returns true if the given node is a literal node

func IsNode

func IsNode(v interface{}) bool

IsNode returns true if the given value is a subject with properties.

Note: A value is a subject if all of these hold true: 1. It is an Object. 2. It is not a @value, @set, or @list. 3. It has more than 1 key OR any existing key is not @id.

func IsNodeReference

func IsNodeReference(v interface{}) bool

IsNodeReference returns true if the given value is a subject reference.

func IsReferencedOnce

func IsReferencedOnce(node *NodeMapNode, referencedOnce map[string]*UsagesNode) bool

IsReferencedOnce helps to solve https://github.com/json-ld/json-ld.org/issues/357 by identifying nodes with just one reference.

func IsRelativeIri

func IsRelativeIri(value string) bool

IsRelativeIri returns true if the given value is a relative IRI, false if not.

func IsValue

func IsValue(v interface{}) bool

IsValue returns true if the given value is a JSON-LD value

func MergeValue

func MergeValue(obj map[string]interface{}, key string, value interface{})

MergeValue adds a value to a subject. If the value is an array, all values in the array will be added.

func ParseLinkHeader

func ParseLinkHeader(header string) map[string][]map[string]string

ParseLinkHeader parses a link header. The results will be keyed by the value of "rel".

Link: <http://json-ld.org/contexts/person.jsonld>; \
  rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"
Parses as: {
  'http://www.w3.org/ns/json-ld#context': {
    target: http://json-ld.org/contexts/person.jsonld,
    rel:    http://www.w3.org/ns/json-ld#context
  }
}

If there is more than one "rel" with the same IRI, then entries in the resulting map for that "rel" will be lists.

func PrintDocument

func PrintDocument(msg string, doc interface{})

PrintDocument prints a JSON-LD document. This is useful for debugging.

func RemoveBase

func RemoveBase(baseobj interface{}, iri string) string

RemoveBase removes base URL from the given IRI.

func RemovePreserve

func RemovePreserve(ctx *Context, input interface{}, opts *JsonLdOptions) (interface{}, error)

RemovePreserve removes the @preserve keywords as the last step of the framing algorithm.

ctx: the active context used to compact the input input: the framed, compacted output opts: the compaction options used

Returns the resulting output.

func Resolve

func Resolve(baseURI string, pathToResolve string) string

Resolve the given path against the given base URI. Returns a full URI.

Types

type BlankNode

type BlankNode struct {
	Attribute string
}

BlankNode represents a blank node value.

func NewBlankNode

func NewBlankNode(attribute string) *BlankNode

NewBlankNode creates a new instance of BlankNode.

func (BlankNode) Equal

func (bn BlankNode) Equal(n Node) bool

Equal returns true id this node is equal to the given node.

func (BlankNode) GetValue

func (bn BlankNode) GetValue() string

GetValue returns the node's value.

type BlankNodeIDGenerator

type BlankNodeIDGenerator struct {
	// contains filtered or unexported fields
}

BlankNodeIDGenerator generates IDs for blank nodes as specified in http://www.w3.org/TR/json-ld-api/#generate-blank-node-identifier

func NewBlankNodeIDGenerator

func NewBlankNodeIDGenerator() *BlankNodeIDGenerator

NewBlankNodeIDGenerator creates and returns a new instance of BlankNodeIDGenerator

func (*BlankNodeIDGenerator) GenerateBlankNodeIdentifier

func (bnig *BlankNodeIDGenerator) GenerateBlankNodeIdentifier(id string) string

GenerateBlankNodeIdentifier generates a blank node identifier for the given key using the algorithm specified in: http://www.w3.org/TR/json-ld-api/#generate-blank-node-identifier

id: The id, or an empty string to generate a fresh, unused, blank node identifier.

Returns a blank node identifier based on id if it was not an empty string, or a fresh, unused, blank node identifier if it was an empty string.

type ByHash

type ByHash []*HashResult

ByHash helps sorting HashResult by hash

func (ByHash) Len

func (bh ByHash) Len() int

func (ByHash) Less

func (bh ByHash) Less(i, j int) bool

func (ByHash) Swap

func (bh ByHash) Swap(i, j int)

type CachingDocumentLoader

type CachingDocumentLoader struct {
	// contains filtered or unexported fields
}

CachingDocumentLoader is an overlay on top of DocumentLoader instance which allows caching documents as soon as they get retrieved from the underlying loader. You may also preload it with documents - this is useful for testing.

func NewCachingDocumentLoader

func NewCachingDocumentLoader(nextLoader DocumentLoader) *CachingDocumentLoader

NewCachingDocumentLoader creates a new instance of CachingDocumentLoader.

func (*CachingDocumentLoader) AddDocument

func (cdl *CachingDocumentLoader) AddDocument(u string, doc interface{})

AddDocument populates the cache with the given document (doc) for the provided URL (u).

func (*CachingDocumentLoader) LoadDocument

func (cdl *CachingDocumentLoader) LoadDocument(u string) (*RemoteDocument, error)

LoadDocument returns a RemoteDocument containing the contents of the JSON resource from the given URL.

func (*CachingDocumentLoader) PreloadWithMapping

func (cdl *CachingDocumentLoader) PreloadWithMapping(urlMap map[string]string) error

PreloadWithMapping populates the cache with a number of documents which may be loaded from location different from the original URL (most importantly, from local files).

Example:

l.PreloadWithMapping(map[string]string{
    "http://www.example.com/context.json": "/home/me/cache/example_com_context.json",
})

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context represents a JSON-LD context and provides easy access to specific keys and operations.

func CopyContext

func CopyContext(ctx *Context) *Context

CopyContext creates a full copy of the given context.

func NewContext

func NewContext(values map[string]interface{}, options *JsonLdOptions) *Context

NewContext creates and returns a new Context object.

func (*Context) CompactIri

func (c *Context) CompactIri(iri string, value interface{}, relativeToVocab bool, reverse bool) string

CompactIri compacts an IRI or keyword into a term or CURIE if it can be. If the IRI has an associated value it may be passed.

iri: the IRI to compact. value: the value to check or None. relativeToVocab: true to compact using @vocab if available, false not to. reverse: true if a reverse property is being compacted, false if not.

Returns the compacted term, prefix, keyword alias, or original IRI.

func (*Context) CompactValue

func (c *Context) CompactValue(activeProperty string, value map[string]interface{}) interface{}

CompactValue performs value compaction on an object with @value or @id as the only property. See http://www.w3.org/TR/json-ld-api/#value-compaction

func (*Context) ExpandIri

func (c *Context) ExpandIri(value string, relative bool, vocab bool, context map[string]interface{},
	defined map[string]bool) (string, error)

ExpandIri expands a string value to a full IRI.

The string may be a term, a prefix, a relative IRI, or an absolute IRI. The associated absolute IRI will be returned.

value: the string value to expand. relative: true to resolve IRIs against the base IRI, false not to. vocab: true to concatenate after @vocab, false not to. context: the local context being processed (only given if called during context processing). defined: a map for tracking cycles in context definitions (only given if called during context processing).

func (*Context) ExpandValue

func (c *Context) ExpandValue(activeProperty string, value interface{}) (interface{}, error)

ExpandValue expands the given value by using the coercion and keyword rules in the context.

func (*Context) GetContainer

func (c *Context) GetContainer(property string) string

GetContainer retrieves container mapping for the given property.

func (*Context) GetInverse

func (c *Context) GetInverse() map[string]interface{}

GetInverse generates an inverse context for use in the compaction algorithm, if not already generated for the given active context. See http://www.w3.org/TR/json-ld-api/#inverse-context-creation for further details.

func (*Context) GetLanguageMapping

func (c *Context) GetLanguageMapping(property string) string

GetLanguageMapping returns language mapping for the given property

func (*Context) GetPrefixes

func (c *Context) GetPrefixes(onlyCommonPrefixes bool) map[string]string

GetPrefixes returns a map of potential RDF prefixes based on the JSON-LD Term Definitions in this context. No guarantees of the prefixes are given, beyond that it will not contain ":".

onlyCommonPrefixes: If true, the result will not include "not so useful" prefixes, such as "term1": "http://example.com/term1", e.g. all IRIs will end with "/" or "#". If false, all potential prefixes are returned.

Returns a map from prefix string to IRI string

func (*Context) GetTermDefinition

func (c *Context) GetTermDefinition(key string) map[string]interface{}

GetTermDefinition returns a term definition for the given key

func (*Context) GetTypeMapping

func (c *Context) GetTypeMapping(property string) string

GetTypeMapping returns type mapping for the given property

func (*Context) IsReverseProperty

func (c *Context) IsReverseProperty(property string) bool

IsReverseProperty returns true if the given property is a reverse property

func (*Context) Parse

func (c *Context) Parse(localContext interface{}) (*Context, error)

Parse processes a local context, retrieving any URLs as necessary, and returns a new active context. Refer to http://www.w3.org/TR/json-ld-api/#context-processing-algorithms for details

func (*Context) SelectTerm

func (c *Context) SelectTerm(iri string, containers []string, typeLanguage string, preferredValues []string) string

SelectTerm picks the preferred compaction term from the inverse context entry. See http://www.w3.org/TR/json-ld-api/#term-selection

This algorithm, invoked via the IRI Compaction algorithm, makes use of an active context's inverse context to find the term that is best used to compact an IRI. Other information about a value associated with the IRI is given, including which container mappings and which type mapping or language mapping would be best used to express the value.

func (*Context) Serialize

func (c *Context) Serialize() map[string]interface{}

Serialize transforms the context back into JSON form.

type DefaultDocumentLoader

type DefaultDocumentLoader struct {
	// contains filtered or unexported fields
}

DefaultDocumentLoader is a standard implementation of DocumentLoader which can retrieve documents via HTTP.

func NewDefaultDocumentLoader

func NewDefaultDocumentLoader(httpClient *http.Client) *DefaultDocumentLoader

NewDefaultDocumentLoader creates a new instance of DefaultDocumentLoader

func (*DefaultDocumentLoader) LoadDocument

func (dl *DefaultDocumentLoader) LoadDocument(u string) (*RemoteDocument, error)

LoadDocument returns a RemoteDocument containing the contents of the JSON resource from the given URL.

type DocumentLoader

type DocumentLoader interface {
	LoadDocument(u string) (*RemoteDocument, error)
}

DocumentLoader knows how to load remote documents.

type EmbedNode

type EmbedNode struct {
	// contains filtered or unexported fields
}

EmbedNode represents embed meta info

type ErrorCode

type ErrorCode string

ErrorCode is a JSON-LD error code as per spec.

const (
	LoadingDocumentFailed       ErrorCode = "loading document failed"
	ListOfLists                 ErrorCode = "list of lists"
	InvalidIndexValue           ErrorCode = "invalid @index value"
	ConflictingIndexes          ErrorCode = "conflicting indexes"
	InvalidIDValue              ErrorCode = "invalid @id value"
	InvalidLocalContext         ErrorCode = "invalid local context"
	MultipleContextLinkHeaders  ErrorCode = "multiple context link headers"
	LoadingRemoteContextFailed  ErrorCode = "loading remote context failed"
	InvalidRemoteContext        ErrorCode = "invalid remote context"
	RecursiveContextInclusion   ErrorCode = "recursive context inclusion"
	InvalidBaseIRI              ErrorCode = "invalid base IRI"
	InvalidVocabMapping         ErrorCode = "invalid vocab mapping"
	InvalidDefaultLanguage      ErrorCode = "invalid default language"
	KeywordRedefinition         ErrorCode = "keyword redefinition"
	InvalidTermDefinition       ErrorCode = "invalid term definition"
	InvalidReverseProperty      ErrorCode = "invalid reverse property"
	InvalidIRIMapping           ErrorCode = "invalid IRI mapping"
	CyclicIRIMapping            ErrorCode = "cyclic IRI mapping"
	InvalidKeywordAlias         ErrorCode = "invalid keyword alias"
	InvalidTypeMapping          ErrorCode = "invalid type mapping"
	InvalidLanguageMapping      ErrorCode = "invalid language mapping"
	CollidingKeywords           ErrorCode = "colliding keywords"
	InvalidContainerMapping     ErrorCode = "invalid container mapping"
	InvalidTypeValue            ErrorCode = "invalid type value"
	InvalidValueObject          ErrorCode = "invalid value object"
	InvalidValueObjectValue     ErrorCode = "invalid value object value"
	InvalidLanguageTaggedString ErrorCode = "invalid language-tagged string"
	InvalidLanguageTaggedValue  ErrorCode = "invalid language-tagged value"
	InvalidTypedValue           ErrorCode = "invalid typed value"
	InvalidSetOrListObject      ErrorCode = "invalid set or list object"
	InvalidLanguageMapValue     ErrorCode = "invalid language map value"
	CompactionToListOfLists     ErrorCode = "compaction to list of lists"
	InvalidReversePropertyMap   ErrorCode = "invalid reverse property map"
	InvalidReverseValue         ErrorCode = "invalid @reverse value"
	InvalidReversePropertyValue ErrorCode = "invalid reverse property value"

	// non spec related errors
	SyntaxError    ErrorCode = "syntax error"
	NotImplemented ErrorCode = "not implemnted"
	UnknownFormat  ErrorCode = "unknown format"
	InvalidInput   ErrorCode = "invalid input"
	ParseError     ErrorCode = "parse error"
	IOError        ErrorCode = "io error"
	UnknownError   ErrorCode = "unknown error"
)

type FramingContext

type FramingContext struct {
	// contains filtered or unexported fields
}

FramingContext stores framing state

func NewFramingContext

func NewFramingContext(opts *JsonLdOptions) *FramingContext

NewFramingContext creates and returns as new framing context.

type HashResult

type HashResult struct {
	// contains filtered or unexported fields
}

HashResult

type IRI

type IRI struct {
	Value string
}

IRI represents an IRI value.

func NewIRI

func NewIRI(iri string) *IRI

NewIRI creates a new instance of IRI.

func (IRI) Equal

func (iri IRI) Equal(n Node) bool

Equal returns true id this node is equal to the given node.

func (IRI) GetValue

func (iri IRI) GetValue() string

GetValue returns the node's value.

type JsonLdApi

type JsonLdApi struct {
}

JsonLdApi exposes internal functions used by JsonLdProcessor. See http://www.w3.org/TR/json-ld-api/ for detailed description of underlying algorithms

Warning: using this interface directly is highly discouraged. Please use JsonLdProcessor instead.

func NewJsonLdApi

func NewJsonLdApi() *JsonLdApi

NewJsonLdApi creates a new instance of JsonLdApi.

func (*JsonLdApi) Compact

func (api *JsonLdApi) Compact(activeCtx *Context, activeProperty string, element interface{},
	compactArrays bool) (interface{}, error)

Compact operation compacts the given input using the context according to the steps in the Compaction Algorithm:

http://www.w3.org/TR/json-ld-api/#compaction-algorithm

Returns the compacted JSON-LD object. Returns an error if there was an error during compaction.

func (*JsonLdApi) Expand

func (api *JsonLdApi) Expand(activeCtx *Context, activeProperty string, element interface{}) (interface{}, error)

Expand operation expands the given input according to the steps in the Expansion algorithm:

http://www.w3.org/TR/json-ld-api/#expansion-algorithm

Returns the expanded JSON-LD object. Returns an error if there was an error during expansion.

func (*JsonLdApi) Frame

func (api *JsonLdApi) Frame(input interface{}, frame []interface{}, opts *JsonLdOptions) ([]interface{}, error)

Frame performs JSON-LD framing as defined in:

http://json-ld.org/spec/latest/json-ld-framing/

Frames the given input using the frame according to the steps in the Framing Algorithm. The input is used to build the framed output and is returned if there are no errors.

Returns the framed output.

func (*JsonLdApi) FromRDF

func (api *JsonLdApi) FromRDF(dataset *RDFDataset, opts *JsonLdOptions) ([]interface{}, error)

FromRDF converts RDF statements into JSON-LD. Returns a list of JSON-LD objects found in the given dataset.

func (*JsonLdApi) GenerateNodeMap

func (api *JsonLdApi) GenerateNodeMap(element interface{}, nodeMap map[string]interface{}, activeGraph string,
	activeSubject interface{}, activeProperty string, list map[string]interface{},
	idGen *BlankNodeIDGenerator) error

GenerateNodeMap recursively flattens the subjects in the given JSON-LD expanded input into a node map.

func (*JsonLdApi) Normalize

func (api *JsonLdApi) Normalize(dataset *RDFDataset, opts *JsonLdOptions) (interface{}, error)

Normalize performs RDF normalization on the given JSON-LD input. dataset: the expanded JSON-LD object to normalize. Returns the normalized JSON-LD object.

func (*JsonLdApi) ToRDF

func (api *JsonLdApi) ToRDF(input interface{}, opts *JsonLdOptions) (*RDFDataset, error)

ToRDF adds RDF triples for each graph in the current node map to an RDF dataset.

type JsonLdError

type JsonLdError struct {
	Code    ErrorCode
	Details interface{}
}

JsonLdError is a JSON-LD error as defined in the spec. See the allowed values and error messages below.

func NewJsonLdError

func NewJsonLdError(code ErrorCode, details interface{}) *JsonLdError

NewJsonLdError creates a new instance of JsonLdError.

func (JsonLdError) Error

func (e JsonLdError) Error() string

type JsonLdOptions

JsonLdOptions type as specified in the JSON-LD-API specification: http://www.w3.org/TR/json-ld-api/#the-jsonldoptions-type

func NewJsonLdOptions

func NewJsonLdOptions(base string) *JsonLdOptions

NewJsonLdOptions creates and returns new instance of JsonLdOptions with the given base.

type JsonLdProcessor

type JsonLdProcessor struct {
}

JsonLdProcessor implements the JsonLdProcessor interface, see http://www.w3.org/TR/json-ld-api/#the-jsonldprocessor-interface

func NewJsonLdProcessor

func NewJsonLdProcessor() *JsonLdProcessor

NewJsonLdProcessor creates an instance of JsonLdProcessor.

func (*JsonLdProcessor) Compact

func (jldp *JsonLdProcessor) Compact(input interface{}, context interface{},
	opts *JsonLdOptions) (map[string]interface{}, error)

Compact operation compacts the given input using the context according to the steps in the Compaction algorithm: http://www.w3.org/TR/json-ld-api/#compaction-algorithm

func (*JsonLdProcessor) Expand

func (jldp *JsonLdProcessor) Expand(input interface{}, opts *JsonLdOptions) ([]interface{}, error)

Expand operation expands the given input according to the steps in the Expansion algorithm: http://www.w3.org/TR/json-ld-api/#expansion-algorithm

func (*JsonLdProcessor) Flatten

func (jldp *JsonLdProcessor) Flatten(input interface{}, context interface{}, opts *JsonLdOptions) (interface{}, error)

Flatten operation flattens the given input and compacts it using the passed context according to the steps in the Flattening algorithm: http://www.w3.org/TR/json-ld-api/#flattening-algorithm

func (*JsonLdProcessor) Frame

func (jldp *JsonLdProcessor) Frame(input interface{}, frame interface{}, opts *JsonLdOptions) (map[string]interface{}, error)

Frame operation frames the given input using the frame according to the steps in the Framing Algorithm: http://json-ld.org/spec/latest/json-ld-framing/#framing-algorithm

input: The input JSON-LD object frame: The frame to use when re-arranging the data of input; either in the form of an JSON object or as IRI.

Returns the framed JSON-LD document.

func (*JsonLdProcessor) FromRDF

func (jldp *JsonLdProcessor) FromRDF(dataset interface{}, opts *JsonLdOptions) (interface{}, error)

FromRDF converts an RDF dataset to JSON-LD.

dataset: a serialized string of RDF in a format specified by the format option or an RDF dataset to convert. opts: the options to use:

[format] the format if input is not an array: 'application/nquads' for N-Quads (default).
[useRdfType] true to use rdf:type, false to use @type (default: false).
[useNativeTypes] true to convert XSD types into native types (boolean, integer, double),
false not to (default: true).

func (*JsonLdProcessor) Normalize

func (jldp *JsonLdProcessor) Normalize(input interface{}, opts *JsonLdOptions) (interface{}, error)

Normalize performs RDF dataset normalization on the given JSON-LD input. The output is an RDF dataset unless the 'format' option is used.

func (*JsonLdProcessor) ToRDF

func (jldp *JsonLdProcessor) ToRDF(input interface{}, opts *JsonLdOptions) (interface{}, error)

ToRDF outputs the RDF dataset found in the given JSON-LD object.

input: the JSON-LD input. opts: the options to use:

[base] the base IRI to use.
[format] the format to use to output a string: 'application/nquads' for N-Quads (default).

type JsonLdUrl

type JsonLdUrl struct {
	Href      string
	Protocol  string
	Host      string
	Auth      string
	User      string
	Password  string
	Hostname  string
	Port      string
	Relative  string
	Path      string
	Directory string
	File      string
	Query     string
	Hash      string

	// things not populated by the regex
	Pathname       string
	NormalizedPath string
	Authority      string
}

JsonLdUrl represents a URL split into individual components for easy manipulation. TODO: This implementation was taken from Java. Do we really need it in Go?

func ParseURL

func ParseURL(url string) *JsonLdUrl

ParseURL parses a string URL into JsonLdUrl struct.

type Literal

type Literal struct {
	Value    string
	Datatype string
	Language string
}

Literal represents a literal value.

func NewLiteral

func NewLiteral(value string, datatype string, language string) *Literal

NewLiteral creates a new instance of Literal.

func (Literal) Equal

func (l Literal) Equal(n Node) bool

Equal returns true id this node is equal to the given node.

func (Literal) GetValue

func (l Literal) GetValue() string

GetValue returns the node's value.

type NQuadRDFSerializer

type NQuadRDFSerializer struct {
}

NQuadRDFSerializer parses and serializes N-Quads.

func (*NQuadRDFSerializer) Parse

func (s *NQuadRDFSerializer) Parse(input interface{}) (*RDFDataset, error)

Parse N-Quads from string into an RDFDataset.

func (*NQuadRDFSerializer) Serialize

func (s *NQuadRDFSerializer) Serialize(dataset *RDFDataset) (interface{}, error)

Serialize an RDFDataset into N-Quad string.

func (*NQuadRDFSerializer) SerializeTo

func (s *NQuadRDFSerializer) SerializeTo(w io.Writer, dataset *RDFDataset) error

SerializeTo writes RDFDataset as N-Quad into a writer.

type Node

type Node interface {
	// GetValue returns the node's value.
	GetValue() string

	// Equal returns true id this node is equal to the given node.
	Equal(n Node) bool
}

Node is the value of a subject, predicate or object i.e. a IRI reference, blank node or literal.

type NodeMapNode

type NodeMapNode struct {
	Values map[string]interface{}
	// contains filtered or unexported fields
}

NodeMapNode

func NewNodeMapNode

func NewNodeMapNode(id string) *NodeMapNode

NewNodeMapNode creates a new instance of NodeMapNode.

func (*NodeMapNode) IsWellFormedListNode

func (nmn *NodeMapNode) IsWellFormedListNode() bool

IsWellFormedListNode is a helper function for 4.3.3

func (*NodeMapNode) Serialize

func (nmn *NodeMapNode) Serialize() map[string]interface{}

Serialize returns this node without the usages variable

type NormalizeUtils

type NormalizeUtils struct {
	// contains filtered or unexported fields
}

NormalizeUtils keeps the state of the Normalisation process

func NewNormalizeUtils

func NewNormalizeUtils(quads []*Quad, bnodes map[string]interface{}, namer *UniqueNamer,
	format string) *NormalizeUtils

NewNormalizeUtils creates a new instance of NormalizeUtils

func (*NormalizeUtils) HashBlankNodes

func (nu *NormalizeUtils) HashBlankNodes(unnamed []string) (interface{}, error)

HashBlankNodes generates unique and duplicate hashes for bnodes

type Permutator

type Permutator struct {
	// contains filtered or unexported fields
}

Permutator

func NewPermutator

func NewPermutator(list []string) *Permutator

NewPermutator creates a new instance of Permutator.

func (*Permutator) HasNext

func (p *Permutator) HasNext() bool

HasNext returns true if there is another permutation.

func (*Permutator) Next

func (p *Permutator) Next() []string

Next gets the next permutation. Call HasNext() to ensure there is another one first.

type Quad

type Quad struct {
	Subject   Node
	Predicate Node
	Object    Node
	Graph     Node
}

Quad represents an RDF quad.

func NewQuad

func NewQuad(subject Node, predicate Node, object Node, graph string) *Quad

NewQuad creates a new instance of Quad.

func (Quad) Equal

func (q Quad) Equal(o *Quad) bool

Equal returns true if this quad is equal to the given quad.

type RDFDataset

type RDFDataset struct {
	Graphs map[string][]*Quad
	// contains filtered or unexported fields
}

RDFDataset is an internal representation of an RDF dataset.

func NewRDFDataset

func NewRDFDataset() *RDFDataset

NewRDFDataset creates a new instance of RDFDataset.

func ParseNQuads

func ParseNQuads(input string) (*RDFDataset, error)

ParseNQuads parses RDF in the form of N-Quads.

func ParseNQuadsFrom

func ParseNQuadsFrom(o interface{}) (*RDFDataset, error)

ParseNQuadsFrom parses RDF in the form of N-Quads from io.Reader, []byte or string.

func (*RDFDataset) ClearNamespaces

func (ds *RDFDataset) ClearNamespaces()

ClearNamespaces clears all the namespaces in this dataset

func (*RDFDataset) GetContext

func (ds *RDFDataset) GetContext() map[string]interface{}

GetContext returns a valid context containing any namespaces set.

func (*RDFDataset) GetNamespace

func (ds *RDFDataset) GetNamespace(ns string) string

GetNamespace

func (*RDFDataset) GetNamespaces

func (ds *RDFDataset) GetNamespaces() map[string]string

GetNamespaces

func (*RDFDataset) GetQuads

func (ds *RDFDataset) GetQuads(graphName string) []*Quad

GetQuads returns a list of quads for the given graph

func (*RDFDataset) GraphToRDF

func (ds *RDFDataset) GraphToRDF(graphName string, graph map[string]interface{}, idGenerator *BlankNodeIDGenerator,
	produceGeneralizedRdf bool)

GraphToRDF creates an array of RDF triples for the given graph.

func (*RDFDataset) ParseContext

func (ds *RDFDataset) ParseContext(contextLike interface{}, opts *JsonLdOptions) error

ParseContext parses a context object and sets any namespaces found within it.

func (*RDFDataset) SetNamespace

func (ds *RDFDataset) SetNamespace(ns string, prefix string)

SetNamespace

type RDFSerializer

type RDFSerializer interface {
	// Parse the input into the internal RDF Dataset format.
	// The format is a map with the following structure:
	// {
	// 	   GRAPH_1: [ TRIPLE_1, TRIPLE_2, ..., TRIPLE_N ],
	//     GRAPH_2: [ TRIPLE_1, TRIPLE_2, ..., TRIPLE_N ],
	//     ...
	//     GRAPH_N: [ TRIPLE_1, TRIPLE_2, ..., TRIPLE_N ]
	// }
	//
	// GRAPH: Must be the graph name/IRI. If no graph is present for a triple,
	// add it to the "@default" graph TRIPLE: Must be a map with the following
	// structure:
	// {
	//     "subject" : SUBJECT,
	//     "predicate" : PREDICATE,
	//     "object" : OBJECT
	// }
	//
	// Each of the values in the triple map must also be a map with the
	// following key-value pairs:
	//
	// "value": The value of the node.
	// "subject" can be an IRI or blank node id.
	// "predicate" should only ever be an IRI
	// "object" can be and IRI or blank node id, or a literal value (represented
	//     as a string)
	// "type": "IRI" if the value is an IRI or "blank node" if the
	// value is a blank node. "object" can also be "literal" in the case of
	// literals. The value of "object" can also contain the following optional
	// key-value pairs:
	//
	// "language" : the language value of a string literal
	// "datatype" : the datatype of the literal. (if not set will default to XSD:string,
	//     if set to null, null will be used).
	//
	Parse(input interface{}) (*RDFDataset, error)

	// Serialize an RDFDataset
	Serialize(dataset *RDFDataset) (interface{}, error)
}

RDFSerializer can serialize and de-serialize RDFDatasets.

type RDFSerializerTo

type RDFSerializerTo interface {
	SerializeTo(w io.Writer, dataset *RDFDataset) error
}

RDFSerializerTo can serialize RDFDatasets into io.Writer.

type RemoteDocument

type RemoteDocument struct {
	DocumentURL string
	Document    interface{}
	ContextURL  string
}

RemoteDocument is a document retrieved from a remote source.

type ShortestLeast

type ShortestLeast []string

ShortestLeast is a struct which allows sorting using CompareShortestLeast function.

func (ShortestLeast) Len

func (s ShortestLeast) Len() int

func (ShortestLeast) Less

func (s ShortestLeast) Less(i, j int) bool

func (ShortestLeast) Swap

func (s ShortestLeast) Swap(i, j int)

type TurtleRDFSerializer

type TurtleRDFSerializer struct {
}

TurtleRDFSerializer parses and serializes Turtle data.

func (*TurtleRDFSerializer) Parse

func (s *TurtleRDFSerializer) Parse(input interface{}) (*RDFDataset, error)

Parse Turtle from string into an RDFDataset

func (*TurtleRDFSerializer) Serialize

func (s *TurtleRDFSerializer) Serialize(dataset *RDFDataset) (interface{}, error)

Serialize an RDFDataset into a Turtle string.

type UniqueNamer

type UniqueNamer struct {
	// contains filtered or unexported fields
}

UniqueNamer issues unique names, keeping track of any previously issued names.

func NewUniqueNamer

func NewUniqueNamer(prefix string) *UniqueNamer

NewUniqueNamer creates and returns a new UniqueNamer.

func (*UniqueNamer) Clone

func (un *UniqueNamer) Clone() *UniqueNamer

Clone copies this UniqueNamer.

func (*UniqueNamer) GetName

func (un *UniqueNamer) GetName(oldName string) string

GetName gets the new name for the given old name, where if no old name is given a new name will be generated.

func (*UniqueNamer) IsNamed

func (un *UniqueNamer) IsNamed(oldName string) bool

IsNamed returns true if there was already a name created for the given old name.

type UsagesNode

type UsagesNode struct {
	// contains filtered or unexported fields
}

UsagesNode is a helper class for node usages

func NewUsagesNode

func NewUsagesNode(node *NodeMapNode, property string, value map[string]interface{}) *UsagesNode

NewUsagesNode creates a new instance of UsagesNode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL