sparql

package
v0.0.0-...-0dfd57a Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sparql implements a simple SPARQL client and query builder.

Index

Constants

This section is empty.

Variables

View Source
var (
	CommonPrefixes = map[string]string{
		"sarif": "sarif://schema/",

		"dbpedia":      "http://dbpedia.org/resource/",
		"dbpedia-owl":  "http://dbpedia.org/ontology/",
		"dbpedia-prop": "http://dbpedia.org/property/",
		"foaf":         "http://xmlns.com/foaf/0.1/",
		"freebase-key": "http://rdf.freebase.com/key/",
		"freebase-ns":  "http://rdf.freebase.com/ns/",
		"mo":           "http://purl.org/ontology/mo/",
		"owl":          "http://www.w3.org/2002/07/owl#",
		"rdf":          "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
		"rdfs":         "http://www.w3.org/2000/01/rdf-schema#",
		"schema":       "http://schema.org/",
		"vcard":        "http://www.w3.org/2006/vcard/ns#",
		"yago":         "http://yago-knowledge.org/resource/",
		"xsd":          "http://www.w3.org/2001/XMLSchema#",
	}
)
View Source
var (
	DBPedia = NewEndpoint("http://dbpedia.org/sparql")
)

Functions

This section is empty.

Types

type Endpoint

type Endpoint interface {
	Select(q string, result interface{}) error
	Describe(q string, result interface{}) error
}

type GenericEndpoint

type GenericEndpoint struct {
	Url string
}

func NewEndpoint

func NewEndpoint(url string) *GenericEndpoint

func (*GenericEndpoint) Describe

func (p *GenericEndpoint) Describe(q string, result interface{}) error

func (*GenericEndpoint) Query

func (p *GenericEndpoint) Query() *Query

func (*GenericEndpoint) Select

func (p *GenericEndpoint) Select(q string, result interface{}) error

type Query

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

func New

func New(ep ...Endpoint) *Query

func (*Query) Describe

func (q *Query) Describe(fields ...string) *Query

func (*Query) Exec

func (q *Query) Exec(result interface{}) error

func (*Query) Filter

func (q *Query) Filter(fs ...string) *Query

func (*Query) FilterLang

func (q *Query) FilterLang(v, lang string) *Query

func (*Query) Optional

func (q *Query) Optional(s, p, o string) *Query

func (*Query) Prefix

func (q *Query) Prefix(p, uri string) *Query

func (*Query) Select

func (q *Query) Select(fields ...string) *Query

func (*Query) String

func (q *Query) String() string

func (*Query) Where

func (q *Query) Where(s, p, o string) *Query

type Resource

type Resource struct {
	Type     string `json:"type"`
	DataType string `json:"datatype"`
	Value    string `json:"value"`
}

type ResourceResponse

type ResourceResponse struct {
	Results struct {
		Bindings []Row `json:"bindings"`
	} `json:"results"`
}

type Row

type Row map[string]Resource

type Triple

type Triple struct {
	Subject   string
	Predicate string
	Object    string
}

func (Triple) String

func (t Triple) String() string

Jump to

Keyboard shortcuts

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