owl

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 11 Imported by: 1

Documentation

Overview

Package owl extracts classes and properties from an owl ontology and maps them to a Go model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBoolPropertyToGraph added in v1.1.0

func AddBoolPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj bool)

AddBoolPropertyToGraph adds the specified property to the graph

func AddClassPropertyToGraph added in v1.1.0

func AddClassPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj Thing)

AddClassPropertyToGraph adds the specified property to the graph

func AddDatePropertyToGraph added in v1.1.0

func AddDatePropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj time.Time)

AddDatePropertyToGraph adds the specified property to the graph

func AddDateTimePropertyToGraph added in v1.1.0

func AddDateTimePropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj time.Time)

AddDateTimePropertyToGraph adds the specified property to the graph

func AddDateTimeStampPropertyToGraph added in v1.1.0

func AddDateTimeStampPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj time.Time)

AddDateTimeStampPropertyToGraph adds the specified property to the graph

func AddDurationPropertyToGraph added in v1.1.0

func AddDurationPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj time.Duration)

AddDurationPropertyToGraph adds the specified property to the graph

func AddFloatPropertyToGraph added in v1.1.0

func AddFloatPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj float64)

AddFloatPropertyToGraph adds the specified property to the graph

func AddGDayPropertyToGraph added in v1.1.0

func AddGDayPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj time.Time)

AddGDayPropertyToGraph adds the specified property to the graph

func AddGMonthPropertyToGraph added in v1.1.0

func AddGMonthPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj time.Time)

AddGMonthPropertyToGraph adds the specified property to the graph

func AddGYearMonthPropertyToGraph added in v1.1.0

func AddGYearMonthPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj time.Time)

AddGYearMonthPropertyToGraph adds the specified property to the graph

func AddGYearPropertyToGraph added in v1.1.0

func AddGYearPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj time.Time)

AddGYearPropertyToGraph adds the specified property to the graph

func AddIntPropertyToGraph added in v1.1.0

func AddIntPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj int)

AddIntPropertyToGraph adds the specified property to the graph

func AddInterfacePropertyToGraph added in v1.1.0

func AddInterfacePropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj interface{})

AddInterfacePropertyToGraph adds the specified property to the graph

func AddObjectToGraph added in v1.1.0

func AddObjectToGraph(g *rdf.Graph, typeIRI string, res Thing) (node *rdf.Node)

AddObjectToGraph adds the specified object to the graph

func AddStringPropertyToGraph added in v1.1.0

func AddStringPropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj string)

AddStringPropertyToGraph adds the specified property to the graph

func AddTimePropertyToGraph added in v1.1.0

func AddTimePropertyToGraph(g *rdf.Graph, propIRI string, subjNode *rdf.Node, obj time.Time)

AddTimePropertyToGraph adds the specified property to the graph

func ParseXsdDuration added in v1.1.0

func ParseXsdDuration(in string) (out time.Duration, err error)

ParseXsdDuration parses xsdDuration

Types

type Class

type Class struct {
	Node         *rdf.Node      // graph Node of class
	Parent       []*Class       // all direct parent classes of class
	Child        []*Class       // all direct children classes of class
	Enumeration  []*Individual  // enumerations in owl:OneOf
	Restriction  []*Restriction // restrictions of class in owl:Restriction
	Intersection []*Class       // intersections in owl:IntersectionOf
	Union        []*Class       // unions in owl:UnionOf
	Complement   []*Class       // complements in owl:Complement
	Name         string         // class name (IRI)
	Comment      string         // comment
}

Class is one ontology class

func GetBaseClass

func GetBaseClass(values []string, classes map[string]*Class) (base *Class, err error)

GetBaseClass returns the base class of all values

func GetBaseType

func GetBaseType(individual []string, individuals map[string]*Individual,
	classes map[string]*Class) (base *Class, err error)

GetBaseType returns the base type of specified individuals

func (*Class) GetAllParents

func (class *Class) GetAllParents() (parents []*Class)

GetAllParents returns all transitive parents

func (*Class) GetRestrictions

func (class *Class) GetRestrictions() (ret []*Restriction)

GetRestrictions returns all restrictions of a class and its base classes

func (*Class) GetRestrictionsInverse

func (class *Class) GetRestrictionsInverse() (ret []*Restriction)

GetRestrictionsInverse returns all restrictions of a class and its base classes prioritizing base class restrictions

func (*Class) String

func (class *Class) String() (ret string)

String prints a class

