ntriples

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Example (Example1)
package main

import (
	"embed"
	"fmt"

	_ "embed"
	nt "github.com/0x51-dev/rdf/ntriples"
)

var example1 string

func main() {
	doc, _ := nt.ParseDocument(example1)
	fmt.Println(doc)
}
Output:

<http://one.example/subject1> <http://one.example/predicate1> <http://one.example/object1> .
_:subject1 <http://an.example/predicate1> "object1" .
_:subject2 <http://an.example/predicate2> "object2" .

Index

Examples

Constants

View Source
const MediaType = "application/n-triples"

Variables

This section is empty.

Functions

func ToggleValidation

func ToggleValidation(enabled bool)

ToggleValidation enables/disables validation of IRIs.

Types

type BlankNode

type BlankNode string

func ParseBlankNodeLabel

func ParseBlankNodeLabel(n *parser.Node) (*BlankNode, error)

func (BlankNode) Equal

func (n BlankNode) Equal(v any) bool

Equal returns true if the blank node is equal to the given value.

func (BlankNode) String

func (n BlankNode) String() string

type Document

type Document []Triple

func ParseDocument

func ParseDocument(doc string) (Document, error)

func (Document) Equal

func (d Document) Equal(other Document) bool

Equal returns true if the document is equal to the given value. NOTE: blank nodes will be compared, not by value, but by relation in the document.

func (Document) Len

func (d Document) Len() int

func (Document) Less

func (d Document) Less(i, j int) bool

func (Document) NormalizeBlankNodes

func (d Document) NormalizeBlankNodes() (n Document)

func (Document) String

func (d Document) String() string

func (Document) Swap

func (d Document) Swap(i, j int)

type IRIReference

type IRIReference string

func ParseIRIReference

func ParseIRIReference(n *parser.Node) (*IRIReference, error)

func ParsePredicate

func ParsePredicate(n *parser.Node) (*IRIReference, error)

func (IRIReference) Equal

func (r IRIReference) Equal(v any) bool

Equal returns true if the IRI reference is equal to the given value.

func (IRIReference) IsValid

func (r IRIReference) IsValid() bool

func (IRIReference) String

func (r IRIReference) String() string

type Literal

type Literal struct {
	Value     string
	Reference *IRIReference
	Language  string
}

func ParseLiteral

func ParseLiteral(n *parser.Node) (*Literal, error)

func (Literal) Equal

func (l Literal) Equal(v any) bool

Equal returns true if the literal is equal to the given value.

func (Literal) String

func (l Literal) String() string

type Object

type Object interface {
	Equal(v any) bool
	fmt.Stringer
	// contains filtered or unexported methods
}

Object is either an IRI, a blank node, or a literal.

func ParseObject

func ParseObject(n *parser.Node) (Object, error)

type Subject

type Subject interface {
	Equal(v any) bool
	fmt.Stringer
	// contains filtered or unexported methods
}

Subject is either an IRI or a blank node.

func ParseSubject

func ParseSubject(n *parser.Node) (Subject, error)

type Triple

type Triple struct {
	Subject   Subject
	Predicate IRIReference
	Object    Object
}

func ParseTriple

func ParseTriple(n *parser.Node) (*Triple, error)

func (Triple) Equal

func (t Triple) Equal(v any) bool

Equal returns true if the triple is equal to the given value. NOTE: comparing blank nodes does not really make sense, as they are not globally unique.

func (Triple) String

func (t Triple) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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