scanner

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package scanner implements parsing Turtle data provided as a byte slice and reading it triple by triple. It handles the compact version of Turtle just as the N-triples version where each row corresponds to a single triple. It handles @base and @forms. It ignores comments and labels and data types assigned to object literals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// If set, URLs will be shortened to their relative representation to the base.
	Base string
	// If set, URLs will be shortened to their relative representation to the
	// base of the prefix on match, and the prefix applied. Resource tags ("<>")
	// will be omitted from this representation.
	Prefixes map[string]string
}

Options changes the behavior of the scanner. It is passed to NewWithOptions.

type Scanner

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

Scanner uses bufio.Scanner to parse the provided byte slice word by word. It keeps information about prefixes and base of the provided graph and the next triple to be read.

func New

func New(data []byte) *Scanner

New accepts a byte slice of the Turtle data and returns a new scanner.Scanner.

func NewWithOptions

func NewWithOptions(data []byte, options Options) *Scanner

func (*Scanner) Base

func (s *Scanner) Base() string

Base returns empty string in case there was no base specified in the so far scanned content and returns the string of the base prefix in case there was.

func (*Scanner) Next

func (s *Scanner) Next() bool

Next tries to extract a next triple or multiple triples from the provided data, when succesful it stores the new triples and returns true. If not it returns false. Another calls to Next would also return false.

func (*Scanner) Prefixes

func (s *Scanner) Prefixes() map[string]string

Prefixes returns all prefixes from the so far scanned content.

func (*Scanner) Triple

func (s *Scanner) Triple() [3]string

Triple returns the next triple

func (*Scanner) TripleWithAnnotations

func (s *Scanner) TripleWithAnnotations() [6]string

TripleWithAnnotations returns the next triple with label and datatype

Jump to

Keyboard shortcuts

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