type GoClass

type GoClass struct {
	IRI          string       // iri of class
	Name         string       // class name
	Parent       []string     // parent classes (also transitive)
	DirectParent []string     // direct parent classes
	Property     []GoProperty // properties of class
	Comment      string       // comment for doc
	Model        *GoModel     // pointer to model
}

GoClass holds properties of a class

type GoIndividual

type GoIndividual struct {
	IRI  string // Individual iri
	Name string // name of individual
	Typ  string // type of individual (class)
}

GoIndividual individuals

type GoModel

type GoModel struct {
	Class       map[string]GoClass // map className->Class
	Individual  []GoIndividual     // all individuals
	IRI         string             // ontology iri
	Description string             // description extracted from ontology
	Name        string             // name (part of iri)
	Content     []byte             // ontology in ttl
	Module      string             // Go module name
}

GoModel holds all classes

func MapModel

func MapModel(ont *Ontology, moduleName string) (mod GoModel, err error)

MapModel extracts the model from an ontology

type GoProperty

type GoProperty struct {
	IRI          string      // IRI
	Name         string      // name
	Capital      string      // name with capital first letter
	Typ          [2]string   // type in struct (child of BaseTyp, 0: typ; 1: IRI)
	BaseTyp      [2]string   // type in interface
	AllowedTyp   [][2]string // allowed types (children of Typ)
	XSDTyp       string      // XSD type if any
	Individual   []string    // predefined Individuals
	Multi        bool        // multiple values possible?
	Multiplicity string      // multiplicity (slice or single value)
	Comment      string      // comment for doc
	Inverse      string      // inverse property if any
	Symmetric    bool        // symmetric?
}

GoProperty holds condiguration of a property

type Individual

type Individual struct {
	Node          *rdf.Node     // graph node of individual
	Comment       string        // comment
	Name          string        // name
	Type          *Class        // value type
	SameAs        *Individual   // owl:sameAs
	DifferentFrom *Individual   // owl:differentFrom
	AllDifferent  []*Individual // owl:AllDifferent
}

Individual is one ontology individual

func (*Individual) String

func (ind *Individual) String() (ret string)

String prints a individual

type Ontology

type Ontology struct {
	IRI         string
	Class       map[string]*Class      // all classes (key = iri)
	Property    map[string]*Property   // all properties (key = iri)
	Individual  map[string]*Individual // all individuals (key = iri)
	Imports     map[string][]string    // imported ontologies
	Description map[string]string      // comment about Ontology
	Content     map[string][]byte      // Ontology specification in ttl format
	// contains filtered or unexported fields
}

Ontology holds all information of one ontology

func ExtractOntology

func ExtractOntology(input io.Reader) (on Ontology, err error)

ExtractOntology extracts all classes, properties, individuals and imports

func ExtractOntologyLink(link string) (on Ontology, err error)

ExtractOntologyLink extracts all classes, properties, individuals and imports

type Property

type Property struct {
	Node                *rdf.Node   // graph node of property
	Name                string      // name of property (IRI)
	Comment             string      // comment
	Domain              []*Class    // rdfs:domain
	Range               []string    // rdfs:range
	Equivalent          *Property   // owl:equivalentProperty
	Inverse             *Property   // owl:inverseOf
	SubPropertyOf       []*Property //owl:subPropertyOf
	Type                string      // object or datatype property
	IsFunctional        bool        // owl:functionalProperty
	IsInverseFunctional bool        // owlInverseFunctionalProperty
	IsTransitive        bool        // owl:TransistiveProperty
	IsSymmetric         bool        // owl:SysmmetricProperty
}

Property is one ontology property

func (*Property) String

func (prop *Property) String() (ret string)

String prints a property

type Restriction

type Restriction struct {
	Node                  *rdf.Node // graph node of restriction
	Property              *Property // property
	ValueConstraint       string    // owl:allValuesFrom, owl:someValuesFrom or owl:hasValue
	CardinalityConstraint string    // owl:maxCardinality, owl:minCardinality or owl:cardinality
	Multiplicity          int       // if restriction has cardinality constraint this shows the multiplicity
	Value                 []string  // value type
}

Restriction is a restriction of a class property

type Thing

type Thing interface {
	IRI() string
	String() string
	InitFromNode(*rdf.Node) error
	ToGraph(*rdf.Graph)
	RemoveObject(Thing, string)
}

Thing is the common base class of all types (owl:Thing)

Jump to

Keyboard shortcuts

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