reasoner

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: 7 Imported by: 0

Documentation

Overview

Service reasoner provides a knowledge base and inference engine.

Index

Constants

This section is empty.

Variables

View Source
var Module = &services.Module{
	Name:        "reasoner",
	Version:     "1.0",
	NewInstance: NewService,
}

Functions

func AddNamespacePrefix

func AddNamespacePrefix(s string, ns map[string]string) string

func BuildQuery

func BuildQuery(q *sparql.Query, facts []*Fact) *sparql.Query

func CreateURIFromLiteral

func CreateURIFromLiteral(s string) string

func FillVariables

func FillVariables(fs []*Fact)

func FormSentences

func FormSentences(fs []*Fact) []string

func GetLabelMappings

func GetLabelMappings(fs []*Fact) (map[string]string, []string)

func GuessType

func GuessType(s string) string

func ToJsonLd

func ToJsonLd(fs []*Fact) []interface{}

Types

type Dependencies

type Dependencies struct {
	DB     *gorm.DB
	Client sarif.Client
}

type Fact

type Fact struct {
	Id int64 `json:"-"`

	Subject   string `json:"subject"`
	Predicate string `json:"predicate"`
	Object    string `json:"object"`

	SubjectType   string    `json:"subject_type" sql:"-"`
	PredicateType string    `json:"predicate_type" sql:"-"`
	ObjectType    string    `json:"object_type" sql:"-"`
	UpdatedAt     time.Time `json:"updated_at,omitempty" sql:"index"`
}

func ApplyBindings

func ApplyBindings(fs []*Fact, bs []sparql.Row, ns map[string]string) []*Fact

func (*Fact) Each

func (f *Fact) Each(fn func(string) string)

func (*Fact) EachType

func (f *Fact) EachType(fn func(v, t string) (string, string))

func (*Fact) FillMissingTypes

func (f *Fact) FillMissingTypes()

func (Fact) String

func (f Fact) String() string

type Service

type Service struct {
	DB *gorm.DB
	sarif.Client
}

func NewService

func NewService(deps *Dependencies) *Service

func (*Service) AddLabelFacts

func (s *Service) AddLabelFacts(fs []*Fact) ([]*Fact, error)

func (*Service) Enable

func (s *Service) Enable() error

func (*Service) HandleQuery

func (s *Service) HandleQuery(msg sarif.Message)

func (*Service) HandleQueryExternal

func (s *Service) HandleQueryExternal(msg sarif.Message)

func (*Service) HandleStore

func (s *Service) HandleStore(msg sarif.Message)

func (*Service) InterpretLiterals

func (s *Service) InterpretLiterals(f Fact) (Fact, error)

Jump to

Keyboard shortcuts

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